From 0b974dba2d6b5581ce422ed883209de46f313fb6 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Wed, 11 Oct 2017 16:01:52 -0700 Subject: Add configure infrastructure to detect support for C99's restrict. Will be used in later commits improving performance for a few key routines where information about aliasing allows for significantly better code generation. This allows to use the C99 'restrict' keyword without breaking C89, or for that matter C++, compilers. If not supported it's defined to be empty. Author: Andres Freund Discussion: https://postgr.es/m/20170914063418.sckdzgjfrsbekae4@alap3.anarazel.de --- src/include/pg_config.h.in | 14 ++++++++++++++ src/include/pg_config.h.win32 | 11 +++++++++++ 2 files changed, 25 insertions(+) (limited to 'src') diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index b0298cca19c..80ee37dd622 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -923,6 +923,20 @@ if such a type exists, and if the system does not define it. */ #undef intptr_t +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#undef restrict +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif + /* Define to empty if the C compiler does not understand signed types. */ #undef signed diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index b76aad02676..3be1c235aaa 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -681,6 +681,17 @@ #define inline __inline #endif +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +/* Visual Studio 2008 and upwards */ +#if (_MSC_VER >= 1500) +/* works for C and C++ in msvc */ +#define restrict __restrict +#else +#define restrict +#endif + /* Define to empty if the C compiler does not understand signed types. */ /* #undef signed */ -- cgit v1.2.3