X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=include%2Fc99_compat.h;h=429c6014845ac3470cc3b14860c6503ea7ccd2b4;hb=9f3cfe6aafc210906be85de065afff7503ef240b;hp=39f958fdfdda8b7405632cd48e62daa8167278f8;hpb=70fe7c6d3e1c7534f6598c4616bebf672f42668b;p=mesa.git diff --git a/include/c99_compat.h b/include/c99_compat.h index 39f958fdfdd..429c6014845 100644 --- a/include/c99_compat.h +++ b/include/c99_compat.h @@ -29,6 +29,35 @@ #define _C99_COMPAT_H_ +/* + * MSVC hacks. + */ +#if defined(_MSC_VER) + /* + * Visual Studio 2012 will complain if we define the `inline` keyword, but + * actually it only supports the keyword on C++. + * + * To avoid this the _ALLOW_KEYWORD_MACROS must be set. + */ +# if (_MSC_VER >= 1700) && !defined(_ALLOW_KEYWORD_MACROS) +# define _ALLOW_KEYWORD_MACROS +# endif + + /* + * XXX: MSVC has a `__restrict` keyword, but it also has a + * `__declspec(restrict)` modifier, so it is impossible to define a + * `restrict` macro without interfering with the latter. Furthermore the + * MSVC standard library uses __declspec(restrict) under the _CRTRESTRICT + * macro. For now resolve this issue by redefining _CRTRESTRICT, but going + * forward we should probably should stop using restrict, especially + * considering that our code does not obbey strict aliasing rules any way. + */ +# include +# undef _CRTRESTRICT +# define _CRTRESTRICT +#endif + + /* * C99 inline keyword */ @@ -102,4 +131,15 @@ #endif +/* Simple test case for debugging */ +#if 0 +static inline const char * +test_c99_compat_h(const void * restrict a, + const void * restrict b) +{ + return __func__; +} +#endif + + #endif /* _C99_COMPAT_H_ */