utils: Move thread-safe strerror replacement to a separate file

For some utils _GNU_SOURCE might be needed but that conflicts with the
signature of strerror_r(3).
This commit is contained in:
Tobias Brunner
2014-02-24 12:04:10 +01:00
parent aa693d763a
commit ba10cd3c7f
7 changed files with 145 additions and 99 deletions
+1 -17
View File
@@ -30,6 +30,7 @@
#include <string.h>
#include "enum.h"
#include "utils/strerror.h"
/**
* strongSwan program return codes
@@ -494,23 +495,6 @@ char *strreplace(const char *str, const char *search, const char *replace);
*/
bool mkdir_p(const char *path, mode_t mode);
/**
* Thread-safe wrapper around strerror and strerror_r.
*
* This is required because the first is not thread-safe (on some platforms)
* and the second uses two different signatures (POSIX/GNU) and is impractical
* to use anyway.
*
* @param errnum error code (i.e. errno)
* @return error message
*/
const char *safe_strerror(int errnum);
/**
* Replace usages of strerror(3) with thread-safe variant.
*/
#define strerror(errnum) safe_strerror(errnum)
#ifndef HAVE_CLOSEFROM
/**
* Close open file descriptors greater than or equal to lowfd.