Skip to content

Commit

Permalink
Bring back __xpg_strerror_r
Browse files Browse the repository at this point in the history
  • Loading branch information
sionescu committed Nov 2, 2011
1 parent 07437f2 commit 5328641
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -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])
Expand Down
12 changes: 7 additions & 5 deletions src/lib/strerror.c
Expand Up @@ -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.