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