Clone of mesa.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. #include "no_extern_c.h"
  28. #ifndef _C99_COMPAT_H_
  29. #define _C99_COMPAT_H_
  30. /*
  31. * MSVC hacks.
  32. */
  33. #if defined(_MSC_VER)
  34. # if _MSC_VER < 1500
  35. # error "Microsoft Visual Studio 2008 or higher required"
  36. # endif
  37. /*
  38. * Visual Studio 2012 will complain if we define the `inline` keyword, but
  39. * actually it only supports the keyword on C++.
  40. *
  41. * To avoid this the _ALLOW_KEYWORD_MACROS must be set.
  42. */
  43. # if (_MSC_VER >= 1700) && !defined(_ALLOW_KEYWORD_MACROS)
  44. # define _ALLOW_KEYWORD_MACROS
  45. # endif
  46. /*
  47. * XXX: MSVC has a `__restrict` keyword, but it also has a
  48. * `__declspec(restrict)` modifier, so it is impossible to define a
  49. * `restrict` macro without interfering with the latter. Furthermore the
  50. * MSVC standard library uses __declspec(restrict) under the _CRTRESTRICT
  51. * macro. For now resolve this issue by redefining _CRTRESTRICT, but going
  52. * forward we should probably should stop using restrict, especially
  53. * considering that our code does not obbey strict aliasing rules any way.
  54. */
  55. # include <crtdefs.h>
  56. # undef _CRTRESTRICT
  57. # define _CRTRESTRICT
  58. #endif
  59. /*
  60. * C99 inline keyword
  61. */
  62. #ifndef inline
  63. # ifdef __cplusplus
  64. /* C++ supports inline keyword */
  65. # elif defined(__GNUC__)
  66. # define inline __inline__
  67. # elif defined(_MSC_VER)
  68. # define inline __inline
  69. # elif defined(__ICL)
  70. # define inline __inline
  71. # elif defined(__INTEL_COMPILER)
  72. /* Intel compiler supports inline keyword */
  73. # elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
  74. # define inline __inline
  75. # elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
  76. /* C99 supports inline keyword */
  77. # elif (__STDC_VERSION__ >= 199901L)
  78. /* C99 supports inline keyword */
  79. # else
  80. # define inline
  81. # endif
  82. #endif
  83. /*
  84. * C99 restrict keyword
  85. *
  86. * See also:
  87. * - http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html
  88. */
  89. #ifndef restrict
  90. # if (__STDC_VERSION__ >= 199901L)
  91. /* C99 */
  92. # elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
  93. /* C99 */
  94. # elif defined(__GNUC__)
  95. # define restrict __restrict__
  96. # elif defined(_MSC_VER)
  97. # define restrict __restrict
  98. # else
  99. # define restrict /* */
  100. # endif
  101. #endif
  102. /*
  103. * C99 __func__ macro
  104. */
  105. #ifndef __func__
  106. # if (__STDC_VERSION__ >= 199901L)
  107. /* C99 */
  108. # elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
  109. /* C99 */
  110. # elif defined(__GNUC__)
  111. # define __func__ __FUNCTION__
  112. # elif defined(_MSC_VER)
  113. # define __func__ __FUNCTION__
  114. # else
  115. # define __func__ "<unknown>"
  116. # endif
  117. #endif
  118. /* Simple test case for debugging */
  119. #if 0
  120. static inline const char *
  121. test_c99_compat_h(const void * restrict a,
  122. const void * restrict b)
  123. {
  124. return __func__;
  125. }
  126. #endif
  127. #endif /* _C99_COMPAT_H_ */