2 // Copyright (C) 2007 by Martin Moracek
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Header file for platform dependent macros and constants.
28 * Little/big endianism
35 # if (IS_BIG_ENDIAN == 1)
36 # define PLATFORM_BIG_ENDIAN
38 // platform conversion functions
39 inline uint16
ToLittleEndian(uint16 v
)
41 return (0x00FF & v
) << 8 |
45 inline uint32
ToLittleEndian(uint32 v
)
47 return (0x000000FF & v
) << 24 |
48 (0x0000FF00 & v
) << 8 |
49 (0x00FF0000 & v
) >> 8 |
50 (0xFF000000 & v
) >> 24;
53 inline uint16
ToBigEndian(uint16 v
)
58 inline uint32
ToBigEndian(uint32 v
)
63 # else /* (IS_BIG_ENDIAN == 1) */
64 # define PLATFORM_LITTLE_ENDIAN
66 // platform conversion functions
67 inline uint16
ToLittleEndian(uint16 v
)
72 inline uint32
ToLittleEndian(uint32 v
)
77 inline uint16
ToBigEndian(uint16 v
)
79 return (0x00FF & v
) << 8 |
83 inline uint32
ToBigEndian(uint32 v
)
85 return (0x000000FF & v
) << 24 |
86 (0x0000FF00 & v
) << 8 |
87 (0x00FF0000 & v
) >> 8 |
88 (0xFF000000 & v
) >> 24;
91 # endif /* (IS_BIG_ENDIAN == 1) */
92 #endif /* IS_BIG_ENDIAN */
95 * Platform/compiler detection
99 # define PLATFORM_MSVC
102 # define PLATFORM_GCC
104 # define PLATFORM_GCC_LINUX
106 # define PLATFORM_GCC_WIN
109 # error Unknown compiler!
110 # endif /* __GNUC__ */
111 #endif /* _MSC_VER */
113 #if defined(_DEBUG) && !defined(DEBUG)
118 * Platform dependent macros
122 # define lseek _lseek
124 # define write _write
126 # define snprintf _snprintf
127 # define strcasecmp _stricmp
129 // to get clearer compiler output
130 # pragma warning( disable : 4290 )
131 # pragma warning( disable : 4996 )
133 // conversion from 'x' to 'y', possible loss of data
134 # pragma warning( disable : 4244 )
136 # pragma warning( disable : 4345 )
138 #endif /* PLATFORM_MSVC */
142 #define __FUNCTION__ __PRETTY_FUNCTION__
144 #endif /* PLATFORM_GCC */
147 * Build name - for creating project dependent logfiles, etc.
149 extern const char * gBuildName
;