strerror_r.m4 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #serial 1003
  2. # Experimental replacement for the function in the latest CVS autoconf.
  3. # Use with the error.c file in ../lib.
  4. # Copyright 2001 Free Software Foundation, Inc.
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  16. undefine([AC_FUNC_STRERROR_R])
  17. # AC_FUNC_STRERROR_R
  18. # ------------------
  19. AC_DEFUN([AC_FUNC_STRERROR_R],
  20. [AC_CHECK_DECLS([strerror_r])
  21. AC_CHECK_FUNCS([strerror_r])
  22. AC_CACHE_CHECK([whether strerror_r returns char *],
  23. ac_cv_func_strerror_r_char_p,
  24. [
  25. ac_cv_func_strerror_r_char_p=no
  26. if test $ac_cv_have_decl_strerror_r = yes; then
  27. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  28. [[
  29. char buf[100];
  30. char x = *strerror_r (0, buf, sizeof buf);
  31. char *p = strerror_r (0, buf, sizeof buf);
  32. ]])],
  33. ac_cv_func_strerror_r_char_p=yes)
  34. else
  35. # strerror_r is not declared. Choose between
  36. # systems that have relatively inaccessible declarations for the
  37. # function. BeOS and DEC UNIX 4.0 fall in this category, but the
  38. # former has a strerror_r that returns char*, while the latter
  39. # has a strerror_r that returns `int'.
  40. # This test should segfault on the DEC system.
  41. AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
  42. extern char *strerror_r ();],
  43. [[char buf[100];
  44. char x = *strerror_r (0, buf, sizeof buf);
  45. exit (!isalpha (x));]])],
  46. ac_cv_func_strerror_r_char_p=yes, , :)
  47. fi
  48. ])
  49. if test $ac_cv_func_strerror_r_char_p = yes; then
  50. AC_DEFINE([STRERROR_R_CHAR_P], 1,
  51. [Define to 1 if strerror_r returns char *.])
  52. fi
  53. ])# AC_FUNC_STRERROR_R