X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fstrerror_r.m4;h=6cf46240a7912f5386a488ed9ec1d0fbda10f770;hb=79f50aa7d1140a274d8e41f8c1bc2e9ac747a5ca;hp=410dfdfa2a65a6d3b7497303a4ac191cefe9262c;hpb=912ce237a653bd78c622c3193a1a6b00e552b446;p=gnulib.git diff --git a/m4/strerror_r.m4 b/m4/strerror_r.m4 index 410dfdfa2..6cf46240a 100644 --- a/m4/strerror_r.m4 +++ b/m4/strerror_r.m4 @@ -1,40 +1,66 @@ -#serial 2 +#serial 1002 +# 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. +# Use with the error.c file in ../lib. -dnl From Jim Meyering. -dnl Determine whether the strerror_r implementation is one of -dnl the broken ones that returns `int' rather than `char*'. -dnl Actually, this tests only whether it returns a scalar -dnl or an array, but that should be enough. -dnl On at least DEC UNIX 4.0[A-D] and HP-UX B.10.20, strerror_r -dnl returns `int'. This is used by lib/error.c. +undefine([AC_FUNC_STRERROR_R]) -AC_DEFUN(jm_FUNC_STRERROR_R, -[ - # Check strerror_r - AC_CHECK_FUNCS([strerror_r]) - if test $ac_cv_func_strerror_r = yes; then - AC_CHECK_HEADERS(string.h) - AC_CACHE_CHECK([for working strerror_r], - jm_cv_func_working_strerror_r, +# AC_FUNC_STRERROR_R +# ------------------ +AC_DEFUN([AC_FUNC_STRERROR_R], +[AC_CHECK_DECLS([strerror_r]) +AC_CHECK_FUNCS([strerror_r]) +if test $ac_cv_func_strerror_r = yes; then + AC_CHECK_HEADERS(string.h) + AC_CACHE_CHECK([for working strerror_r], + ac_cv_func_strerror_r_works, + [ + AC_TRY_COMPILE( [ - AC_TRY_COMPILE( - [ # include # if HAVE_STRING_H # include # endif - ], + ], + [ + char buf[100]; + char x = *strerror_r (0, buf, sizeof buf); + ], + 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 + # systems that have relatively inaccessible declarations for the + # function. BeOS and DEC UNIX 4.0 fall in this category, but the + # former has a strerror_r that returns char*, while the latter + # has a strerror_r that returns `int'. + # This test should segfault on the DEC system. + AC_TRY_RUN( [ - int buf; /* avoiding square brackets makes this easier */ - char x = *strerror_r (0, buf, sizeof buf); +# include +# include +# include + + extern char *strerror_r (); + + int + main () + { + char buf[100]; + char x = *strerror_r (0, buf, sizeof buf); + exit (!isalpha (x)); + } ], - jm_cv_func_working_strerror_r=yes, - jm_cv_func_working_strerror_r=no - ) - if test $jm_cv_func_working_strerror_r = yes; then - AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1, - [Define to 1 if strerror_r returns a string.]) - fi - ]) + ac_cv_func_strerror_r_works=yes, + ac_cv_func_strerror_r_works=no, + ac_cv_func_strerror_r_works=no) + fi + ]) + if test $ac_cv_func_strerror_r_works = yes; then + AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1, + [Define to 1 if `strerror_r' returns a string.]) fi -]) +fi +])# AC_FUNC_STRERROR_R