Browse code

add AC_C_RESTRICT (bb #452)

git-svn: trunk@3564

Török Edvin authored on 2008/01/31 06:12:43
Showing 4 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Jan 30 22:52:54 EET 2008 (edwin)
2
+------------------------------------
3
+ * configure.in,configure: add AC_C_RESTRICT (bb #452)
4
+
1 5
 Wed Jan 30 22:42:39 EET 2008 (edwin)
2 6
 ------------------------------------
3 7
  * build system modernization: (based on suggestion from
... ...
@@ -390,5 +390,9 @@
390 390
 /* Define to `long int' if <sys/types.h> does not define. */
391 391
 #undef off_t
392 392
 
393
+/* Define to equivalent of C99 restrict keyword, or to nothing if this is not
394
+   supported. Do not define if restrict is supported directly. */
395
+#undef restrict
396
+
393 397
 /* Define to "int" if <sys/socket.h> does not define. */
394 398
 #undef socklen_t
... ...
@@ -10215,6 +10215,81 @@ _ACEOF
10215 10215
 
10216 10216
 fi
10217 10217
 
10218
+{ echo "$as_me:$LINENO: checking for C/C++ restrict keyword" >&5
10219
+echo $ECHO_N "checking for C/C++ restrict keyword... $ECHO_C" >&6; }
10220
+if test "${ac_cv_c_restrict+set}" = set; then
10221
+  echo $ECHO_N "(cached) $ECHO_C" >&6
10222
+else
10223
+  ac_cv_c_restrict=no
10224
+   # Try the official restrict keyword, then gcc's __restrict, and
10225
+   # the less common variants.
10226
+   for ac_kw in restrict __restrict __restrict__ _Restrict; do
10227
+     cat >conftest.$ac_ext <<_ACEOF
10228
+/* confdefs.h.  */
10229
+_ACEOF
10230
+cat confdefs.h >>conftest.$ac_ext
10231
+cat >>conftest.$ac_ext <<_ACEOF
10232
+/* end confdefs.h.  */
10233
+typedef int * int_ptr;
10234
+        int foo (int_ptr $ac_kw ip) {
10235
+        return ip[0];
10236
+       }
10237
+int
10238
+main ()
10239
+{
10240
+int s[1];
10241
+        int * $ac_kw t = s;
10242
+        t[0] = 0;
10243
+        return foo(t)
10244
+  ;
10245
+  return 0;
10246
+}
10247
+_ACEOF
10248
+rm -f conftest.$ac_objext
10249
+if { (ac_try="$ac_compile"
10250
+case "(($ac_try" in
10251
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
10252
+  *) ac_try_echo=$ac_try;;
10253
+esac
10254
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
10255
+  (eval "$ac_compile") 2>conftest.er1
10256
+  ac_status=$?
10257
+  grep -v '^ *+' conftest.er1 >conftest.err
10258
+  rm -f conftest.er1
10259
+  cat conftest.err >&5
10260
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
10261
+  (exit $ac_status); } && {
10262
+	 test -z "$ac_c_werror_flag" ||
10263
+	 test ! -s conftest.err
10264
+       } && test -s conftest.$ac_objext; then
10265
+  ac_cv_c_restrict=$ac_kw
10266
+else
10267
+  echo "$as_me: failed program was:" >&5
10268
+sed 's/^/| /' conftest.$ac_ext >&5
10269
+
10270
+
10271
+fi
10272
+
10273
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
10274
+     test "$ac_cv_c_restrict" != no && break
10275
+   done
10276
+
10277
+fi
10278
+{ echo "$as_me:$LINENO: result: $ac_cv_c_restrict" >&5
10279
+echo "${ECHO_T}$ac_cv_c_restrict" >&6; }
10280
+ case $ac_cv_c_restrict in
10281
+   restrict) ;;
10282
+   no)
10283
+cat >>confdefs.h <<\_ACEOF
10284
+#define restrict
10285
+_ACEOF
10286
+ ;;
10287
+   *)  cat >>confdefs.h <<_ACEOF
10288
+#define restrict $ac_cv_c_restrict
10289
+_ACEOF
10290
+ ;;
10291
+ esac
10292
+
10218 10293
 
10219 10294
 # Check whether --enable-gcc-vcheck was given.
10220 10295
 if test "${enable_gcc_vcheck+set}" = set; then
... ...
@@ -64,6 +64,7 @@ AC_DEFINE(SCANBUFF, 131072, [scan buffer size])
64 64
 AC_DEFINE(FILEBUFF, 8192,   [file i/o buffer size])
65 65
 
66 66
 AC_HEADER_STDC
67
+AC_C_RESTRICT
67 68
 
68 69
 AC_ARG_ENABLE(gcc-vcheck,
69 70
 [  --disable-gcc-vcheck	  do not check for buggy gcc version ],