1#serial 1003
2# Experimental replacement for the function in the latest CVS autoconf.
3# Use with the error.c file in ../lib.
4
5dnl Copyright 2001 Free Software Foundation, Inc.
6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved.
9
10undefine([AC_FUNC_STRERROR_R])
11
12# AC_FUNC_STRERROR_R
13# ------------------
14AC_DEFUN([AC_FUNC_STRERROR_R],
15[AC_CHECK_DECLS([strerror_r])
16AC_CHECK_FUNCS([strerror_r])
17AC_CACHE_CHECK([whether strerror_r returns char *],
18               ac_cv_func_strerror_r_char_p,
19   [
20    ac_cv_func_strerror_r_char_p=no
21    if test $ac_cv_have_decl_strerror_r = yes; then
22      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
23	[[
24	  char buf[100];
25	  char x = *strerror_r (0, buf, sizeof buf);
26	  char *p = strerror_r (0, buf, sizeof buf);
27	]])],
28			ac_cv_func_strerror_r_char_p=yes)
29    else
30      # strerror_r is not declared.  Choose between
31      # systems that have relatively inaccessible declarations for the
32      # function.  BeOS and DEC UNIX 4.0 fall in this category, but the
33      # former has a strerror_r that returns char*, while the latter
34      # has a strerror_r that returns `int'.
35      # This test should segfault on the DEC system.
36      AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
37	extern char *strerror_r ();],
38	[[char buf[100];
39	  char x = *strerror_r (0, buf, sizeof buf);
40	  exit (!isalpha (x));]])],
41                    ac_cv_func_strerror_r_char_p=yes, , :)
42    fi
43  ])
44if test $ac_cv_func_strerror_r_char_p = yes; then
45  AC_DEFINE([STRERROR_R_CHAR_P], 1,
46	    [Define to 1 if strerror_r returns char *.])
47fi
48])# AC_FUNC_STRERROR_R
49