| 1 | #serial 1002, but ported to autoconf 2.13 by eggert
|
|---|
| 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 | [jm_CHECK_DECLARATION(strerror_r, [#include <string.h>])
|
|---|
| 13 | test $jm_cv_func_decl_strerror_r != yes
|
|---|
| 14 | AC_DEFINE_UNQUOTED(HAVE_DECL_STRERROR_R, $?,
|
|---|
| 15 | [Define to 1 if strerror_r is declared.])
|
|---|
| 16 | AC_CHECK_FUNCS([strerror_r])
|
|---|
| 17 | if test $ac_cv_func_strerror_r = yes; then
|
|---|
| 18 | AC_CHECK_HEADERS(string.h)
|
|---|
| 19 | AC_CACHE_CHECK([for working strerror_r],
|
|---|
| 20 | ac_cv_func_strerror_r_works,
|
|---|
| 21 | [
|
|---|
| 22 | AC_TRY_COMPILE(
|
|---|
| 23 | [
|
|---|
| 24 | # include <stdio.h>
|
|---|
| 25 | # if HAVE_STRING_H
|
|---|
| 26 | # include <string.h>
|
|---|
| 27 | # endif
|
|---|
| 28 | ],
|
|---|
| 29 | [
|
|---|
| 30 | char buf[100];
|
|---|
| 31 | char x = *strerror_r (0, buf, sizeof buf);
|
|---|
| 32 | ],
|
|---|
| 33 | ac_cv_func_strerror_r_works=yes,
|
|---|
| 34 | ac_cv_func_strerror_r_works=no
|
|---|
| 35 | )
|
|---|
| 36 | if test $ac_cv_func_strerror_r_works = no; then
|
|---|
| 37 | # strerror_r seems not to work, but now we have to choose between
|
|---|
| 38 | # systems that have relatively inaccessible declarations for the
|
|---|
| 39 | # function. BeOS and DEC UNIX 4.0 fall in this category, but the
|
|---|
| 40 | # former has a strerror_r that returns char*, while the latter
|
|---|
| 41 | # has a strerror_r that returns int.
|
|---|
| 42 | # This test should segfault on the DEC system.
|
|---|
| 43 | AC_TRY_RUN(
|
|---|
| 44 | [
|
|---|
| 45 | # include <stdio.h>
|
|---|
| 46 | # include <string.h>
|
|---|
| 47 | # include <ctype.h>
|
|---|
| 48 |
|
|---|
| 49 | extern char *strerror_r ();
|
|---|
| 50 |
|
|---|
| 51 | int
|
|---|
| 52 | main ()
|
|---|
| 53 | {
|
|---|
| 54 | char buf[100];
|
|---|
| 55 | char x = *strerror_r (0, buf, sizeof buf);
|
|---|
| 56 | exit (!isalpha (x));
|
|---|
| 57 | }
|
|---|
| 58 | ],
|
|---|
| 59 | ac_cv_func_strerror_r_works=yes,
|
|---|
| 60 | ac_cv_func_strerror_r_works=no,
|
|---|
| 61 | ac_cv_func_strerror_r_works=no)
|
|---|
| 62 | fi
|
|---|
| 63 | ])
|
|---|
| 64 | if test $ac_cv_func_strerror_r_works = yes; then
|
|---|
| 65 | AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1,
|
|---|
| 66 | [Define to 1 if strerror_r returns a string.])
|
|---|
| 67 | fi
|
|---|
| 68 | fi
|
|---|
| 69 | ])# AC_FUNC_STRERROR_R
|
|---|