1 /**************************************************************************
3 * Copyright 2007-2008 VMware, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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 VMWARE 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.
26 **************************************************************************/
32 #include "c99_compat.h" /* inline, __func__, etc. */
36 #include "util/macros.h"
45 #if defined(_WIN32) && !defined(__WIN32__)
53 /* Avoid 'expression is always true' warning */
54 #pragma warning(disable: 4296)
60 * Alternative stdint.h and stdbool.h headers are supplied in include/c99 for
61 * systems that lack it.
72 #if !defined(__HAIKU__) && !defined(__USE_MISC)
73 #if !defined(PIPE_OS_ANDROID)
74 typedef unsigned int uint
;
76 typedef unsigned short ushort
;
78 typedef unsigned char ubyte
;
80 typedef unsigned char boolean
;
90 #define va_copy(dest, src) __va_copy((dest), (src))
92 #define va_copy(dest, src) (dest) = (src)
97 /* XXX: Use standard `__func__` instead */
99 # define __FUNCTION__ __func__
103 /* This should match linux gcc cdecl semantics everywhere, so that we
104 * just codegen one calling convention on all platforms.
107 #define PIPE_CDECL __cdecl
114 #if defined(__GNUC__)
115 #define PIPE_DEPRECATED __attribute__((__deprecated__))
117 #define PIPE_DEPRECATED
122 /* Macros for data alignment. */
123 #if defined(__GNUC__)
125 /* See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Type-Attributes.html */
126 #define PIPE_ALIGN_TYPE(_alignment, _type) _type __attribute__((aligned(_alignment)))
128 /* See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Variable-Attributes.html */
129 #define PIPE_ALIGN_VAR(_alignment) __attribute__((aligned(_alignment)))
131 #if defined(__GNUC__) && !defined(PIPE_ARCH_X86_64)
132 #define PIPE_ALIGN_STACK __attribute__((force_align_arg_pointer))
134 #define PIPE_ALIGN_STACK
137 #elif defined(_MSC_VER)
139 /* See http://msdn.microsoft.com/en-us/library/83ythb65.aspx */
140 #define PIPE_ALIGN_TYPE(_alignment, _type) __declspec(align(_alignment)) _type
141 #define PIPE_ALIGN_VAR(_alignment) __declspec(align(_alignment))
143 #define PIPE_ALIGN_STACK
147 #define PIPE_ALIGN_TYPE(_alignment, _type) _type
148 #define PIPE_ALIGN_VAR(_alignment)
150 #define PIPE_ALIGN_STACK
154 #error "Unsupported compiler"
159 #if defined(__GNUC__)
161 #define PIPE_READ_WRITE_BARRIER() __asm__("":::"memory")
163 #elif defined(_MSC_VER)
165 #define PIPE_READ_WRITE_BARRIER() _ReadWriteBarrier()
169 #warning "Unsupported compiler"
170 #define PIPE_READ_WRITE_BARRIER() /* */
174 #if defined(__cplusplus)
179 #endif /* P_COMPILER_H */