gallium: Remove unnecessary includes. Add others to compensate.
[mesa.git] / src / gallium / include / pipe / p_compiler.h
1 /**************************************************************************
2 *
3 * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef P_COMPILER_H
29 #define P_COMPILER_H
30
31
32 #include "p_config.h"
33
34 #ifndef XFree86Server
35 #include <stdlib.h>
36 #include <string.h>
37 #else
38 #include "xf86_ansic.h"
39 #include "xf86_libc.h"
40 #endif
41 #include <stddef.h>
42
43
44 #if defined(_WIN32) && !defined(__WIN32__)
45 #define __WIN32__
46 #endif
47
48 #if defined(_MSC_VER)
49
50 /* Avoid 'expression is always true' warning */
51 #pragma warning(disable: 4296)
52
53 #endif /* _MSC_VER */
54
55
56 /*
57 * Alternative stdint.h and stdbool.h headers are supplied in include/c99 for
58 * systems that lack it.
59 */
60 #ifndef __STDC_LIMIT_MACROS
61 #define __STDC_LIMIT_MACROS 1
62 #endif
63 #include <stdint.h>
64 #include <stdbool.h>
65
66
67 #if !defined(__HAIKU__) && !defined(__USE_MISC)
68 typedef unsigned int uint;
69 typedef unsigned short ushort;
70 #endif
71 typedef unsigned char ubyte;
72
73 typedef unsigned char boolean;
74 #ifndef TRUE
75 #define TRUE true
76 #endif
77 #ifndef FALSE
78 #define FALSE false
79 #endif
80
81
82 /* Function inlining */
83 #ifndef INLINE
84 # ifdef __cplusplus
85 # define INLINE inline
86 # elif defined(__GNUC__)
87 # define INLINE __inline__
88 # elif defined(_MSC_VER)
89 # define INLINE __inline
90 # elif defined(__ICL)
91 # define INLINE __inline
92 # elif defined(__INTEL_COMPILER)
93 # define INLINE inline
94 # elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
95 # define INLINE __inline
96 # elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
97 # define INLINE inline
98 # elif (__STDC_VERSION__ >= 199901L) /* C99 */
99 # define INLINE inline
100 # else
101 # define INLINE
102 # endif
103 #endif
104
105
106 /* Function visibility */
107 #ifndef PUBLIC
108 # if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \
109 || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
110 # define PUBLIC __attribute__((visibility("default")))
111 # else
112 # define PUBLIC
113 # endif
114 #endif
115
116
117 /* The __FUNCTION__ gcc variable is generally only used for debugging.
118 * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
119 */
120 #ifndef __FUNCTION__
121 # if (!defined(__GNUC__) || (__GNUC__ < 2))
122 # if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
123 (defined(__SUNPRO_C) && defined(__C99FEATURES__))
124 # define __FUNCTION__ __func__
125 # else
126 # define __FUNCTION__ "<unknown>"
127 # endif
128 # endif
129 #endif
130
131
132
133 /* This should match linux gcc cdecl semantics everywhere, so that we
134 * just codegen one calling convention on all platforms.
135 */
136 #ifdef _MSC_VER
137 #define PIPE_CDECL __cdecl
138 #else
139 #define PIPE_CDECL
140 #endif
141
142
143
144 /* Macros for data alignment. */
145 #if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
146
147 /* See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Type-Attributes.html */
148 #define PIPE_ALIGN_TYPE(_alignment, _type) _type __attribute__((aligned(_alignment)))
149
150 /* See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Variable-Attributes.html */
151 #define PIPE_ALIGN_VAR(_alignment) __attribute__((aligned(_alignment)))
152
153 #if (__GNUC__ > 4 || (__GNUC__ == 4 &&__GNUC_MINOR__>1)) && !defined(PIPE_ARCH_X86_64)
154 #define PIPE_ALIGN_STACK __attribute__((force_align_arg_pointer))
155 #else
156 #define PIPE_ALIGN_STACK
157 #endif
158
159 #elif defined(_MSC_VER)
160
161 /* See http://msdn.microsoft.com/en-us/library/83ythb65.aspx */
162 #define PIPE_ALIGN_TYPE(_alignment, _type) __declspec(align(_alignment)) _type
163 #define PIPE_ALIGN_VAR(_alignment) __declspec(align(_alignment))
164
165 #define PIPE_ALIGN_STACK
166
167 #elif defined(SWIG)
168
169 #define PIPE_ALIGN_TYPE(_alignment, _type) _type
170 #define PIPE_ALIGN_VAR(_alignment)
171
172 #define PIPE_ALIGN_STACK
173
174 #else
175
176 #error "Unsupported compiler"
177
178 #endif
179
180
181
182 #endif /* P_COMPILER_H */