mesa: move LONGSTRING into generated enums.c
[mesa.git] / src / mesa / main / compiler.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27 /**
28 * \file compiler.h
29 * Compiler-related stuff.
30 */
31
32
33 #ifndef COMPILER_H
34 #define COMPILER_H
35
36
37 #include <assert.h>
38
39 #include "util/macros.h"
40
41 #include "c99_compat.h" /* inline, __func__, etc. */
42
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48
49 /**
50 * Sun compilers define __i386 instead of the gcc-style __i386__
51 */
52 #ifdef __SUNPRO_C
53 # if !defined(__i386__) && defined(__i386)
54 # define __i386__
55 # elif !defined(__amd64__) && defined(__amd64)
56 # define __amd64__
57 # elif !defined(__sparc__) && defined(__sparc)
58 # define __sparc__
59 # endif
60 #endif
61
62
63 /**
64 * Disable assorted warnings
65 */
66 #if defined(_WIN32) && !defined(__CYGWIN__)
67 # if !defined(__GNUC__) /* mingw environment */
68 # pragma warning( disable : 4068 ) /* unknown pragma */
69 # pragma warning( disable : 4710 ) /* function 'foo' not inlined */
70 # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
71 # pragma warning( disable : 4127 ) /* conditional expression is constant */
72 # if defined(MESA_MINWARN)
73 # pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
74 # pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
75 # pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
76 # pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
77 # pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
78 # endif
79 # endif
80 #endif
81
82
83 /* XXX: Use standard `__func__` instead */
84 #ifndef __FUNCTION__
85 # define __FUNCTION__ __func__
86 #endif
87
88 /**
89 * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32.
90 * Do not use these unless absolutely necessary!
91 * Try to use a runtime test instead.
92 * For now, only used by some DRI hardware drivers for color/texel packing.
93 */
94 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
95 #if defined(__linux__)
96 #include <byteswap.h>
97 #define CPU_TO_LE32( x ) bswap_32( x )
98 #elif defined(__APPLE__)
99 #include <CoreFoundation/CFByteOrder.h>
100 #define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x )
101 #elif defined(__OpenBSD__)
102 #include <sys/types.h>
103 #define CPU_TO_LE32( x ) htole32( x )
104 #else /*__linux__ */
105 #include <sys/endian.h>
106 #define CPU_TO_LE32( x ) bswap32( x )
107 #endif /*__linux__*/
108 #define MESA_BIG_ENDIAN 1
109 #else
110 #define CPU_TO_LE32( x ) ( x )
111 #define MESA_LITTLE_ENDIAN 1
112 #endif
113 #define LE32_TO_CPU( x ) CPU_TO_LE32( x )
114
115
116
117 #define IEEE_ONE 0x3f800000
118
119
120 #ifdef __cplusplus
121 }
122 #endif
123
124
125 #endif /* COMPILER_H */