Merge commit 'origin/gallium-0.1' into gallium-0.2
[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 typedef uint64_t uint64;
100
101 #if 0
102 #define boolean bool
103 #else
104 typedef unsigned char boolean;
105 #endif
106 #ifndef TRUE
107 #define TRUE true
108 #endif
109 #ifndef FALSE
110 #define FALSE false
111 #endif
112
113
114 /* Function inlining */
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 #else
128 # define INLINE
129 #endif
130
131
132 /* This should match linux gcc cdecl semantics everywhere, so that we
133 * just codegen one calling convention on all platforms.
134 */
135 #ifdef _MSC_VER
136 #define PIPE_CDECL __cdecl
137 #else
138 #define PIPE_CDECL
139 #endif
140
141
142
143 #if defined(__GNUC__)
144 #define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___aligned[SIZE] __attribute__(( aligned( 16 ) ))
145 #define ALIGN16_ASSIGN(NAME) NAME##___aligned
146 #define ALIGN16_ATTRIB __attribute__(( aligned( 16 ) ))
147 #define ALIGN8_ATTRIB __attribute__(( aligned( 8 ) ))
148 #else
149 #define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___unaligned[SIZE + 1]
150 #define ALIGN16_ASSIGN(NAME) align16(NAME##___unaligned)
151 #define ALIGN16_ATTRIB
152 #define ALIGN8_ATTRIB
153 #endif
154
155
156
157 #endif /* P_COMPILER_H */