-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: move code using type-punned pointers to dedicated files
This allows to only use the -fno-strict-aliasing compilation flag on that code, nothing else.
- Loading branch information
Showing
6 changed files
with
128 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
=========================================================================== | ||
Daemon GPL Source Code | ||
Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company. | ||
This file is part of the Daemon GPL Source Code (Daemon Source Code). | ||
Daemon Source Code is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Daemon Source Code is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Daemon Source Code. If not, see <http://www.gnu.org/licenses/>. | ||
In addition, the Daemon Source Code is also subject to certain additional terms. | ||
You should have received a copy of these additional terms immediately following the | ||
terms and conditions of the GNU General Public License which accompanied the Daemon | ||
Source Code. If not, please request a copy in writing from id Software at the address | ||
below. | ||
If you have questions concerning this license or the applicable additional terms, you | ||
may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, | ||
Maryland 20850 USA. | ||
=========================================================================== | ||
*/ | ||
|
||
// This file should be built with the -fno-strict-aliasing flag. | ||
|
||
#include "qcommon.h" | ||
|
||
void MSG_WriteDeltaFloat( msg_t *msg, float oldV, float newV ) | ||
{ | ||
if ( oldV == newV ) | ||
{ | ||
MSG_WriteBits( msg, 0, 1 ); | ||
return; | ||
} | ||
|
||
MSG_WriteBits( msg, 1, 1 ); | ||
MSG_WriteBits( msg, * ( int * ) &newV, 32 ); | ||
} | ||
|
||
float MSG_ReadDeltaFloat( msg_t *msg, float oldV ) | ||
{ | ||
if ( MSG_ReadBits( msg, 1 ) ) | ||
{ | ||
float newV; | ||
|
||
* ( int * ) &newV = MSG_ReadBits( msg, 32 ); | ||
return newV; | ||
} | ||
|
||
return oldV; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
=========================================================================== | ||
Copyright (C) 1999-2005 Id Software, Inc. | ||
Copyright (C) 2006-2011 Robert Beckebans <[email protected]> | ||
Copyright (C) 2009 Peter McNeill <[email protected]> | ||
This file is part of Daemon source code. | ||
Daemon source code is free software; you can redistribute it | ||
and/or modify it under the terms of the GNU General Public License as | ||
published by the Free Software Foundation; either version 2 of the License, | ||
or (at your option) any later version. | ||
Daemon source code is distributed in the hope that it will be | ||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Daemon source code; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
=========================================================================== | ||
*/ | ||
|
||
// This file should be built with the -fno-strict-aliasing flag. | ||
|
||
#include "tr_local.h" | ||
|
||
unsigned int VertexCoordGenerateHash( const vec3_t xyz ) | ||
{ | ||
unsigned int hash = 0; | ||
|
||
#ifndef HASH_USE_EPSILON | ||
hash += ~( * ( ( unsigned int * ) &xyz[ 0 ] ) << 15 ); | ||
hash ^= ( * ( ( unsigned int * ) &xyz[ 0 ] ) >> 10 ); | ||
hash += ( * ( ( unsigned int * ) &xyz[ 1 ] ) << 3 ); | ||
hash ^= ( * ( ( unsigned int * ) &xyz[ 1 ] ) >> 6 ); | ||
hash += ~( * ( ( unsigned int * ) &xyz[ 2 ] ) << 11 ); | ||
hash ^= ( * ( ( unsigned int * ) &xyz[ 2 ] ) >> 16 ); | ||
#else | ||
vec3_t xyz_epsilonspace; | ||
|
||
VectorScale( xyz, HASH_XYZ_EPSILONSPACE_MULTIPLIER, xyz_epsilonspace ); | ||
xyz_epsilonspace[ 0 ] = floor( xyz_epsilonspace[ 0 ] ); | ||
xyz_epsilonspace[ 1 ] = floor( xyz_epsilonspace[ 1 ] ); | ||
xyz_epsilonspace[ 2 ] = floor( xyz_epsilonspace[ 2 ] ); | ||
|
||
hash += ~( * ( ( unsigned int * ) &xyz_epsilonspace[ 0 ] ) << 15 ); | ||
hash ^= ( * ( ( unsigned int * ) &xyz_epsilonspace[ 0 ] ) >> 10 ); | ||
hash += ( * ( ( unsigned int * ) &xyz_epsilonspace[ 1 ] ) << 3 ); | ||
hash ^= ( * ( ( unsigned int * ) &xyz_epsilonspace[ 1 ] ) >> 6 ); | ||
hash += ~( * ( ( unsigned int * ) &xyz_epsilonspace[ 2 ] ) << 11 ); | ||
hash ^= ( * ( ( unsigned int * ) &xyz_epsilonspace[ 2 ] ) >> 16 ); | ||
|
||
#endif | ||
|
||
hash = hash % ( HASHTABLE_SIZE ); | ||
return hash; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters