strerror_r.m4 1.8 KB

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