From 3bc888d2335fd1b42102b034d17e73ab96b6b4eb Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 8 Jun 2011 12:27:31 +0200 Subject: [PATCH] strerror_r-posix: Tweaks. * m4/strerror.m4 (gl_FUNC_STRERROR): Omit the code that tests gl_cv_func_strerror_r_works if gl_FUNC_STRERROR_R_WORKS is not present. * m4/strerror_r.m4 (gl_FUNC_STRERROR_R_WORKS): Fix AC_CACHE_CHECK message. Move gl_HEADER_STRING_H_DEFAULTS invocation from here... (gl_FUNC_STRERROR_R): ... to here. (gl_PREREQ_STRERROR_R): Test for __xpg_strerror_r. --- ChangeLog | 10 ++++++++++ m4/strerror.m4 | 11 +++++++---- m4/strerror_r.m4 | 17 +++++++++-------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index e899a6b1a2..d57fd3fd67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-06-08 Bruno Haible + + strerror_r-posix: Tweaks. + * m4/strerror.m4 (gl_FUNC_STRERROR): Omit the code that tests + gl_cv_func_strerror_r_works if gl_FUNC_STRERROR_R_WORKS is not present. + * m4/strerror_r.m4 (gl_FUNC_STRERROR_R_WORKS): Fix AC_CACHE_CHECK + message. Move gl_HEADER_STRING_H_DEFAULTS invocation from here... + (gl_FUNC_STRERROR_R): ... to here. + (gl_PREREQ_STRERROR_R): Test for __xpg_strerror_r. + 2011-06-07 Eric Blake perror: document fixed bugs diff --git a/m4/strerror.m4 b/m4/strerror.m4 index de4ba9674b..1ae1a2d12d 100644 --- a/m4/strerror.m4 +++ b/m4/strerror.m4 @@ -35,10 +35,13 @@ AC_DEFUN([gl_FUNC_STRERROR], dnl integers. Replace it. REPLACE_STRERROR=1 fi - dnl If the system's strerror_r clobbers strerror, we must replace strerror. - case $gl_cv_func_strerror_r_works in - *no) REPLACE_STRERROR=1 ;; - esac + m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [ + dnl If the system's strerror_r or __xpg_strerror_r clobbers strerror's + dnl buffer, we must replace strerror. + case "$gl_cv_func_strerror_r_works" in + *no) REPLACE_STRERROR=1 ;; + esac + ]) else dnl The system's strerror() cannot know about the new errno values we add dnl to . Replace it. diff --git a/m4/strerror_r.m4 b/m4/strerror_r.m4 index c1d1a8eb05..68a0b69112 100644 --- a/m4/strerror_r.m4 +++ b/m4/strerror_r.m4 @@ -6,6 +6,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_STRERROR_R], [ + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS]) dnl Persuade Solaris to declare strerror_r(). @@ -26,7 +27,7 @@ AC_DEFUN([gl_FUNC_STRERROR_R], *no) REPLACE_STRERROR_R=1 ;; esac else - dnl The system's strerror() has a wrong signature. Replace it. + dnl The system's strerror_r() has a wrong signature. Replace it. REPLACE_STRERROR_R=1 fi else @@ -39,15 +40,15 @@ AC_DEFUN([gl_FUNC_STRERROR_R], # Prerequisites of lib/strerror_r.c. AC_DEFUN([gl_PREREQ_STRERROR_R], [ + dnl glibc >= 2.3.4 and cygwin 1.7.9 have a function __xpg_strerror_r. + AC_CHECK_FUNCS([__xpg_strerror_r]) AC_CHECK_FUNCS_ONCE([catgets]) - : ]) # Detect if strerror_r works, but without affecting whether a replacement # strerror_r will be used. AC_DEFUN([gl_FUNC_STRERROR_R_WORKS], [ - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) AC_REQUIRE([gl_HEADER_ERRNO_H]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles @@ -120,10 +121,10 @@ changequote([,])dnl dnl The system's strerror() has a wrong signature. dnl glibc >= 2.3.4 and cygwin 1.7.9 have a function __xpg_strerror_r. AC_CHECK_FUNCS([__xpg_strerror_r]) - dnl glibc < 2.14 does not populate buf on failure - dnl cygwin < 1.7.10 clobbers strerror + dnl In glibc < 2.14, __xpg_strerror_r does not populate buf on failure. + dnl In cygwin < 1.7.10, __xpg_strerror_r clobbers strerror's buffer. if test $ac_cv_func___xpg_strerror_r = yes; then - AC_CACHE_CHECK([whether strerror_r works], + AC_CACHE_CHECK([whether __xpg_strerror_r works], [gl_cv_func_strerror_r_works], [AC_RUN_IFELSE( [AC_LANG_PROGRAM( @@ -147,8 +148,8 @@ changequote([,])dnl ]])], [gl_cv_func_strerror_r_works=yes], [gl_cv_func_strerror_r_works=no], - [dnl guess no on all platforms that have __xpg_strerror_r, - dnl at least until fixed glibc and cygwin are more common + [dnl Guess no on all platforms that have __xpg_strerror_r, + dnl at least until fixed glibc and cygwin are more common. gl_cv_func_strerror_r_works="guessing no" ]) ]) -- 2.30.2