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.
7 undefine([AC_FUNC_STRERROR_R])
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,
28 char x = *strerror_r (0, buf, sizeof buf);
30 ac_cv_func_strerror_r_works=yes,
31 ac_cv_func_strerror_r_works=no
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.
46 extern char *strerror_r ();
52 char x = *strerror_r (0, buf, sizeof buf);
56 ac_cv_func_strerror_r_works=yes,
57 ac_cv_func_strerror_r_works=no,
58 ac_cv_func_strerror_r_works=no)
61 if test $ac_cv_func_strerror_r_works = yes; then
62 AC_DEFINE(HAVE_WORKING_STRERROR_R, 1,
63 [Define to 1 if `strerror_r' returns a string.])
66 ])# AC_FUNC_STRERROR_R