mirror of
https://github.com/postgres/postgres.git
synced 2025-05-17 00:03:56 -04:00
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
This commit is contained in:
parent
5fa6b0d102
commit
0b974dba2d
46
configure
vendored
46
configure
vendored
@ -11545,6 +11545,52 @@ _ACEOF
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
|
||||||
|
$as_echo_n "checking for C/C++ restrict keyword... " >&6; }
|
||||||
|
if ${ac_cv_c_restrict+:} false; then :
|
||||||
|
$as_echo_n "(cached) " >&6
|
||||||
|
else
|
||||||
|
ac_cv_c_restrict=no
|
||||||
|
# The order here caters to the fact that C++ does not require restrict.
|
||||||
|
for ac_kw in __restrict __restrict__ _Restrict restrict; do
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
typedef int * int_ptr;
|
||||||
|
int foo (int_ptr $ac_kw ip) {
|
||||||
|
return ip[0];
|
||||||
|
}
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
int s[1];
|
||||||
|
int * $ac_kw t = s;
|
||||||
|
t[0] = 0;
|
||||||
|
return foo(t)
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
if ac_fn_c_try_compile "$LINENO"; then :
|
||||||
|
ac_cv_c_restrict=$ac_kw
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||||
|
test "$ac_cv_c_restrict" != no && break
|
||||||
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5
|
||||||
|
$as_echo "$ac_cv_c_restrict" >&6; }
|
||||||
|
|
||||||
|
case $ac_cv_c_restrict in
|
||||||
|
restrict) ;;
|
||||||
|
no) $as_echo "#define restrict /**/" >>confdefs.h
|
||||||
|
;;
|
||||||
|
*) cat >>confdefs.h <<_ACEOF
|
||||||
|
#define restrict $ac_cv_c_restrict
|
||||||
|
_ACEOF
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf format archetype" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf format archetype" >&5
|
||||||
$as_echo_n "checking for printf format archetype... " >&6; }
|
$as_echo_n "checking for printf format archetype... " >&6; }
|
||||||
if ${pgac_cv_printf_archetype+:} false; then :
|
if ${pgac_cv_printf_archetype+:} false; then :
|
||||||
|
@ -1299,6 +1299,7 @@ fi
|
|||||||
m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that.
|
m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that.
|
||||||
AC_C_BIGENDIAN
|
AC_C_BIGENDIAN
|
||||||
AC_C_INLINE
|
AC_C_INLINE
|
||||||
|
AC_C_RESTRICT
|
||||||
PGAC_PRINTF_ARCHETYPE
|
PGAC_PRINTF_ARCHETYPE
|
||||||
AC_C_FLEXIBLE_ARRAY_MEMBER
|
AC_C_FLEXIBLE_ARRAY_MEMBER
|
||||||
PGAC_C_SIGNED
|
PGAC_C_SIGNED
|
||||||
|
@ -923,6 +923,20 @@
|
|||||||
if such a type exists, and if the system does not define it. */
|
if such a type exists, and if the system does not define it. */
|
||||||
#undef intptr_t
|
#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. */
|
/* Define to empty if the C compiler does not understand signed types. */
|
||||||
#undef signed
|
#undef signed
|
||||||
|
|
||||||
|
@ -681,6 +681,17 @@
|
|||||||
#define inline __inline
|
#define inline __inline
|
||||||
#endif
|
#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. */
|
/* Define to empty if the C compiler does not understand signed types. */
|
||||||
/* #undef signed */
|
/* #undef signed */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user