Skip to content

Commit

Permalink
Add configure check for restrict keyword.
Browse files Browse the repository at this point in the history
  • Loading branch information
millert committed Jul 7, 2023
1 parent 0205f6f commit f7801f2
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
15 changes: 15 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,21 @@
/* Define to an OS-specific initialization function or 'os_init_common'. */
#undef os_init

/* Define to the equivalent of the C99 'restrict' keyword, or to
nothing if this is not supported. Do not define if restrict is
supported only directly. */
#undef restrict
/* Work around a bug in older versions of Sun C++, which did not
#define __restrict__ or support _Restrict or __restrict__
even though the corresponding Sun C compiler ended up with
"#define restrict _Restrict" or "#define restrict __restrict__"
in the previous line. This workaround can be removed once
we assume Oracle Developer Studio 12.5 (2016) or later. */
#if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
# define _Restrict
# define __restrict__
#endif

/* Define as 'int' if <sys/types.h> doesn't define. */
#undef uid_t

Expand Down
51 changes: 51 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -19022,6 +19022,57 @@ printf "%s\n" "#define const /**/" >>confdefs.h

fi

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
printf %s "checking for C/C++ restrict keyword... " >&6; }
if test ${ac_cv_c_restrict+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) ac_cv_c_restrict=no
# Put '__restrict__' first, to avoid problems with glibc and non-GCC; see:
# https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html
# Put 'restrict' last, because C++ lacks it.
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 bar (int [$ac_kw]); /* Catch GCC bug 14050. */
int bar (int ip[$ac_kw]) { return ip[0]; }

int
main (void)
{
int s[1];
int *$ac_kw t = s;
t[0] = 0;
return foo (t) + bar (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.beam conftest.$ac_ext
test "$ac_cv_c_restrict" != no && break
done
;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5
printf "%s\n" "$ac_cv_c_restrict" >&6; }

case $ac_cv_c_restrict in
restrict) ;;
no) printf "%s\n" "#define restrict /**/" >>confdefs.h
;;
*) printf "%s\n" "#define restrict $ac_cv_c_restrict" >>confdefs.h
;;
esac

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
printf %s "checking for inline... " >&6; }
if test ${ac_cv_c_inline+y}
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,7 @@ dnl AC_PROG_CC_STDC is deprecated in autoconf 2.70 and above.
dnl
m4_bmatch(m4_defn([AC_AUTOCONF_VERSION]), [^2\.69], [AC_PROG_CC_STDC])
AC_C_CONST
AC_C_RESTRICT
AC_C_INLINE
AC_C_VOLATILE
SUDO_CPP_VARIADIC_MACROS
Expand Down

0 comments on commit f7801f2

Please sign in to comment.