Tizen 2.1 base
[sdk/emulator/qemu.git] / gl / mesa / src / egl / main / eglcompiler.h
1 /**************************************************************************
2  *
3  * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
4  * Copyright 2010 LunarG, Inc.
5  * All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sub license, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the
16  * next paragraph) shall be included in all copies or substantial portions
17  * of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26  *
27  **************************************************************************/
28
29
30 #ifndef EGLCOMPILER_INCLUDED
31 #define EGLCOMPILER_INCLUDED
32
33
34 /**
35  * Get standard integer types
36  */
37 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
38 #  include <stdint.h>
39 #elif defined(_MSC_VER)
40    typedef __int8             int8_t;
41    typedef unsigned __int8    uint8_t;
42    typedef __int16            int16_t;
43    typedef unsigned __int16   uint16_t;
44    typedef __int32            int32_t;
45    typedef unsigned __int32   uint32_t;
46    typedef __int64            int64_t;
47    typedef unsigned __int64   uint64_t;
48
49 #  if defined(_WIN64)
50      typedef __int64            intptr_t;
51      typedef unsigned __int64   uintptr_t;
52 #  else
53      typedef __int32            intptr_t;
54      typedef unsigned __int32   uintptr_t;
55 #  endif
56
57 #  define INT64_C(__val) __val##i64
58 #  define UINT64_C(__val) __val##ui64
59 #else
60 /* hope the best instead of adding a bunch of ifdef's */
61 #  include <stdint.h>
62 #endif
63
64
65 /**
66  * Function inlining
67  */
68 #ifndef inline
69 #  ifdef __cplusplus
70      /* C++ supports inline keyword */
71 #  elif defined(__GNUC__)
72 #    define inline __inline__
73 #  elif defined(_MSC_VER)
74 #    define inline __inline
75 #  elif defined(__ICL)
76 #    define inline __inline
77 #  elif defined(__INTEL_COMPILER)
78      /* Intel compiler supports inline keyword */
79 #  elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
80 #    define inline __inline
81 #  elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
82      /* C99 supports inline keyword */
83 #  elif (__STDC_VERSION__ >= 199901L)
84      /* C99 supports inline keyword */
85 #  else
86 #    define inline
87 #  endif
88 #endif
89 #ifndef INLINE
90 #  define INLINE inline
91 #endif
92
93
94 /**
95  * Function visibility
96  */
97 #ifndef PUBLIC
98 #  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
99 #    define PUBLIC __attribute__((visibility("default")))
100 #  elif defined(_MSC_VER)
101 #    define PUBLIC __declspec(dllexport)
102 #  else
103 #    define PUBLIC
104 #  endif
105 #endif
106
107 /**
108  * The __FUNCTION__ gcc variable is generally only used for debugging.
109  * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
110  * Don't define it if using a newer Windows compiler.
111  */
112 #ifndef __FUNCTION__
113 # if defined(__VMS)
114 #  define __FUNCTION__ "VMS$NL:"
115 # elif (!defined __GNUC__) && (!defined __xlC__) && \
116       (!defined(_MSC_VER) || _MSC_VER < 1300)
117 #  if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
118     (defined(__SUNPRO_C) && defined(__C99FEATURES__))
119 #   define __FUNCTION__ __func__
120 #  else
121 #   define __FUNCTION__ "<unknown>"
122 #  endif
123 # endif
124 #endif
125
126 #endif /* EGLCOMPILER_INCLUDED */