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