1 | /**************************************************************************
|
---|
2 | *
|
---|
3 | * Copyright 2007-2013 VMware, Inc.
|
---|
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 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.
|
---|
25 | *
|
---|
26 | **************************************************************************/
|
---|
27 |
|
---|
28 | #include "no_extern_c.h"
|
---|
29 |
|
---|
30 | #ifndef _C99_COMPAT_H_
|
---|
31 | #define _C99_COMPAT_H_
|
---|
32 |
|
---|
33 |
|
---|
34 | /*
|
---|
35 | * MSVC hacks.
|
---|
36 | */
|
---|
37 | #if defined(_MSC_VER)
|
---|
38 |
|
---|
39 | # if _MSC_VER < 1900
|
---|
40 | # error "Microsoft Visual Studio 2015 or higher required"
|
---|
41 | # endif
|
---|
42 |
|
---|
43 | /*
|
---|
44 | * XXX: MSVC has a `__restrict` keyword, but it also has a
|
---|
45 | * `__declspec(restrict)` modifier, so it is impossible to define a
|
---|
46 | * `restrict` macro without interfering with the latter. Furthermore the
|
---|
47 | * MSVC standard library uses __declspec(restrict) under the _CRTRESTRICT
|
---|
48 | * macro. For now resolve this issue by redefining _CRTRESTRICT, but going
|
---|
49 | * forward we should probably should stop using restrict, especially
|
---|
50 | * considering that our code does not obbey strict aliasing rules any way.
|
---|
51 | */
|
---|
52 | # ifndef IPRT_NO_CRT
|
---|
53 | # include <crtdefs.h>
|
---|
54 | # undef _CRTRESTRICT
|
---|
55 | # define _CRTRESTRICT
|
---|
56 | # endif
|
---|
57 | #endif
|
---|
58 |
|
---|
59 |
|
---|
60 | /*
|
---|
61 | * C99 restrict keyword
|
---|
62 | *
|
---|
63 | * See also:
|
---|
64 | * - http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html
|
---|
65 | */
|
---|
66 | #ifndef restrict
|
---|
67 | # ifndef __cplusplus
|
---|
68 | /* Use C99 restrict keyword */
|
---|
69 | # elif defined(__GNUC__)
|
---|
70 | # define restrict __restrict__
|
---|
71 | # elif defined(_MSC_VER)
|
---|
72 | # define restrict __restrict
|
---|
73 | # else
|
---|
74 | # define restrict /* */
|
---|
75 | # endif
|
---|
76 | #endif
|
---|
77 |
|
---|
78 |
|
---|
79 | /* Simple test case for debugging */
|
---|
80 | #if 0
|
---|
81 | static inline const char *
|
---|
82 | test_c99_compat_h(const void * restrict a,
|
---|
83 | const void * restrict b)
|
---|
84 | {
|
---|
85 | return __func__;
|
---|
86 | }
|
---|
87 | #endif
|
---|
88 |
|
---|
89 |
|
---|
90 | #endif /* _C99_COMPAT_H_ */
|
---|