]> git.saurik.com Git - bison.git/blob - m4/strerror_r.m4
* src/print_graph.c (print_actions): CPP out useless code.
[bison.git] / m4 / strerror_r.m4
1 #serial 1002
2 # Experimental replacement for the function in the latest CVS autoconf.
3 # If the compile-test says strerror_r doesn't work, then resort to a
4 # `run'-test that works on BeOS and segfaults on DEC Unix.
5 # Use with the error.c file in ../lib.
6
7 undefine([AC_FUNC_STRERROR_R])
8
9 # AC_FUNC_STRERROR_R
10 # ------------------
11 AC_DEFUN([AC_FUNC_STRERROR_R],
12 [AC_CHECK_DECLS([strerror_r])
13 AC_CHECK_FUNCS([strerror_r])
14 if test $ac_cv_func_strerror_r = yes; then
15 AC_CHECK_HEADERS(string.h)
16 AC_CACHE_CHECK([for working strerror_r],
17 ac_cv_func_strerror_r_works,
18 [
19 AC_TRY_COMPILE(
20 [
21 # include <stdio.h>
22 # if HAVE_STRING_H
23 # include <string.h>
24 # endif
25 ],
26 [
27 char buf[100];
28 char x = *strerror_r (0, buf, sizeof buf);
29 ],
30 ac_cv_func_strerror_r_works=yes,
31 ac_cv_func_strerror_r_works=no
32 )
33 if test $ac_cv_func_strerror_r_works = no; then
34 # strerror_r seems not to work, but now we have to choose between
35 # systems that have relatively inaccessible declarations for the
36 # function. BeOS and DEC UNIX 4.0 fall in this category, but the
37 # former has a strerror_r that returns char*, while the latter
38 # has a strerror_r that returns `int'.
39 # This test should segfault on the DEC system.
40 AC_TRY_RUN(
41 [
42 # include <stdio.h>
43 # include <string.h>
44 # include <ctype.h>
45
46 extern char *strerror_r ();
47
48 int
49 main ()
50 {
51 char buf[100];
52 char x = *strerror_r (0, buf, sizeof buf);
53 exit (!isalpha (x));
54 }
55 ],
56 ac_cv_func_strerror_r_works=yes,
57 ac_cv_func_strerror_r_works=no,
58 ac_cv_func_strerror_r_works=no)
59 fi
60 ])
61 if test $ac_cv_func_strerror_r_works = yes; then
62 AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1,
63 [Define to 1 if `strerror_r' returns a string.])
64 fi
65 fi
66 ])# AC_FUNC_STRERROR_R