1#serial 1003 2dnl Copyright (C) 2003 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7# This macro can be removed once we can rely on Autoconf 2.57a or later, 8# since we can then use its AC_C_RESTRICT. 9 10# gl_C_RESTRICT 11# -------------- 12# Determine whether the C/C++ compiler supports the "restrict" keyword 13# introduced in ANSI C99, or an equivalent. Do nothing if the compiler 14# accepts it. Otherwise, if the compiler supports an equivalent, 15# define "restrict" to be that. Here are some variants: 16# - GCC supports both __restrict and __restrict__ 17# - older DEC Alpha C compilers support only __restrict 18# - _Restrict is the only spelling accepted by Sun WorkShop 6 update 2 C 19# Otherwise, define "restrict" to be empty. 20AC_DEFUN([gl_C_RESTRICT], 21[AC_CACHE_CHECK([for C/C++ restrict keyword], gl_cv_c_restrict, 22 [gl_cv_c_restrict=no 23 # Try the official restrict keyword, then gcc's __restrict, and 24 # the less common variants. 25 for ac_kw in restrict __restrict __restrict__ _Restrict; do 26 AC_COMPILE_IFELSE([AC_LANG_SOURCE( 27 [float * $ac_kw x;])], 28 [gl_cv_c_restrict=$ac_kw; break]) 29 done 30 ]) 31 case $gl_cv_c_restrict in 32 restrict) ;; 33 no) AC_DEFINE(restrict,, 34 [Define to equivalent of C99 restrict keyword, or to nothing if this 35 is not supported. Do not define if restrict is supported directly.]) ;; 36 *) AC_DEFINE_UNQUOTED(restrict, $gl_cv_c_restrict) ;; 37 esac 38]) 39