Add #ifdefs needed to compile Gallium on Solaris with gcc or Sun cc
[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
42
43 #if defined(_WIN32) && !defined(__WIN32__)
44 #define __WIN32__
45 #endif
46
47 #if defined(_MSC_VER)
48
49 /* Avoid 'expression is always true' warning */
50 #pragma warning(disable: 4296)
51
52 #endif /* _MSC_VER */
53
54
55 #if defined(_MSC_VER)
56
57 typedef __int8 int8_t;
58 typedef unsigned __int8 uint8_t;
59 typedef __int16 int16_t;
60 typedef unsigned __int16 uint16_t;
61 #ifndef __eglplatform_h_
62 typedef __int32 int32_t;
63 #endif
64 typedef unsigned __int32 uint32_t;
65 typedef __int64 int64_t;
66 typedef unsigned __int64 uint64_t;
67
68 #if defined(_WIN64)
69 typedef __int64 intptr_t;
70 typedef unsigned __int64 uintptr_t;
71 #else
72 typedef __int32 intptr_t;
73 typedef unsigned __int32 uintptr_t;
74 #endif
75
76 #define INT64_C(__val) __val##i64
77 #define UINT64_C(__val) __val##ui64
78
79 #ifndef __cplusplus
80 #define false 0
81 #define true 1
82 #define bool _Bool
83 typedef int _Bool;
84 #define __bool_true_false_are_defined 1
85 #endif /* !__cplusplus */
86
87 #else
88 #ifndef __STDC_LIMIT_MACROS
89 #define __STDC_LIMIT_MACROS 1
90 #endif
91 #include <stdint.h>
92 #include <stdbool.h>
93 #endif
94
95
96 typedef unsigned int uint;
97 typedef unsigned char ubyte;
98 typedef unsigned short ushort;
99
100 #if 0
101 #define boolean bool
102 #else
103 typedef unsigned char boolean;
104 #endif
105 #ifndef TRUE
106 #define TRUE true
107 #endif
108 #ifndef FALSE
109 #define FALSE false
110 #endif
111
112
113 /* Function inlining */
114 #ifndef INLINE
115 # ifdef __cplusplus
116 # define INLINE inline
117 # elif defined(__GNUC__)
118 # define INLINE __inline__
119 # elif defined(_MSC_VER)
120 # define INLINE __inline
121 # elif defined(__ICL)
122 # define INLINE __inline
123 # elif defined(__INTEL_COMPILER)
124 # define INLINE inline
125 # elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
126 # define INLINE __inline
127 # elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
128 # define INLINE inline
129 # elif (__STDC_VERSION__ >= 199901L) /* C99 */
130 # define INLINE inline
131 # else
132 # define INLINE
133 # endif
134 #endif
135
136 /* The __FUNCTION__ gcc variable is generally only used for debugging.
137 * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
138 */
139 #ifndef __FUNCTION__
140 # if (!defined(__GNUC__) || (__GNUC__ < 2))
141 # if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
142 (defined(__SUNPRO_C) && defined(__C99FEATURES__))
143 # define __FUNCTION__ __func__
144 # else
145 # define __FUNCTION__ "<unknown>"
146 # endif
147 # endif
148 #endif
149
150
151
152 /* This should match linux gcc cdecl semantics everywhere, so that we
153 * just codegen one calling convention on all platforms.
154 */
155 #ifdef _MSC_VER
156 #define PIPE_CDECL __cdecl
157 #else
158 #define PIPE_CDECL
159 #endif
160
161
162
163 #if defined(__GNUC__)
164 #define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___aligned[SIZE] __attribute__(( aligned( 16 ) ))
165 #define ALIGN16_ASSIGN(NAME) NAME##___aligned
166 #define ALIGN16_ATTRIB __attribute__(( aligned( 16 ) ))
167 #define ALIGN8_ATTRIB __attribute__(( aligned( 8 ) ))
168 #else
169 #define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___unaligned[SIZE + 1]
170 #define ALIGN16_ASSIGN(NAME) align16(NAME##___unaligned)
171 #define ALIGN16_ATTRIB
172 #define ALIGN8_ATTRIB
173 #endif
174
175
176
177 #endif /* P_COMPILER_H */