Panda3D
|
00001 /* Filename: dtoolbase.h 00002 * Created by: drose (12Sep00) 00003 * 00004 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00005 * 00006 * PANDA 3D SOFTWARE 00007 * Copyright (c) Carnegie Mellon University. All rights reserved. 00008 * 00009 * All use of this software is subject to the terms of the revised BSD 00010 * license. You should have received a copy of this license along 00011 * with this source code in a file named "LICENSE." 00012 * 00013 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00014 00015 /* This file is included at the beginning of every header file and/or 00016 C or C++ file. It must be compilable for C as well as C++ files, 00017 so no C++-specific code or syntax can be put here. See 00018 dtoolbase_cc.h for C++-specific stuff. */ 00019 00020 #ifndef DTOOLBASE_H 00021 #define DTOOLBASE_H 00022 00023 #include "dtool_config.h" 00024 00025 /* Make sure WIN32 and WIN32_VC are defined when using MSVC */ 00026 #ifdef _WIN32 00027 #ifndef WIN32 00028 #define WIN32 00029 #endif 00030 #ifdef _MSC_VER 00031 #ifndef WIN32_VC 00032 #define WIN32_VC 00033 #endif 00034 #endif 00035 #endif 00036 00037 #ifdef WIN32_VC 00038 /* These warning pragmas must appear before anything else for VC++ to 00039 respect them. Sheesh. */ 00040 00041 /* C4231: extern before template instantiation */ 00042 /* For some reason, this particular warning won't disable. */ 00043 #pragma warning (disable : 4231) 00044 /* C4786: 255 char debug symbols */ 00045 #pragma warning (disable : 4786) 00046 /* C4251: needs dll interface */ 00047 #pragma warning (disable : 4251) 00048 /* C4503: decorated name length exceeded */ 00049 #pragma warning (disable : 4503) 00050 /* C4305: truncation from 'const double' to 'float' */ 00051 #pragma warning (disable : 4305) 00052 /* C4250: 'myclass' : inherits 'baseclass::member' via dominance */ 00053 #pragma warning (disable : 4250) 00054 /* C4355: 'this' : used in base member initializer list */ 00055 #pragma warning (disable : 4355) 00056 /* C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data */ 00057 #pragma warning (disable : 4244) 00058 00059 #if _MSC_VER >= 1300 00060 #if _MSC_VER >= 1310 00061 #define USING_MSVC7_1 00062 //#pragma message("VC 7.1") 00063 #else 00064 //#pragma message("VC 7.0") 00065 #endif 00066 #define USING_MSVC7 00067 #else 00068 // #pragma message("VC 6.0") 00069 #endif 00070 00071 // Use NODEFAULT to optimize a switch() stmt to tell MSVC to automatically go to the final untested case 00072 // after it has failed all the other cases (i.e. 'assume at least one of the cases is always true') 00073 #ifdef _DEBUG 00074 # define NODEFAULT default: assert(0); 00075 #else 00076 # define NODEFAULT default: __assume(0); // special VC keyword 00077 #endif 00078 00079 #else /* if !WIN32_VC */ 00080 #ifdef _DEBUG 00081 # define NODEFAULT default: assert(0); 00082 #else 00083 # define NODEFAULT 00084 #endif 00085 #endif /* WIN32_VC */ 00086 00087 /* 00088 include win32 defns for everything up to WinServer2003, and assume 00089 I'm smart enough to use GetProcAddress for backward compat on 00090 w95/w98 for newer fns 00091 */ 00092 #ifdef _WIN32_WINNT 00093 #undef _WIN32_WINNT 00094 #endif 00095 #define _WIN32_WINNT 0x0502 00096 00097 #if defined(PHAVE_STDINT_H) && defined(__cplusplus) 00098 #ifndef __STDC_LIMIT_MACROS 00099 #define __STDC_LIMIT_MACROS 00100 #endif 00101 #ifndef __STDC_CONSTANT_MACROS 00102 #define __STDC_CONSTANT_MACROS 00103 #endif 00104 #endif 00105 00106 #ifdef HAVE_PYTHON 00107 #undef _POSIX_C_SOURCE 00108 #undef _XOPEN_SOURCE 00109 #include "pyconfig.h" 00110 #endif 00111 00112 #include "dtoolsymbols.h" 00113 00114 // always include assert.h until drose unbreaks it for opt4 00115 #include <assert.h> 00116 00117 #ifdef __GNUC__ 00118 // Large file >2GB support 00119 // this needs be be before systypes.h and other C headers 00120 #define _FILE_OFFSET_BITS 64 00121 #define _LARGEFILE_SOURCE 1 00122 #endif 00123 00124 #ifdef PHAVE_TYPES_H 00125 #include <types.h> 00126 #endif 00127 00128 #ifdef PHAVE_SYS_TYPES_H 00129 #include <sys/types.h> 00130 #endif 00131 00132 #ifdef PHAVE_MALLOC_H 00133 #include <malloc.h> 00134 #endif 00135 00136 #ifdef PHAVE_SYS_MALLOC_H 00137 #include <sys/malloc.h> 00138 #endif 00139 00140 #ifdef PHAVE_ALLOCA_H 00141 #include <alloca.h> 00142 #endif 00143 00144 #ifdef PHAVE_UNISTD_H 00145 #include <unistd.h> 00146 #endif 00147 00148 #ifdef PHAVE_IO_H 00149 #include <io.h> 00150 #endif 00151 00152 #ifdef PHAVE_LOCALE_H 00153 #include <locale.h> 00154 #endif 00155 00156 #ifdef PHAVE_STRING_H 00157 #include <string.h> 00158 #endif 00159 00160 #ifdef PHAVE_STDLIB_H 00161 #include <stdlib.h> 00162 #endif 00163 00164 #ifdef PHAVE_LIMITS_H 00165 #include <limits.h> 00166 #endif 00167 00168 #ifdef PHAVE_MINMAX_H 00169 #include <minmax.h> 00170 #endif 00171 00172 #ifdef PHAVE_SYS_TIME_H 00173 #include <sys/time.h> 00174 #endif 00175 00176 #ifdef PHAVE_STDINT_H 00177 #include <stdint.h> 00178 #endif 00179 00180 #ifdef CPPPARSER 00181 #include <stdtypedefs.h> 00182 #endif 00183 00184 #ifdef USE_TAU 00185 /* If we're building with the Tau instrumentor, include the 00186 appropriate header file to pick up the TAU macros. */ 00187 #include <TAU.h> 00188 #include <Profile/Profiler.h> 00189 #else 00190 /* Otherwise, if we're not building with the Tau instrumentor, turn 00191 off all the TAU macros. We could include the Tau header file to do 00192 this, but it's better not to assume that Tau is installed. */ 00193 #define TAU_TYPE_STRING(profileString, str) 00194 #define TAU_PROFILE(name, type, group) 00195 #define TAU_PROFILE_TIMER(var, name, type, group) 00196 #define TAU_PROFILE_START(var) 00197 #define TAU_PROFILE_STOP(var) 00198 #define TAU_PROFILE_STMT(stmt) 00199 #define TAU_PROFILE_EXIT(msg) 00200 #define TAU_PROFILE_INIT(argc, argv) 00201 #define TAU_PROFILE_SET_NODE(node) 00202 #define TAU_PROFILE_SET_CONTEXT(context) 00203 #define TAU_PROFILE_SET_GROUP_NAME(newname) 00204 #define TAU_PROFILE_TIMER_SET_GROUP_NAME(t, newname) 00205 #define TAU_PROFILE_CALLSTACK() 00206 #define TAU_DB_DUMP() 00207 #define TAU_DB_PURGE() 00208 00209 #define TAU_REGISTER_CONTEXT_EVENT(event, name) 00210 #define TAU_CONTEXT_EVENT(event, data) 00211 #define TAU_DISABLE_CONTEXT_EVENT(event) 00212 #define TAU_ENABLE_CONTEXT_EVENT(event) 00213 00214 #define TAU_REGISTER_EVENT(event, name) 00215 #define TAU_EVENT(event, data) 00216 #define TAU_EVENT_DISABLE_MIN(event) 00217 #define TAU_EVENT_DISABLE_MAX(event) 00218 #define TAU_EVENT_DISABLE_MEAN(event) 00219 #define TAU_EVENT_DISABLE_STDDEV(event) 00220 #define TAU_REPORT_STATISTICS() 00221 #define TAU_REPORT_THREAD_STATISTICS() 00222 #define TAU_REGISTER_THREAD() 00223 #define TAU_REGISTER_FORK(id, op) 00224 #define TAU_ENABLE_INSTRUMENTATION() 00225 #define TAU_DISABLE_INSTRUMENTATION() 00226 #define TAU_ENABLE_GROUP(group) 00227 #define TAU_DISABLE_GROUP(group) 00228 #define TAU_ENABLE_GROUP_NAME(group) 00229 #define TAU_DISABLE_GROUP_NAME(group) 00230 #define TAU_ENABLE_ALL_GROUPS() 00231 #define TAU_DISABLE_ALL_GROUPS() 00232 #define TAU_TRACK_MEMORY() 00233 #define TAU_TRACK_MEMORY_HERE() 00234 #define TAU_ENABLE_TRACKING_MEMORY() 00235 #define TAU_DISABLE_TRACKING_MEMORY() 00236 #define TAU_TRACK_MEMORY() 00237 #define TAU_TRACK_MEMORY_HERE() 00238 #define TAU_ENABLE_TRACKING_MUSE_EVENTS() 00239 #define TAU_DISABLE_TRACKING_MUSE_EVENTS() 00240 #define TAU_TRACK_MUSE_EVENTS() 00241 #define TAU_SET_INTERRUPT_INTERVAL(value) 00242 00243 #define TAU_TRACE_SENDMSG(type, destination, length) 00244 #define TAU_TRACE_RECVMSG(type, source, length) 00245 00246 #define TAU_MAPPING(stmt, group) stmt 00247 #define TAU_MAPPING_OBJECT(FuncInfoVar) 00248 #define TAU_MAPPING_LINK(FuncInfoVar, Group) 00249 #define TAU_MAPPING_PROFILE(FuncInfoVar) 00250 #define TAU_MAPPING_CREATE(name, type, key, groupname, tid) 00251 #define TAU_MAPPING_PROFILE_TIMER(Timer, FuncInfoVar, tid) 00252 #define TAU_MAPPING_TIMER_CREATE(t, name, type, gr, group_name) 00253 #define TAU_MAPPING_PROFILE_START(Timer, tid) 00254 #define TAU_MAPPING_PROFILE_STOP(tid) 00255 #define TAU_MAPPING_PROFILE_EXIT(msg, tid) 00256 #define TAU_MAPPING_DB_DUMP(tid) 00257 #define TAU_MAPPING_DB_PURGE(tid) 00258 #define TAU_MAPPING_PROFILE_SET_NODE(node, tid) 00259 #define TAU_MAPPING_PROFILE_SET_GROUP_NAME(timer, name) 00260 #define TAU_PROFILE_TIMER_SET_NAME(t, newname) 00261 #define TAU_PROFILE_TIMER_SET_TYPE(t, newname) 00262 #define TAU_PROFILE_TIMER_SET_GROUP(t, id) 00263 #define TAU_MAPPING_PROFILE_SET_NAME(timer, name) 00264 #define TAU_MAPPING_PROFILE_SET_TYPE(timer, name) 00265 #define TAU_MAPPING_PROFILE_SET_GROUP(timer, id) 00266 #define TAU_MAPPING_PROFILE_GET_GROUP_NAME(timer) 00267 #define TAU_MAPPING_PROFILE_GET_GROUP(timer) 00268 #define TAU_MAPPING_PROFILE_GET_NAME(timer) 00269 #define TAU_MAPPING_PROFILE_GET_TYPE(timer) 00270 00271 #define TAU_PHASE(name, type, group) 00272 #define TAU_PHASE_CREATE_STATIC(var, name, type, group) 00273 #define TAU_PHASE_CREATE_DYNAMIC(var, name, type, group) 00274 #define TAU_PHASE_START(var) 00275 #define TAU_PHASE_STOP(var) 00276 #define TAU_GLOBAL_PHASE(timer, name, type, group) 00277 #define TAU_GLOBAL_PHASE_START(timer) 00278 #define TAU_GLOBAL_PHASE_STOP(timer) 00279 #define TAU_GLOBAL_PHASE_EXTERNAL(timer) 00280 #define TAU_GLOBAL_TIMER(timer, name, type, group) 00281 #define TAU_GLOBAL_TIMER_EXTERNAL(timer) 00282 #define TAU_GLOBAL_TIMER_START(timer) 00283 #define TAU_GLOBAL_TIMER_STOP() 00284 00285 #endif /* USE_TAU */ 00286 00287 /* Try to infer the endianness of the host based on compiler 00288 predefined macros. For systems on which the compiler does not 00289 define these macros, we rely on ppremake to define WORDS_BIGENDIAN 00290 correctly. For systems on which the compiler *does* define these 00291 macros, we ignore what ppremake said and define WORDS_BIGENDIAN 00292 correctly here. (This is essential on OSX, which requires 00293 compiling each file twice in different modes, for universal binary 00294 support.) */ 00295 00296 #if defined(__LITTLE_ENDIAN__) || defined(__i386__) 00297 #undef WORDS_BIGENDIAN 00298 00299 #elif defined(__BIG_ENDIAN__) || defined(__ppc__) 00300 #undef WORDS_BIGENDIAN 00301 #define WORDS_BIGENDIAN 1 00302 00303 #endif 00304 00305 /* Try to determine if we're compiling in a 64-bit mode. */ 00306 00307 #ifdef __WORDSIZE 00308 #define NATIVE_WORDSIZE __WORDSIZE 00309 #elif defined(_LP64) 00310 #define NATIVE_WORDSIZE 64 00311 #else 00312 #define NATIVE_WORDSIZE 32 00313 #endif 00314 00315 00316 /* 00317 We define the macros BEGIN_PUBLISH and END_PUBLISH to bracket 00318 functions and global variable definitions that are to be published 00319 via interrogate to scripting languages. Also, the macro BLOCKING is 00320 used to flag any function or method that might perform I/O blocking 00321 and thus needs to release Python threads for its duration. 00322 */ 00323 #ifdef CPPPARSER 00324 #define BEGIN_PUBLISH __begin_publish 00325 #define END_PUBLISH __end_publish 00326 #define BLOCKING __blocking 00327 #define MAKE_SEQ(seq_name, num_name, element_name) __make_seq(seq_name, num_name, element_name) 00328 #undef USE_STL_ALLOCATOR /* Don't try to parse these template classes in interrogate. */ 00329 #define EXTENSION(x) __extension x 00330 #define EXTEND __extension 00331 #define EXT_FUNC(func) ::func() 00332 #define EXT_FUNC_ARGS(func, ...) ::func(__VA_ARGS__) 00333 #define CALL_EXT_FUNC(func, ...) ::func (__VA_ARGS__) 00334 #else 00335 #define BEGIN_PUBLISH 00336 #define END_PUBLISH 00337 #define BLOCKING 00338 #define MAKE_SEQ(seq_name, num_name, element_name) 00339 #define EXTENSION(x) 00340 #define EXTEND 00341 /* If you change these, don't forget to also change it in interrogate itself. */ 00342 #define _EXT_FUNC(func) _ext__ ## func 00343 #define EXT_FUNC(func) _EXT_FUNC(func) () 00344 #define EXT_FUNC_ARGS(func, ...) _EXT_FUNC(func) (__VA_ARGS__) 00345 #define CALL_EXT_FUNC(func, ...) _EXT_METHOD(cl, m) (__VA_ARGS__) 00346 #endif 00347 00348 #ifdef __cplusplus 00349 #include "dtoolbase_cc.h" 00350 #endif 00351 00352 #endif 00353