1 dnl /usr/share/aclocal/ac-archive-cvs/acx_restrict.m4
2 dnl @synopsis ACX_C_RESTRICT
4 dnl @obsoleted Replaced by AC_C_RESTRICT in Autoconf 2.58
6 dnl This macro determines whether the C compiler supports the
7 dnl "restrict" keyword introduced in ANSI C99, or an equivalent. Does
8 dnl nothing if the compiler accepts the keyword. Otherwise, if the
9 dnl compiler supports an equivalent (like gcc's __restrict__) defines
10 dnl "restrict" to be that. Otherwise, defines "restrict" to be empty.
12 dnl @category Obsolete
13 dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
14 dnl @version 2005-05-31
15 dnl @license GPLWithACException
17 AC_DEFUN([ACX_C_RESTRICT],
18 [AC_CACHE_CHECK([for C restrict keyword], acx_cv_c_restrict,
19 [acx_cv_c_restrict=unsupported
22 # Try the official restrict keyword, then gcc's __restrict__, then
23 # SGI's __restrict. __restrict has slightly different semantics than
24 # restrict (it's a bit stronger, in that __restrict pointers can't
25 # overlap even with non __restrict pointers), but I think it should be
26 # okay under the circumstances where restrict is normally used.
27 for acx_kw in restrict __restrict__ __restrict; do
28 AC_TRY_COMPILE([], [float * $acx_kw x;], [acx_cv_c_restrict=$acx_kw; break])
32 if test "$acx_cv_c_restrict" != "restrict"; then
33 acx_kw="$acx_cv_c_restrict"
34 if test "$acx_kw" = unsupported; then acx_kw=""; fi
35 AC_DEFINE_UNQUOTED(restrict, $acx_kw, [Define to equivalent of C99 restrict keyword, or to nothing if this is not supported. Do not define if restrict is supported directly.])