From 81e43a6335f41f9d555080326a90569b719b7c02 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 16 Sep 2020 22:55:50 +0100 Subject: [PATCH] ITS#9348 cleanup strerr/sys_errlist detection --- build/openldap.m4 | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/build/openldap.m4 b/build/openldap.m4 index 2419683b3d..c34da15899 100644 --- a/build/openldap.m4 +++ b/build/openldap.m4 @@ -530,29 +530,32 @@ dnl Check for declaration of sys_errlist in one of stdio.h and errno.h. dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration. dnl Reported by Keith Bostic. AC_DEFUN([OL_SYS_ERRLIST], -[AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +[AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_have_sys_errlist=yes],[ol_cv_have_sys_errlist=no])]) +if test $ol_cv_have_sys_errlist = yes ; then + AC_DEFINE(HAVE_SYS_ERRLIST,1, + [define if you actually have sys_errlist in your libs]) + AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include #include #ifdef _WIN32 #include -#endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes - ol_cv_have_sys_errlist=yes],[ol_cv_dcl_sys_errlist=no])]) +#endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes], + [ol_cv_dcl_sys_errlist=no])]) # -# It's possible (for near-UNIX clones) that sys_errlist doesn't exist -if test $ol_cv_dcl_sys_errlist = no ; then - AC_DEFINE(DECL_SYS_ERRLIST,1, - [define if sys_errlist is not declared in stdio.h or errno.h]) - - AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[ - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_have_sys_errlist=yes],[ol_cv_have_sys_errlist=no])]) -fi -if test $ol_cv_have_sys_errlist = yes ; then - AC_DEFINE(HAVE_SYS_ERRLIST,1, - [define if you actually have sys_errlist in your libs]) + # It's possible (for near-UNIX clones) that sys_errlist doesn't exist + if test $ol_cv_dcl_sys_errlist = no ; then + AC_DEFINE(DECL_SYS_ERRLIST,1, + [define if sys_errlist is not declared in stdio.h or errno.h]) + fi fi ])dnl +dnl +dnl ==================================================================== +dnl glibc supplies a non-standard strerror_r if _GNU_SOURCE is defined. +dnl It's actually preferable to the POSIX version, if available. AC_DEFUN([OL_NONPOSIX_STRERROR_R], [AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[ AC_EGREP_CPP(strerror_r,[#include ], @@ -572,7 +575,7 @@ AC_DEFUN([OL_NONPOSIX_STRERROR_R], strerror_r( 1, buf, sizeof buf ); exit( buf[0] == 0 ); } - ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror=no],[ol_cv_nonposix_strerror=no]) + ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no],[ol_cv_nonposix_strerror_r=no]) fi ]) if test $ol_cv_nonposix_strerror_r = yes ; then @@ -582,8 +585,7 @@ fi ])dnl dnl AC_DEFUN([OL_STRERROR], -[OL_SYS_ERRLIST dnl TEMPORARY -AC_CHECK_FUNCS(strerror strerror_r) +[AC_CHECK_FUNCS(strerror strerror_r) ol_cv_func_strerror_r=no if test "${ac_cv_func_strerror_r}" = yes ; then OL_NONPOSIX_STRERROR_R