gallium: define PIPE_CDECL calling convention, which really is cdecl everywhere
[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) && !defined(__MSC__)
43 #define __MSC__
44 #endif
45
46
47 #if defined(__MSC__)
48
49 /* Avoid 'expression is always true' warning */
50 #pragma warning(disable: 4296)
51
52 #endif /* __MSC__ */
53
54
55 typedef unsigned int uint;
56 typedef unsigned char ubyte;
57 typedef unsigned char boolean;
58 typedef unsigned short ushort;
59 typedef unsigned long long uint64;
60
61
62 #if defined(__MSC__)
63
64 typedef char int8_t;
65 typedef unsigned char uint8_t;
66 typedef short int16_t;
67 typedef unsigned short uint16_t;
68 typedef long int32_t;
69 typedef unsigned long uint32_t;
70 typedef long long int64_t;
71 typedef unsigned long long uint64_t;
72
73 #if defined(_WIN64)
74 typedef __int64 intptr_t;
75 typedef unsigned __int64 uintptr_t;
76 #else
77 typedef int intptr_t;
78 typedef unsigned int uintptr_t;
79 #endif
80
81 #else
82 #include <stdint.h>
83 #endif
84
85
86 #define TRUE 1
87 #define FALSE 0
88
89
90 /* Function inlining */
91 #if defined(__GNUC__)
92 # define INLINE __inline__
93 #elif defined(__MSC__)
94 # define INLINE __inline
95 #elif defined(__ICL)
96 # define INLINE __inline
97 #elif defined(__INTEL_COMPILER)
98 # define INLINE inline
99 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
100 # define INLINE __inline
101 #else
102 # define INLINE
103 #endif
104
105
106 /* This should match linux gcc cdecl semantics everywhere, so that we
107 * just codegen one calling convention on all platforms.
108 */
109 #ifdef WIN32
110 #define PIPE_CDECL __cdecl
111 #else
112 #define PIPE_CDECL
113 #endif
114
115
116
117 #if defined __GNUC__
118 #define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___aligned[SIZE] __attribute__(( aligned( 16 ) ))
119 #define ALIGN16_ASSIGN(NAME) NAME##___aligned
120 #define ALIGN16_ATTRIB __attribute__(( aligned( 16 ) ))
121 #else
122 #define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___unaligned[SIZE + 1]
123 #define ALIGN16_ASSIGN(NAME) align16(NAME##___unaligned)
124 #define ALIGN16_ATTRIB
125 #endif
126
127
128
129 /**
130 * For calling code-gen'd functions, phase out in favor of
131 * PIPE_CDECL, above, which really means cdecl on all platforms, not
132 * like the below...
133 */
134 #if !defined(XSTDCALL)
135 #if defined(WIN32)
136 #define XSTDCALL __stdcall /* phase this out */
137 #else
138 #define XSTDCALL /* XXX: NOTE! not STDCALL! */
139 #endif
140 #endif
141
142
143 #endif /* P_COMPILER_H */