From 24aaa24b5c39db0a204b7ed78d5bbc154563dd0a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 2 May 2011 17:06:32 -0700 Subject: Check for the C99 restrict keyword GCC does not default to C99 mode yet, so does not know restrict, however it still allows using __restrict in its place --- CMakeLists.txt | 6 ++++++ OpenAL32/Include/alMain.h | 8 ++++++++ config.h.in | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78110594..a4d4c254 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,12 @@ CHECK_TYPE_SIZE("unsigned int" SIZEOF_UINT) CHECK_TYPE_SIZE("void*" SIZEOF_VOIDP) +CHECK_C_SOURCE_COMPILES("int *restrict foo; + int main() {return 0;}" HAVE_RESTRICT) +CHECK_C_SOURCE_COMPILES("int *__restrict foo; + int main() {return 0;}" HAVE___RESTRICT) + + # Add definitions, compiler switches, etc. INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}") diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 09b85baf..aa1b50a1 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -171,6 +171,14 @@ typedef unsigned long long ALuint64; #define PRINTF_STYLE(x, y) #endif +#if defined(HAVE_RESTRICT) +#define RESTRICT restrict +#elif defined(HAVE___RESTRICT) +#define RESTRICT __restrict +#else +#define RESTRICT +#endif + #ifdef _WIN32 #ifndef _WIN32_WINNT diff --git a/config.h.in b/config.h.in index c031ce45..f14ecb52 100644 --- a/config.h.in +++ b/config.h.in @@ -97,4 +97,10 @@ /* Define if we have pthread_setschedparam() */ #cmakedefine HAVE_PTHREAD_SETSCHEDPARAM +/* Define if we have the restrict keyword */ +#cmakedefine HAVE_RESTRICT + +/* Define if we have the __restrict keyword */ +#cmakedefine HAVE___RESTRICT + #endif -- cgit v1.2.3