AtxConfig.h

00001 /*****************************************************************
00002 |
00003 |   Atomix - Platform Configuration
00004 |
00005 |   (c) 2002-2006 Gilles Boccon-Gibod
00006 |   Author: Gilles Boccon-Gibod (bok@bok.net)
00007 |
00008  ****************************************************************/
00009 
00010 #ifndef _ATX_CONFIG_H_
00011 #define _ATX_CONFIG_H_
00012 
00013 /*----------------------------------------------------------------------
00014 |    defaults
00015 +---------------------------------------------------------------------*/
00016 /* assume little endian by default as this is the most common  */
00017 #define ATX_CONFIG_CPU_BYTE_ORDER ATX_CPU_LITTLE_ENDIAN
00018 
00019 #define ATX_CONFIG_HAVE_STD_C
00020 #define ATX_CONFIG_HAVE_STDLIB_H
00021 #define ATX_CONFIG_HAVE_STRING_H
00022 #define ATX_CONFIG_HAVE_STDIO_H
00023 #define ATX_CONFIG_HAVE_STDARG_H
00024 #define ATX_CONFIG_HAVE_STDDEF_H
00025 #define ATX_CONFIG_HAVE_CTYPE_H
00026 #define ATX_CONFIG_HAVE_MATH_H
00027 #define ATX_CONFIG_HAVE_ASSERT_H
00028 #define ATX_CONFIG_HAVE_LIMITS_H
00029 #define ATX_CONFIG_HAVE_UNISTD_H
00030 
00031 #define ATX_CONFIG_HAVE_INT64
00032 
00033 /*----------------------------------------------------------------------
00034 |    CPU byte order
00035 +---------------------------------------------------------------------*/
00036 #define ATX_CPU_BIG_ENDIAN    1
00037 #define ATX_CPU_LITTLE_ENDIAN 2
00038 
00039 /*----------------------------------------------------------------------
00040 |    standard C runtime
00041 +---------------------------------------------------------------------*/
00042 #if defined(ATX_CONFIG_HAVE_STD_C)
00043 #define ATX_CONFIG_HAVE_MALLOC
00044 #define ATX_CONFIG_HAVE_CALLOC
00045 #define ATX_CONFIG_HAVE_REALLOC
00046 #define ATX_CONFIG_HAVE_FREE
00047 #define ATX_CONFIG_HAVE_MEMCPY
00048 #define ATX_CONFIG_HAVE_MEMMOVE
00049 #define ATX_CONFIG_HAVE_MEMSET
00050 #define ATX_CONFIG_HAVE_MEMCMP
00051 #define ATX_CONFIG_HAVE_ATEXIT
00052 #define ATX_CONFIG_HAVE_GETENV
00053 #endif /* ATX_CONFIG_HAS_STD_C */
00054 
00055 #if defined(ATX_CONFIG_HAVE_STRING_H)
00056 #define ATX_CONFIG_HAVE_STRCMP
00057 #define ATX_CONFIG_HAVE_STRNCMP
00058 #define ATX_CONFIG_HAVE_STRCHR
00059 #define ATX_CONFIG_HAVE_STRDUP
00060 #define ATX_CONFIG_HAVE_STRLEN
00061 #define ATX_CONFIG_HAVE_STRCPY
00062 #define ATX_CONFIG_HAVE_STRNCPY
00063 #endif /* ATX_CONFIG_HAVE_STRING_H */
00064 
00065 #if defined(ATX_CONFIG_HAVE_STDIO_H)
00066 #define ATX_CONFIG_HAVE_SNPRINTF
00067 #define ATX_CONFIG_HAVE_VSNPRINTF
00068 #endif /* ATX_CONFIG_HAVE_STDIO_H_ */
00069 
00070 #if defined(ATX_CONFIG_HAVE_CTYPE_H)
00071 #define ATX_CONFIG_HAVE_IS_SPACE
00072 #define ATX_CONFIG_HAVE_IS_ALNUM
00073 #endif /* ATX_CONFIG_HAVE_CTYPE_H */
00074 
00075 #if defined(ATX_CONFIG_HAVE_LIMITS_H)
00076 #define ATX_CONFIG_HAVE_INT_MIN
00077 #define ATX_CONFIG_HAVE_INT_MAX
00078 #define ATX_CONFIG_HAVE_UINT_MAX
00079 #define ATX_CONFIG_HAVE_LONG_MIN
00080 #define ATX_CONFIG_HAVE_LONG_MAX
00081 #define ATX_CONFIG_HAVE_ULONG_MAX
00082 #endif
00083 
00084 /*----------------------------------------------------------------------
00085 |    compiler specifics
00086 +---------------------------------------------------------------------*/
00087 /* GCC */
00088 #if defined(__GNUC__)
00089 #define ATX_COMPILER_UNUSED(p) (void)p
00090 #else
00091 #define ATX_COMPILER_UNUSED(p) 
00092 #endif
00093 
00094 /* Microsoft C Compiler */
00095 #if defined(_MSC_VER)
00096 #define ATX_CONFIG_HAVE_INT64
00097 #define ATX_CONFIG_INT64_TYPE __int64
00098 #define ATX_strdup     _strdup
00099 #if (_MSC_VER >= 1400) && !defined(_WIN32_WCE)
00100 #define ATX_vsnprintf(s,c,f,a)  _vsnprintf_s(s,c,_TRUNCATE,f,a)
00101 #define ATX_snprintf(s,c,f,...) _snprintf_s(s,c,_TRUNCATE,f,__VA_ARGS__)
00102 #define ATX_strncpy(d,s,c)       strncpy_s(d,c,s,_TRUNCATE)
00103 #undef ATX_CONFIG_HAVE_GETENV
00104 #define ATX_CONFIG_HAVE_DUPENV_S
00105 #define dupenv_s _dupenv_s
00106 #else
00107 #define ATX_vsnprintf  _vsnprintf
00108 #define ATX_snprintf   _snprintf
00109 #endif
00110 #if (_MSC_VER >= 1300)
00111 #if defined (_WIN64)
00112 typedef __int64 ATX_PointerLong;
00113 #define ATX_CONFIG_INT_32_64_TYPE __int64
00114 #else
00115 typedef __w64 long ATX_PointerLong;
00116 #define ATX_CONFIG_INT_32_64_TYPE long
00117 #endif
00118 #define ATX_POINTER_TO_LONG(_p) ((ATX_PointerLong) (_p) )
00119 #undef ATX_CONFIG_HAVE_STRCPY
00120 #endif
00121 #if defined(_DEBUG)
00122 #define _CRTDBG_MAP_ALLOC
00123 #endif
00124 #endif
00125 
00126 /* windows CE */
00127 #if defined(_WIN32_WCE)
00128 #undef ATX_CONFIG_HAVE_GETENV
00129 #endif
00130 
00131 /* PS3 */
00132 #if defined(__PPU__)
00133 #undef ATX_CONFIG_HAVE_UNISTD_H
00134 #endif
00135 
00136 /*----------------------------------------------------------------------
00137 |   defaults
00138 +---------------------------------------------------------------------*/
00139 #ifndef ATX_POINTER_TO_LONG
00140 #define ATX_POINTER_TO_LONG(_p) ((long)(_p))
00141 #endif
00142 
00143 #if !defined(ATX_CONFIG_INT_32_64_TYPE)
00144 #define ATX_CONFIG_INT_32_64_TYPE long
00145 #endif
00146 
00147 #if defined(ATX_CONFIG_HAVE_INT64) && !defined(ATX_CONFIG_INT64_TYPE)
00148 #define ATX_CONFIG_INT64_TYPE long long
00149 #endif
00150 
00151 /*----------------------------------------------------------------------
00152 |    defaults
00153 +---------------------------------------------------------------------*/
00154 /* some compilers (ex: MSVC 8) deprecate those, so we rename them */
00155 #if !defined(ATX_strdup)
00156 #define ATX_strdup strdup
00157 #endif
00158 #if !defined(ATX_snprintf)
00159 #define ATX_snprintf snprintf
00160 #endif
00161 #if !defined(ATX_strncpy)
00162 #define ATX_strncpy strncpy
00163 #endif
00164 #if !defined(ATX_vsnprintf)
00165 #define ATX_vsnprintf vsnprintf
00166 #endif
00167 
00168 #endif /* _ATX_CONFIG_H_ */