commit a50d5c0b5381914b6ac8370e23a26292efb97d7d
parent c55556632a4f4f705ce637e9ad9e8dc1c01eeb3d
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Tue, 31 Mar 2026 02:07:52 +0200
configure: replace standard 'restrict' keyword detection with custom test
Diffstat:
| M | configure.ac | | | 44 | ++++++++++++++++++++++++++++++++++---------- |
1 file changed, 34 insertions(+), 10 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -1393,19 +1393,43 @@ AS_VAR_IF([mhd_cv_enum_base_type],["yes"],
]
)
-
-AS_VAR_SET_IF([ac_cv_c_restrict],[],
+# MHD uses 'restrict' keyword in a standard way and does not need
+# extra combinations checked by AC_C_RESTRICT
+AC_CACHE_CHECK([for 'restrict' keyword supported by $CC],
+ [mhd_cv_c_restrict],
[
- # "cache" result in advance if it is known from the compiler test
- AS_CASE([$ac_prog_cc_stdc],
- [c89],[:],
- [c??],[ac_cv_c_restrict="restrict"]
- )
+ ac_c_werror_flag="yes"
+ for chk_kw in restrict __restrict__ __restrict _restrict _Restrict; do
+ AC_COMPILE_IFELSE(
+ [
+ AC_LANG_SOURCE([[
+#ifdef __cplusplus
+#define restrict do not use 'restrict' with C++ compilers [-1]
+#endif
+void test_sum(unsigned int n,
+ unsigned int *${chk_kw} dst_arr,
+ const unsigned int *${chk_kw} src_arr,
+ const unsigned int *${chk_kw} bias);
+void test_sum(unsigned int n,
+ unsigned int *${chk_kw} dst_arr,
+ const unsigned int *${chk_kw} src_arr,
+ const unsigned int *${chk_kw} bias)
+{ while (n--) {dst_arr[n] = src_arr[n] + (*bias);} }
+ ]]
+ )
+ ],[mhd_cv_c_restrict="${chk_kw}"]
+ )
+ test -z "${mhd_cv_c_restrict}" || break
+ done
+ ac_c_werror_flag=""
+ test -n "${mhd_cv_c_restrict}" || mhd_cv_c_restrict="no"
]
)
-AC_C_RESTRICT
-AS_VAR_IF([ac_cv_c_restrict],["no"],[],
- [AC_DEFINE([HAVE_RESTRICT],[1],[Define to '1' if your compiler supports 'restrict' keyword])]
+AS_CASE([${mhd_cv_c_restrict}],
+ [restrict],[],
+ [no],
+ [AC_DEFINE([restrict],[/* Unsupported. Empty macro */],[Define to supported 'restrict' replacement keyword])],
+ [AC_DEFINE_UNQUOTED([restrict],["${mhd_cv_c_restrict}"])]
)
AC_C_INLINE
AS_VAR_IF([ac_cv_c_inline],["no"],[],