nux-0.9.46
|
00001 /* 00002 * Copyright 2010 Inalogic® Inc. 00003 * 00004 * This program is free software: you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License, as 00006 * published by the Free Software Foundation; either version 2.1 or 3.0 00007 * of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranties of 00011 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the applicable version of the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of both the GNU Lesser General Public 00016 * License along with this program. If not, see <http://www.gnu.org/licenses/> 00017 * 00018 * Authored by: Jay Taoko <jaytaoko@inalogic.com> 00019 * 00020 */ 00021 00022 00023 #ifndef SYSTEM_H 00024 #define SYSTEM_H 00025 00026 #ifdef _DEBUG 00027 #define NUX_DEBUG 00028 #endif 00029 00030 #ifdef _WIN32 00031 #define NUX_OS_WINDOWS 00032 #elif __linux 00033 #define NUX_OS_LINUX 00034 #elif __APPLE__ 00035 #define NUX_OS_MACOSX 00036 #endif 00037 00038 #if __GNUC__ 00039 #define NUX_GNUC_COMPILER 00040 #if __GNUG__ 00041 #define NUX_GNUCPP_COMPILER 00042 #else 00043 #error Support only g++. 00044 #endif 00045 00046 // Compiler string. 00047 #define NUX_COMPILER_STRING "GNU CPP Compiler" 00048 00049 // Build string 00050 #ifdef NUX_DEBUG 00051 #define NUX_BUILD_STRING "Debug build compiled with " NUX_COMPILER_STRING 00052 #else 00053 #define NUX_BUILD_STRING "Compiled with " NUX_COMPILER_STRING 00054 #endif 00055 #endif 00056 00057 #if __APPLE_CC__ 00058 #define NUX_APPLE_COMPILER 00059 #endif 00060 00061 #if defined(_M_X64) || defined(__amd64__) || defined(__ia64__) 00062 #define NUX_ARCH_x64 00063 #elif defined(_M_IX86) || defined(__i386__) 00064 #define NUX_ARCH_i386 00065 #elif defined(__arm__) 00066 #define NUX_ARCH_arm 00067 #elif defined(__cell) 00068 #define NUX_ARCH_cell 00069 #endif 00070 00071 #if _MSC_VER 00072 #define NUX_MICROSOFT_COMPILER 00073 #endif 00074 00075 // Compiler Macros: 00076 // NUX_GNUCPP_COMPILER 00077 // NUX_MICROSOFT_COMPILER 00078 00079 // OS Macros: 00080 // NUX_OS_WINDOWS 00081 // NUX_OS_LINUX 00082 // NUX_OS_CELL 00083 // NUX_OS_MACOSX 00084 00085 #ifdef _WIN32 00086 00087 // Add lib DbgHelp.lib for the following function 00088 // StackWalk64 00089 // SymFunctionTableAccess64 00090 // SymGetModuleBase64 00091 // SymGetModuleInfo64 00092 // SymGetLineFromAddr64 00093 // SymGetSymFromAddr64 00094 // SymInitialize 00095 // SymSetOptions 00096 // SymGetOptions 00097 // SymLoadModule64 00098 #pragma comment(lib, "DbgHelp") 00099 00100 // _MSC_VER: Defines the major and minor versions of the compiler. For example, 1300 for Microsoft Visual C++ .NET. 1300 represents version 13 00101 // and no point release. This represents the fact that there have been a total of 13 releases of the compiler. 00102 // If you type cl /? at the command line, you will see the full version for the compiler you are using. 00103 00104 #ifndef _MSC_VER 00105 #error Support only Visual Studio Compiler. 00106 #endif 00107 00108 #define VISUAL_STUDIO_2008_COMPILER 1500 00109 #define VISUAL_STUDIO_2005_COMPILER 1400 00110 #define VISUAL_STUDIO_2003_COMPILER 1310 00111 00112 #if _MSC_VER >= 1500 00113 #define NUX_VISUAL_STUDIO_2008 00114 #elif _MSC_VER >= 1400 00115 #define NUX_VISUAL_STUDIO_2005 00116 #elif _MSC_VER >= 1310 00117 #define NUX_VISUAL_STUDIO_2003 00118 #endif 00119 00120 // Compiler string. 00121 #if (_MSC_VER >= VISUAL_STUDIO_2008_COMPILER) 00122 #define NUX_COMPILER_STRING "Visual Studio 2008" 00123 #elif (_MSC_VER >= VISUAL_STUDIO_2005_COMPILER) 00124 #define NUX_COMPILER_STRING "Visual Studio 2005" 00125 #elif (_MSC_VER >= VISUAL_STUDIO_2003_COMPILER) 00126 #define NUX_COMPILER_STRING "Visual Studio 2003" 00127 #endif 00128 00129 // Build String 00130 #ifdef NUX_DEBUG 00131 #define NUX_BUILD_STRING "Debug build compiled with " NUX_COMPILER_STRING 00132 #else 00133 #define NUX_BUILD_STRING "Compiled with " NUX_COMPILER_STRING 00134 #endif 00135 00136 00137 // Define the proper values for _WIN32_WINNT and WINVER in the compiler response file "compiler_options.h" 00138 // Windows Vista _WIN32_WINNT>=0x0600 00139 // WINVER>=0x0600 00140 // Windows Server 2003 _WIN32_WINNT>=0x0502 00141 // WINVER>=0x0502 00142 // Windows XP _WIN32_WINNT>=0x0501 00143 // WINVER>=0x0501 00144 // Windows 2000 _WIN32_WINNT>=0x0500 00145 // WINVER>=0x0500 00146 // Windows NT 4.0 _WIN32_WINNT>=0x0400 00147 // WINVER>=0x0400 00148 // Windows Me _WIN32_WINDOWS=0x0500 00149 // WINVER>=0x0500 00150 // Windows 98 _WIN32_WINDOWS>=0x0410 00151 // WINVER>=0x0410 00152 // Windows 95 _WIN32_WINDOWS>=0x0400 00153 // WINVER>=0x0400 00154 00155 00156 // Minimum system required Macros to define 00157 // Windows Vista NTDDI_VERSION >=NTDDI_LONGHORN 00158 // Windows Server 2003 SP1 NTDDI_VERSION >=NTDDI_WS03SP1 00159 // Windows Server 2003 NTDDI_VERSION >=NTDDI_WS03 00160 // Windows XP SP2 NTDDI_VERSION >=NTDDI_WINXPSP2 00161 // Windows XP SP1 NTDDI_VERSION >=NTDDI_WINXPSP1 00162 // Windows XP NTDDI_VERSION >=NTDDI_WINXP 00163 // Windows 2000 SP4 NTDDI_VERSION >=NTDDI_WIN2KSP4 00164 // Windows 2000 SP3 NTDDI_VERSION >=NTDDI_WIN2KSP3 00165 // Windows 2000 SP2 NTDDI_VERSION >=NTDDI_WIN2KSP2 00166 // Windows 2000 SP1 NTDDI_VERSION >=NTDDI_WIN2KSP1 00167 // Windows 2000 NTDDI_VERSION >=NTDDI_WIN2K 00168 00169 #define WIN32_LEAN_AND_MEAN 1 00170 #endif // _WIN32 00171 00172 00173 00174 00175 // Logging 00176 #if defined(NUX_OS_WINDOWS) && defined(NUX_DEBUG) 00177 #define NUX_ENABLE_ASSERT_MACROS 00178 #define NUX_ENABLE_LOGGING 00179 #elif defined(NUX_OS_LINUX) && defined(NUX_DEBUG) 00180 #define NUX_ENABLE_ASSERT_MACROS 00181 #define NUX_ENABLE_LOGGING 00182 #endif 00183 00184 // NOP: no operation 00185 // Specifies that a function should be ignored and the argument list 00186 // be parsed but no code be generated for the arguments. It is intended for use in global 00187 // debug functions that take a variable number of arguments. 00188 00189 #if defined(NUX_MICROSOFT_COMPILER) 00190 #define NUX_COMPILER_SUPPORTS_NOOP 00191 #define NUX_NOOP __noop 00192 #elif defined(NUX_GNUCPP_COMPILER) 00193 #define NUX_COMPILER_SUPPORTS_NOOP 00194 #define NUX_NOOP __asm__("nop") 00195 #endif 00196 00197 // Pragma pack support 00198 #if defined(NUX_MICROSOFT_COMPILER) || defined(NUX_GNUCPP_COMPILER) 00199 #define NUX_SUPPORTS_PRAGMA_PACK 00200 #endif 00201 00202 00203 // Define variadic macro support 00204 #if defined(NUX_MICROSOFT_COMPILER) && (defined(NUX_VISUAL_STUDIO_2005) || defined(NUX_VISUAL_STUDIO_2008)) 00205 #define NUX_VARIADIC_MACROS_SUPPORT 00206 #elif defined(NUX_GNUCPP_COMPILER) 00207 #define NUX_VARIADIC_MACROS_SUPPORT 00208 #endif 00209 00210 00212 #if defined(NUX_OS_WINDOWS) 00213 #ifdef NUX_DLL 00214 #if (!defined(_WIN32)) && (!defined(_WIN64)) 00215 #error("ERROR: Use NUX_DLL is permitted only on win32 & win64 platforms") 00216 #endif 00217 00218 #define NUX_DECLSPEC_DLLIMPORT __declspec(dllimport) 00219 #define NUX_DECLSPEC_DLLEXPORT __declspec(dllexport) 00220 #else 00221 #define NUX_DECLSPEC_DLLIMPORT 00222 #define NUX_DECLSPEC_DLLEXPORT 00223 #endif 00224 00225 #ifdef NUX_EXPORT_DLL 00226 #define NUX_DECLSPEC_DLL NUX_DECLSPEC_DLLEXPORT 00227 #else 00228 #define NUX_DECLSPEC_DLL NUX_DECLSPEC_DLLIMPORT 00229 #endif 00230 #elif defined(NUX_OS_LINUX) 00231 #if __GNUC__ >= 4 00232 #define NUX_DECLSPEC_DLLIMPORT __attribute__ ((visibility("default"))) 00233 #define NUX_DECLSPEC_DLLEXPORT __attribute__ ((visibility("default"))) 00234 #else 00235 #define NUX_DECLSPEC_DLLIMPORT 00236 #define NUX_DECLSPEC_DLLEXPORT 00237 #endif 00238 00239 #ifdef NUX_EXPORT_DLL 00240 #define NUX_DECLSPEC_DLL NUX_DECLSPEC_DLLEXPORT 00241 #else 00242 #define NUX_DECLSPEC_DLL NUX_DECLSPEC_DLLIMPORT 00243 #endif 00244 #endif 00245 00246 #define NUX_CHECK_PUREVIRTUALS 1 00247 00248 // Throwing exceptions: 00249 00250 // #ifdef NUX_DEBUG 00251 // // if we are in Debug disable exceptions. What we want is to break were and error happens: ie NUX_BREAK_ASM_INT3 00252 // #define NUX_EXCEPTIONS_DISABLED 1 00253 // #endif 00254 00255 #define NUX_EXCEPTIONS_DISABLED 1 00256 00257 #define STL std 00258 00259 #endif // SYSTEM_H 00260