gallium: Define intptr_t for Windows platform.
[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 <stdlib.h>
33 #include <string.h>
34
35
36 #if defined(_WIN32) && !defined(__WIN32__)
37 #define __WIN32__
38 #endif
39
40 #if defined(_MSC_VER) && !defined(__MSC__)
41 #define __MSC__
42 #endif
43
44
45 typedef unsigned int uint;
46 typedef unsigned char ubyte;
47 typedef unsigned char boolean;
48 typedef unsigned short ushort;
49 typedef unsigned long long uint64;
50
51
52 #if defined(__MSC__)
53
54 typedef char int8_t;
55 typedef unsigned char uint8_t;
56 typedef short int16_t;
57 typedef unsigned short uint16_t;
58 typedef long int32_t;
59 typedef unsigned long uint32_t;
60 typedef long long int64_t;
61 typedef unsigned long long uint64_t;
62
63 #if defined(_WIN64)
64 typedef __int64 intptr_t;
65 typedef unsigned __int64 uintptr_t;
66 #else
67 typedef int intptr_t;
68 typedef unsigned int uintptr_t;
69 #endif
70
71 #else
72 #include <stdint.h>
73 #endif
74
75
76 #define TRUE 1
77 #define FALSE 0
78
79
80 /* Function inlining */
81 #if defined(__GNUC__)
82 # define INLINE __inline__
83 #elif defined(__MSC__)
84 # define INLINE __inline
85 #elif defined(__ICL)
86 # define INLINE __inline
87 #elif defined(__INTEL_COMPILER)
88 # define INLINE inline
89 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
90 # define INLINE __inline
91 #else
92 # define INLINE
93 #endif
94
95
96 #if defined __GNUC__
97 #define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___aligned[SIZE] __attribute__(( aligned( 16 ) ))
98 #define ALIGN16_ASSIGN(NAME) NAME##___aligned
99 #define ALIGN16_ATTRIB __attribute__(( aligned( 16 ) ))
100 #else
101 #define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___unaligned[SIZE + 1]
102 #define ALIGN16_ASSIGN(NAME) align16(NAME##___unaligned)
103 #define ALIGN16_ATTRIB
104 #endif
105
106
107
108 /** For calling code-gen'd functions */
109 #if !defined(XSTDCALL)
110 #if defined(WIN32)
111 #define XSTDCALL __stdcall
112 #else
113 #define XSTDCALL
114 #endif
115 #endif
116
117
118 #endif /* P_COMPILER_H */