1 /**************************************************************************
3 * Copyright 2007-2013 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 **************************************************************************/
28 #include "no_extern_c.h"
30 #ifndef _C99_COMPAT_H_
31 #define _C99_COMPAT_H_
40 # error "Microsoft Visual Studio 2013 or higher required"
44 * Visual Studio will complain if we define the `inline` keyword, but
45 * actually it only supports the keyword on C++.
47 * To avoid this the _ALLOW_KEYWORD_MACROS must be set.
49 # if !defined(_ALLOW_KEYWORD_MACROS)
50 # define _ALLOW_KEYWORD_MACROS
54 * XXX: MSVC has a `__restrict` keyword, but it also has a
55 * `__declspec(restrict)` modifier, so it is impossible to define a
56 * `restrict` macro without interfering with the latter. Furthermore the
57 * MSVC standard library uses __declspec(restrict) under the _CRTRESTRICT
58 * macro. For now resolve this issue by redefining _CRTRESTRICT, but going
59 * forward we should probably should stop using restrict, especially
60 * considering that our code does not obbey strict aliasing rules any way.
73 /* C++ supports inline keyword */
74 # elif defined(__GNUC__)
75 # define inline __inline__
76 # elif defined(_MSC_VER)
77 # define inline __inline
79 # define inline __inline
80 # elif defined(__INTEL_COMPILER)
81 /* Intel compiler supports inline keyword */
82 # elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
83 # define inline __inline
84 # elif (__STDC_VERSION__ >= 199901L)
85 /* C99 supports inline keyword */
93 * C99 restrict keyword
96 * - http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html
99 # if (__STDC_VERSION__ >= 199901L)
101 # elif defined(__GNUC__)
102 # define restrict __restrict__
103 # elif defined(_MSC_VER)
104 # define restrict __restrict
106 # define restrict /* */
115 # if (__STDC_VERSION__ >= 199901L)
117 # elif defined(__GNUC__)
118 # define __func__ __FUNCTION__
119 # elif defined(_MSC_VER)
120 # define __func__ __FUNCTION__
122 # define __func__ "<unknown>"
127 /* Simple test case for debugging */
129 static inline const char *
130 test_c99_compat_h(const void * restrict a
,
131 const void * restrict b
)
138 #endif /* _C99_COMPAT_H_ */