# new year's cleanup (reduce dependencies, clean up headers)

- remove headers always included from PCH
- nommgr.h is only included ifdef REDEFINED_NEW (allows leaving out the
mmgr stuff)
- in lib/*.cpp, moved the corresponding include file to right behind the
PCH (catches headers that aren't compilable by themselves)
- byte_order no longer depends on SDL
- add debug_level (another means of filtering debug output; needed for
thesis)
- split posix stuff up into subdirs (lib/posix and sysdep/win/wposix).
makes including only some of the modules (e.g. sockets, time) much
easier.

This was SVN commit r4728.
This commit is contained in:
janwas
2007-01-01 21:25:47 +00:00
parent 2d1543b93b
commit 0bb0df5b2c
156 changed files with 1944 additions and 1786 deletions
+43 -14
View File
@@ -21,15 +21,44 @@
*/
#include "precompiled.h"
#include "byte_order.h"
#include "sdl.h"
#ifndef swap16
u16 swap16(const u16 x)
{
return (u16)(((x & 0xff) << 8) | (x >> 8));
}
u32 swap32(const u32 x)
{
return (x << 24) |
(x >> 24) |
((x << 8) & 0x00ff0000) |
((x >> 8) & 0x0000ff00);
}
u64 swap64(const u64 x)
{
const u32 lo = (u32)(x & 0xFFFFFFFF);
const u32 hi = (u32)(x >> 32);
u64 ret = swap32(lo);
ret <<= 32;
// careful: must shift var of type u64, not u32
ret |= swap32(hi);
return ret;
}
#endif // #ifndef swap16
//-----------------------------------------------------------------------------
u16 to_le16(u16 x)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
return SDL_Swap16(x);
#if BYTE_ORDER == BIG_ENDIAN
return swap16(x);
#else
return x;
#endif
@@ -37,8 +66,8 @@ u16 to_le16(u16 x)
u32 to_le32(u32 x)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
return SDL_Swap32(x);
#if BYTE_ORDER == BIG_ENDIAN
return swap32(x);
#else
return x;
#endif
@@ -46,8 +75,8 @@ u32 to_le32(u32 x)
u64 to_le64(u64 x)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
return SDL_Swap64(x);
#if BYTE_ORDER == BIG_ENDIAN
return swap64(x);
#else
return x;
#endif
@@ -56,28 +85,28 @@ u64 to_le64(u64 x)
u16 to_be16(u16 x)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#if BYTE_ORDER == BIG_ENDIAN
return x;
#else
return SDL_Swap16(x);
return swap16(x);
#endif
}
u32 to_be32(u32 x)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#if BYTE_ORDER == BIG_ENDIAN
return x;
#else
return SDL_Swap32(x);
return swap32(x);
#endif
}
u64 to_be64(u64 x)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#if BYTE_ORDER == BIG_ENDIAN
return x;
#else
return SDL_Swap64(x);
return swap64(x);
#endif
}