config: add endian detect

byte_order: use config.h defines (avoids pulling in sdl.h everywhere)
precompiled: now include *all* C++ headers

This was SVN commit r2436.
This commit is contained in:
janwas 2005-06-25 07:43:13 +00:00
parent 5c4d41fd0f
commit 85a8d217de
4 changed files with 56 additions and 11 deletions

View File

@ -1,6 +1,7 @@
#include "precompiled.h"
#include "byte_order.h"
#include "sdl.h"
u16 read_le16(const void* p)

View File

@ -1,4 +1,4 @@
#include "sdl.h"
#include "config.h"
// converts 4 character string to u32 for easy comparison
// can't pass code as string, and use s[0]..s[3], because
@ -9,7 +9,7 @@
// the additional u8 cast ensures each character is treated as unsigned
// (otherwise, they'd be promoted to signed int before the u32 cast,
// which would break things).
#if SDL_BYTE_ORDER == SDL_BIG_ENDIAN
#ifdef BIG_ENDIAN
#define FOURCC(a,b,c,d) ( ((u32)(u8)a) << 24 | ((u32)(u8)b) << 16 | \
((u32)(u8)c) << 8 | ((u32)(u8)d) << 0 )
#else

View File

@ -74,6 +74,18 @@
# error "unknown OS - add define here"
#endif
// byte order
#if defined(__i386__) || defined(__i386) || defined(_M_IX86) || \
defined(__ia64__) || defined(__ia64) || defined(_M_IA64) || \
defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) || \
defined(__arm__) || \
defined(__MIPSEL__) || \
defined(__LITTLE_ENDIAN__)
# define LITTLE_ENDIAN
#else
# define BIG_ENDIAN
#endif
//-----------------------------------------------------------------------------
// auto-detect platform features, given the above information
@ -133,4 +145,6 @@
# undef HAVE_VC_DEBUG_ALLOC
#endif
// _CPPLIB_VER
#endif // #ifndef CONFIG_H_INCLUDED

View File

@ -56,36 +56,65 @@
#ifdef HAVE_PCH
// all new-form C library headers
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cerrno>
#include <cfloat>
//#include <ciso646>
// defines e.g. "and" to "&". unnecessary and causes trouble with asm.
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
// all C++98 STL headers
#include <algorithm>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
// all other C++98 headers
#include <bitset>
#include <complex>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <istream>
#include <limits>
#include <locale>
#include <new>
#include <ostream>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <vector>
#include <strstream>
#include <typeinfo>
#include <valarray>
// STL extensions
#ifdef __GNUC__
# include <ext/hash_map>
# include <ext/hash_set>
@ -94,6 +123,7 @@
# include <hash_set>
#endif
// CStr is included very frequently, so a reasonable amount of time is saved
// by including it here. (~10% in a full rebuild, as of r2365)
#include "ps/CStr.h"