Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bring back __xpg_strerror_r

  • Loading branch information...
commit 53286415d93f1568791f3a0c45005efc838ab191 1 parent 07437f2
@sionescu sionescu authored
Showing with 8 additions and 6 deletions.
  1. +1 −1  configure.ac
  2. +7 −5 src/lib/strerror.c
View
2  configure.ac
@@ -78,7 +78,7 @@ dnl Checks for non-standard headers
AC_CHECK_HEADER([sys/signalfd.h])
dnl Checks for functions
-AC_CHECK_FUNCS([strnlen strndup clearenv])
+AC_CHECK_FUNCS([__xpg_strerror_r strnlen strndup clearenv])
LFP_REQUIRE_FUNCS([strtok_r])
LFP_SEARCH_LIBS([socket], [socket nsl])
AC_CHECK_FUNCS([accept4 pipe2 sendfile])
View
12 src/lib/strerror.c
@@ -22,20 +22,22 @@
/* DEALINGS IN THE SOFTWARE. */
/*******************************************************************************/
-#include <config.h>
-
-// _GNU_SOURCE exposes a non-POSIX version of strerror_r
-// that's why we put it into its own file
-#undef _GNU_SOURCE
#include <lfp/strerror.h>
#include <string.h>
#include "utils.h"
+#if defined(HAVE___XPG_STRERROR_R)
+int __xpg_strerror_r (int errnum, char *buf, size_t buflen);
+#endif
int lfp_strerror(int errnum, char *buf, size_t buflen)
{
SYSCHECK(EINVAL, buf == NULL);
+#if defined(HAVE___XPG_STRERROR_R)
+ return __xpg_strerror_r(errnum, buf, buflen);
+#else
return strerror_r(errnum, buf, buflen);
+#endif // HAVE___XPG_STRERROR_R
}
Please sign in to comment.
Something went wrong with that request. Please try again.