no message
This was SVN commit r364.
This commit is contained in:
parent
7c86e3459e
commit
0ce04bf73f
@ -13,7 +13,7 @@
|
||||
#include <xercesc/util/PlatformUtils.hpp>
|
||||
|
||||
// Gee's custom error handler
|
||||
#include <ps/XercesErrorHandler.h>
|
||||
#include "ps/XercesErrorHandler.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "xerces-c_2.lib")
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "types.h"
|
||||
#include "lib.h"
|
||||
|
||||
#include "sdl.h" // endian functions
|
||||
|
||||
|
||||
// more powerful atexit, with 0 or 1 parameters.
|
||||
// callable before libc initialized, frees up the real atexit table,
|
||||
@ -291,7 +293,7 @@ u8 fp_to_u8(double in)
|
||||
return 255;
|
||||
}
|
||||
|
||||
int l = round(in * 255.0);
|
||||
int l = (int)(in * 255.0);
|
||||
assert((unsigned int)l <= 255);
|
||||
return (u8)l;
|
||||
}
|
||||
@ -306,13 +308,36 @@ u16 fp_to_u16(double in)
|
||||
return 65535;
|
||||
}
|
||||
|
||||
long l = round(in * 65535.0);
|
||||
long l = (long)(in * 65535.0);
|
||||
assert((unsigned long)l <= 65535);
|
||||
return (u16)l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inline u16 read_le16(const void* p)
|
||||
{
|
||||
#if SDL_BYTE_ORDER == SDL_BIG_ENDIAN
|
||||
const u8* _p = (const u8*)p;
|
||||
return (u16)_p[0] | (u16)_p[1] << 8;
|
||||
#else
|
||||
return *(u16*)p;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline u32 read_le32(const void* p)
|
||||
{
|
||||
#if SDL_BYTE_ORDER == SDL_BIG_ENDIAN
|
||||
return SDL_Swap32(*(u32*)p);
|
||||
#else
|
||||
return *(u32*)p;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// big endian!
|
||||
void base32(const int len, const u8* in, u8* out)
|
||||
{
|
||||
|
@ -199,7 +199,7 @@ extern int atexit2(void* func, uintptr_t arg, CallConvention cc = CC_CDECL_1);
|
||||
extern int atexit2(void* func);
|
||||
inline int atexit2(void (*func)())
|
||||
{
|
||||
atexit2((void *)func);
|
||||
return atexit2((void *)func);
|
||||
}
|
||||
|
||||
|
||||
@ -238,33 +238,8 @@ extern u16 addusw(u16 x, u16 y);
|
||||
extern u16 subusw(u16 x, u16 y);
|
||||
|
||||
|
||||
|
||||
|
||||
static inline u16 read_le16(const void* p)
|
||||
{
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
const u8* _p = (const u8*)p;
|
||||
return (u16)_p[0] | (u16)_p[1] << 8;
|
||||
#else
|
||||
return *(u16*)p;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static inline u32 read_le32(const void* p)
|
||||
{
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
u32 t = 0;
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
t <<= 8;
|
||||
t |= *((const u8*)p)++;
|
||||
}
|
||||
return t;
|
||||
#else
|
||||
return *(u32*)p;
|
||||
#endif
|
||||
}
|
||||
extern u16 read_le16(const void* p);
|
||||
extern u32 read_le32(const void* p);
|
||||
|
||||
|
||||
extern bool is_pow2(long n);
|
||||
|
Loading…
Reference in New Issue
Block a user