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