]> git.saurik.com Git - bison.git/blame - m4/strerror_r.m4
* data/m4sugar/m4sugar.m4 (m4_map): Recognize when the list of
[bison.git] / m4 / strerror_r.m4
CommitLineData
4a0d8936 1#serial 1003
5141b016 2# Experimental replacement for the function in the latest CVS autoconf.
5141b016
AD
3# Use with the error.c file in ../lib.
4
4a0d8936
PE
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
5141b016
AD
21undefine([AC_FUNC_STRERROR_R])
22
23# AC_FUNC_STRERROR_R
24# ------------------
25AC_DEFUN([AC_FUNC_STRERROR_R],
26[AC_CHECK_DECLS([strerror_r])
27AC_CHECK_FUNCS([strerror_r])
4a0d8936
PE
28AC_CACHE_CHECK([whether strerror_r returns char *],
29 ac_cv_func_strerror_r_char_p,
5141b016 30 [
4a0d8936
PE
31 ac_cv_func_strerror_r_char_p=no
32 if test $ac_cv_have_decl_strerror_r = yes; then
33 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
34 [[
35 char buf[100];
36 char x = *strerror_r (0, buf, sizeof buf);
37 char *p = strerror_r (0, buf, sizeof buf);
38 ]])],
39 ac_cv_func_strerror_r_char_p=yes)
40 else
41 # strerror_r is not declared. Choose between
5141b016
AD
42 # systems that have relatively inaccessible declarations for the
43 # 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
45 # has a strerror_r that returns `int'.
46 # This test should segfault on the DEC system.
4a0d8936
PE
47 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
48 extern char *strerror_r ();],
49 [[char buf[100];
5141b016 50 char x = *strerror_r (0, buf, sizeof buf);
4a0d8936
PE
51 exit (!isalpha (x));]])],
52 ac_cv_func_strerror_r_char_p=yes, , :)
5141b016
AD
53 fi
54 ])
4a0d8936
PE
55if test $ac_cv_func_strerror_r_char_p = yes; then
56 AC_DEFINE([STRERROR_R_CHAR_P], 1,
57 [Define to 1 if strerror_r returns char *.])
5141b016
AD
58fi
59])# AC_FUNC_STRERROR_R