mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
common.c (COM_Init): updated endianism check.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@48 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
44ad29724b
commit
4065ce7280
1 changed files with 21 additions and 6 deletions
|
@ -1204,12 +1204,28 @@ COM_Init
|
|||
*/
|
||||
void COM_Init (char *basedir)
|
||||
{
|
||||
byte swaptest[2] = {1,0};
|
||||
int i = 0x12345678;
|
||||
/* U N I X */
|
||||
|
||||
// set the byte swapping variables in a portable manner
|
||||
if ( *(short *)swaptest == 1)
|
||||
{
|
||||
/*
|
||||
BE_ORDER: 12 34 56 78
|
||||
U N I X
|
||||
|
||||
LE_ORDER: 78 56 34 12
|
||||
X I N U
|
||||
|
||||
PDP_ORDER: 34 12 78 56
|
||||
N U X I
|
||||
*/
|
||||
if ( *(char *)&i == 0x12 )
|
||||
bigendien = true;
|
||||
else if ( *(char *)&i == 0x78 )
|
||||
bigendien = false;
|
||||
else /* if ( *(char *)&i == 0x34 ) */
|
||||
Sys_Error ("Unsupported endianism.");
|
||||
|
||||
if (bigendien == false)
|
||||
{
|
||||
BigShort = ShortSwap;
|
||||
LittleShort = ShortNoSwap;
|
||||
BigLong = LongSwap;
|
||||
|
@ -1217,9 +1233,8 @@ void COM_Init (char *basedir)
|
|||
BigFloat = FloatSwap;
|
||||
LittleFloat = FloatNoSwap;
|
||||
}
|
||||
else
|
||||
else /* we are big endian: */
|
||||
{
|
||||
bigendien = true;
|
||||
BigShort = ShortNoSwap;
|
||||
LittleShort = ShortSwap;
|
||||
BigLong = LongNoSwap;
|
||||
|
|
Loading…
Reference in a new issue