Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
[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 #include <stdlib.h>
35 #include <string.h>
36
37
38 #if defined(_WIN32) && !defined(__WIN32__)
39 #define __WIN32__
40 #endif
41
42 #if defined(_MSC_VER)
43
44 /* Avoid 'expression is always true' warning */
45 #pragma warning(disable: 4296)
46
47 #endif /* _MSC_VER */
48
49
50 #if defined(_MSC_VER)
51
52 typedef __int8 int8_t;
53 typedef unsigned __int8 uint8_t;
54 typedef __int16 int16_t;
55 typedef unsigned __int16 uint16_t;
56 #ifndef __eglplatform_h_
57 typedef __int32 int32_t;
58 #endif
59 typedef unsigned __int32 uint32_t;
60 typedef __int64 int64_t;
61 typedef unsigned __int64 uint64_t;
62
63 #if defined(_WIN64)
64 typedef __int64 intptr_t;
65 typedef unsigned __int64 uintptr_t;
66 #else
67 typedef __int32 intptr_t;
68 typedef unsigned __int32 uintptr_t;
69 #endif
70
71 #define INT64_C(__val) __val##i64
72 #define UINT64_C(__val) __val##ui64
73
74 #ifndef __cplusplus
75 #define false 0
76 #define true 1
77 #define bool _Bool
78 typedef int _Bool;
79 #define __bool_true_false_are_defined 1
80 #endif /* !__cplusplus */
81
82 #else
83 #ifndef __STDC_LIMIT_MACROS
84 #define __STDC_LIMIT_MACROS 1
85 #endif
86 #include <stdint.h>
87 #include <stdbool.h>
88 #endif
89
90
91 typedef unsigned int uint;
92 typedef unsigned char ubyte;
93 typedef unsigned short ushort;
94 typedef uint64_t uint64;
95
96 #if 0
97 #define boolean bool
98 #else
99 typedef unsigned char boolean;
100 #endif
101 #ifndef TRUE
102 #define TRUE true
103 #endif
104 #ifndef FALSE
105 #define FALSE false
106 #endif
107
108
109 /* Function inlining */
110 #ifdef __cplusplus
111 # define INLINE inline
112 #elif defined(__GNUC__)
113 # define INLINE __inline__
114 #elif defined(_MSC_VER)
115 # define INLINE __inline
116 #elif defined(__ICL)
117 # define INLINE __inline
118 #elif defined(__INTEL_COMPILER)
119 # define INLINE inline
120 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
121 # define INLINE __inline
122 #else
123 # define INLINE
124 #endif
125
126
127 /* This should match linux gcc cdecl semantics everywhere, so that we
128 * just codegen one calling convention on all platforms.
129 */
130 #ifdef _MSC_VER
131 #define PIPE_CDECL __cdecl
132 #else
133 #define PIPE_CDECL
134 #endif
135
136
137
138 #if defined(__GNUC__)
139 #define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___aligned[SIZE] __attribute__(( aligned( 16 ) ))
140 #define ALIGN16_ASSIGN(NAME) NAME##___aligned
141 #define ALIGN16_ATTRIB __attribute__(( aligned( 16 ) ))
142 #else
143 #define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___unaligned[SIZE + 1]
144 #define ALIGN16_ASSIGN(NAME) align16(NAME##___unaligned)
145 #define ALIGN16_ATTRIB
146 #endif
147
148
149
150 #endif /* P_COMPILER_H */