/**************************************************************************1*2* Copyright 2007-2013 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#include "no_extern_c.h"2829#ifndef _C99_COMPAT_H_30#define _C99_COMPAT_H_313233/*34* MSVC hacks.35*/36#if defined(_MSC_VER)3738# if _MSC_VER < 190039# error "Microsoft Visual Studio 2015 or higher required"40# endif4142/*43* Visual Studio will complain if we define the `inline` keyword, but44* actually it only supports the keyword on C++.45*46* To avoid this the _ALLOW_KEYWORD_MACROS must be set.47*/48# if !defined(_ALLOW_KEYWORD_MACROS)49# define _ALLOW_KEYWORD_MACROS50# endif5152/*53* XXX: MSVC has a `__restrict` keyword, but it also has a54* `__declspec(restrict)` modifier, so it is impossible to define a55* `restrict` macro without interfering with the latter. Furthermore the56* MSVC standard library uses __declspec(restrict) under the _CRTRESTRICT57* macro. For now resolve this issue by redefining _CRTRESTRICT, but going58* forward we should probably should stop using restrict, especially59* considering that our code does not obbey strict aliasing rules any way.60*/61# include <crtdefs.h>62# undef _CRTRESTRICT63# define _CRTRESTRICT64#endif656667/*68* C99 inline keyword69*/70#ifndef inline71# ifdef __cplusplus72/* C++ supports inline keyword */73# elif defined(__GNUC__)74# define inline __inline__75# elif defined(_MSC_VER)76# define inline __inline77# elif defined(__ICL)78# define inline __inline79# elif defined(__INTEL_COMPILER)80/* Intel compiler supports inline keyword */81# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)82# define inline __inline83# elif (__STDC_VERSION__ >= 199901L)84/* C99 supports inline keyword */85# else86# define inline87# endif88#endif899091/*92* C99 restrict keyword93*94* See also:95* - http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html96*/97#ifndef restrict98# if (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)99/* C99 */100# elif defined(__GNUC__)101# define restrict __restrict__102# elif defined(_MSC_VER)103# define restrict __restrict104# else105# define restrict /* */106# endif107#endif108109110/*111* C99 __func__ macro112*/113#ifndef __func__114# if (__STDC_VERSION__ >= 199901L)115/* C99 */116# elif defined(__GNUC__)117# define __func__ __FUNCTION__118# elif defined(_MSC_VER)119# define __func__ __FUNCTION__120# else121# define __func__ "<unknown>"122# endif123#endif124125126/* Simple test case for debugging */127#if 0128static inline const char *129test_c99_compat_h(const void * restrict a,130const void * restrict b)131{132return __func__;133}134#endif135136137#endif /* _C99_COMPAT_H_ */138139140