Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmcompiler.h
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 7.1 00004 * 00005 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a 00008 * copy of this software and associated documentation files (the "Software"), 00009 * to deal in the Software without restriction, including without limitation 00010 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00011 * and/or sell copies of the Software, and to permit persons to whom the 00012 * Software is furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included 00015 * in all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00018 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00020 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00021 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00022 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 */ 00024 00025 00026 00027 00035 #ifndef MCOMPILER_H 00036 #define MCOMPILER_H 00037 00038 00039 00040 /* Get typedefs for uintptr_t and friends */ 00041 #if defined(__MINGW32__) || defined(__NetBSD__) 00042 # include <stdint.h> 00043 #elif defined(_WIN32) 00044 # include <BaseTsd.h> 00045 # if _MSC_VER == 1200 00046 typedef UINT_PTR uintptr_t; 00047 # endif 00048 #else 00049 # include <inttypes.h> 00050 #endif 00051 00052 00053 00054 00055 #ifdef __cplusplus 00056 extern "C" { 00057 #endif 00058 00059 00060 00064 #ifndef NULL 00065 #define NULL 0 00066 #endif 00067 00068 00069 00073 #if defined(__GNUC__) 00074 # define INLINE __inline__ 00075 #elif defined(__MSC__) 00076 # define INLINE __inline 00077 #elif defined(_MSC_VER) 00078 # define INLINE __inline 00079 #elif defined(__ICL) 00080 # define INLINE __inline 00081 #elif defined(__INTEL_COMPILER) 00082 # define INLINE inline 00083 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) 00084 # define INLINE __inline 00085 #else 00086 # define INLINE 00087 #endif 00088 00089 00099 #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 00100 # define PUBLIC __attribute__((visibility("default"))) 00101 # define USED __attribute__((used)) 00102 #else 00103 # define PUBLIC 00104 # define USED 00105 #endif 00106 00107 00111 #ifdef NO_CONST 00112 # define CONST 00113 #else 00114 # define CONST const 00115 #endif 00116 00117 00121 #if defined(BUILD_FOR_SNAP) && defined(CHECKED) 00122 # define ASSERT(X) _CHECK(X) 00123 #elif defined(DEBUG) 00124 # define ASSERT(X) assert(X) 00125 #else 00126 # define ASSERT(X) 00127 #endif 00128 00129 00133 #if (!defined(__GNUC__) || __GNUC__ < 3) && (!defined(__IBMC__) || __IBMC__ < 900) 00134 # define __builtin_expect(x, y) x 00135 #endif 00136 00137 00138 00144 #if defined(__VMS) 00145 # define __FUNCTION__ "VMS$NL:" 00146 #elif __STDC_VERSION__ < 199901L 00147 # if ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \ 00148 (!defined(_MSC_VER) || _MSC_VER < 1300) 00149 # define __FUNCTION__ "<unknown>" 00150 # endif 00151 #endif 00152 00153 00154 00155 00157 #if !defined(__GNUC__) || (__GNUC__ < 2) || \ 00158 ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 7)) 00159 # define LONGSTRING 00160 #else 00161 # define LONGSTRING __extension__ 00162 #endif 00163 00164 00165 /* Create a macro so that asm functions can be linked into compilers other 00166 * than GNU C 00167 */ 00168 #ifndef _ASMAPI 00169 #if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/ 00170 #define _ASMAPI __cdecl 00171 #else 00172 #define _ASMAPI 00173 #endif 00174 #ifdef PTR_DECL_IN_FRONT 00175 #define _ASMAPIP * _ASMAPI 00176 #else 00177 #define _ASMAPIP _ASMAPI * 00178 #endif 00179 #endif 00180 00181 #ifdef USE_X86_ASM 00182 #define _NORMAPI _ASMAPI 00183 #define _NORMAPIP _ASMAPIP 00184 #else 00185 #define _NORMAPI 00186 #define _NORMAPIP * 00187 #endif 00188 00189 00190 00194 #if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP) 00195 #define CAPI _cdecl 00196 #endif 00197 00198 00199 00203 #if defined(__i386__) || defined(__386__) || defined(__sparc__) || \ 00204 defined(__s390x__) || defined(__powerpc__) || \ 00205 defined(__x86_64__) || \ 00206 defined(ia64) || defined(__ia64__) || \ 00207 defined(__hppa__) || defined(hpux) || \ 00208 defined(__mips) || defined(_MIPS_ARCH) || \ 00209 defined(__arm__) || \ 00210 defined(__sh__) || defined(__m32r__) || \ 00211 (defined(__sun) && defined(_IEEE_754)) || \ 00212 (defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS))) 00213 #define USE_IEEE 00214 #define IEEE_ONE 0x3f800000 00215 #endif 00216 00217 00218 00222 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP) 00223 # define __WIN32__ 00224 # define finite _finite 00225 #endif 00226 00227 #if defined(__WATCOMC__) 00228 # define finite _finite 00229 # pragma disable_message(201) /* Disable unreachable code warnings */ 00230 #endif 00231 00232 00236 #ifdef USE_IEEE 00237 static INLINE int IS_INF_OR_NAN( float x ) 00238 { 00239 fi_type tmp; 00240 tmp.f = x; 00241 return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31); 00242 } 00243 #elif defined(isfinite) 00244 #define IS_INF_OR_NAN(x) (!isfinite(x)) 00245 #elif defined(finite) 00246 #define IS_INF_OR_NAN(x) (!finite(x)) 00247 #elif defined(__VMS) 00248 #define IS_INF_OR_NAN(x) (!finite(x)) 00249 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 00250 #define IS_INF_OR_NAN(x) (!isfinite(x)) 00251 #else 00252 #define IS_INF_OR_NAN(x) (!finite(x)) 00253 #endif 00254 00255 00256 00257 /*** 00258 *** START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save 00259 *** original mode to a temporary). 00260 *** END_FAST_MATH: Restore x86 FPU to original mode. 00261 ***/ 00262 #if defined(__GNUC__) && defined(__i386__) 00263 /* 00264 * Set the x86 FPU control word to guarentee only 32 bits of precision 00265 * are stored in registers. Allowing the FPU to store more introduces 00266 * differences between situations where numbers are pulled out of memory 00267 * vs. situations where the compiler is able to optimize register usage. 00268 * 00269 * In the worst case, we force the compiler to use a memory access to 00270 * truncate the float, by specifying the 'volatile' keyword. 00271 */ 00272 /* Hardware default: All exceptions masked, extended double precision, 00273 * round to nearest (IEEE compliant): 00274 */ 00275 #define DEFAULT_X86_FPU 0x037f 00276 /* All exceptions masked, single precision, round to nearest: 00277 */ 00278 #define FAST_X86_FPU 0x003f 00279 /* The fldcw instruction will cause any pending FP exceptions to be 00280 * raised prior to entering the block, and we clear any pending 00281 * exceptions before exiting the block. Hence, asm code has free 00282 * reign over the FPU while in the fast math block. 00283 */ 00284 #if defined(NO_FAST_MATH) 00285 #define START_FAST_MATH(x) \ 00286 do { \ 00287 static unsigned mask = DEFAULT_X86_FPU; \ 00288 __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ 00289 __asm__ ( "fldcw %0" : : "m" (mask) ); \ 00290 } while (0) 00291 #else 00292 #define START_FAST_MATH(x) \ 00293 do { \ 00294 static unsigned mask = FAST_X86_FPU; \ 00295 __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ 00296 __asm__ ( "fldcw %0" : : "m" (mask) ); \ 00297 } while (0) 00298 #endif 00299 /* Restore original FPU mode, and clear any exceptions that may have 00300 * occurred in the FAST_MATH block. 00301 */ 00302 #define END_FAST_MATH(x) \ 00303 do { \ 00304 __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \ 00305 } while (0) 00306 00307 #elif defined(__WATCOMC__) && defined(__386__) 00308 #define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ 00309 #define FAST_X86_FPU 0x003f /* See GCC comments above */ 00310 void _watcom_start_fast_math(unsigned short *x,unsigned short *mask); 00311 #pragma aux _watcom_start_fast_math = \ 00312 "fnstcw word ptr [eax]" \ 00313 "fldcw word ptr [ecx]" \ 00314 parm [eax] [ecx] \ 00315 modify exact []; 00316 void _watcom_end_fast_math(unsigned short *x); 00317 #pragma aux _watcom_end_fast_math = \ 00318 "fnclex" \ 00319 "fldcw word ptr [eax]" \ 00320 parm [eax] \ 00321 modify exact []; 00322 #if defined(NO_FAST_MATH) 00323 #define START_FAST_MATH(x) \ 00324 do { \ 00325 static unsigned short mask = DEFAULT_X86_FPU; \ 00326 _watcom_start_fast_math(&x,&mask); \ 00327 } while (0) 00328 #else 00329 #define START_FAST_MATH(x) \ 00330 do { \ 00331 static unsigned short mask = FAST_X86_FPU; \ 00332 _watcom_start_fast_math(&x,&mask); \ 00333 } while (0) 00334 #endif 00335 #define END_FAST_MATH(x) _watcom_end_fast_math(&x) 00336 00337 #elif defined(_MSC_VER) && defined(_M_IX86) 00338 #define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ 00339 #define FAST_X86_FPU 0x003f /* See GCC comments above */ 00340 #if defined(NO_FAST_MATH) 00341 #define START_FAST_MATH(x) do {\ 00342 static unsigned mask = DEFAULT_X86_FPU;\ 00343 __asm fnstcw word ptr [x]\ 00344 __asm fldcw word ptr [mask]\ 00345 } while(0) 00346 #else 00347 #define START_FAST_MATH(x) do {\ 00348 static unsigned mask = FAST_X86_FPU;\ 00349 __asm fnstcw word ptr [x]\ 00350 __asm fldcw word ptr [mask]\ 00351 } while(0) 00352 #endif 00353 #define END_FAST_MATH(x) do {\ 00354 __asm fnclex\ 00355 __asm fldcw word ptr [x]\ 00356 } while(0) 00357 00358 #else 00359 #define START_FAST_MATH(x) x = 0 00360 #define END_FAST_MATH(x) (void)(x) 00361 #endif 00362 00363 00364 00371 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN 00372 #if defined(__linux__) 00373 #include <byteswap.h> 00374 #define CPU_TO_LE32( x ) bswap_32( x ) 00375 #else /*__linux__*/ 00376 #define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */ 00377 #endif /*__linux__*/ 00378 #define MESA_BIG_ENDIAN 1 00379 #else 00380 #define CPU_TO_LE32( x ) ( x ) 00381 #define MESA_LITTLE_ENDIAN 1 00382 #endif 00383 #define LE32_TO_CPU( x ) CPU_TO_LE32( x ) 00384 00385 00386 00387 #ifdef __cplusplus 00388 } 00389 #endif 00390 00391 00392 #endif /* MCOMPILER_H */ Generated on Sun May 27 2012 04:20:21 for ReactOS by
1.7.6.1
|