Permalink
Browse files

Bring back __xpg_strerror_r

  • Loading branch information...
sionescu committed Nov 2, 2011
1 parent 07437f2 commit 53286415d93f1568791f3a0c45005efc838ab191
Showing with 8 additions and 6 deletions.
  1. +1 −1 configure.ac
  2. +7 −5 src/lib/strerror.c
View
@@ -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
@@ -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
}

0 comments on commit 5328641

Please sign in to comment.