moved errno_to_string() to the tools

This commit is contained in:
Devaev Maxim
2021-04-01 08:49:18 +03:00
parent 00e83c155e
commit 71f1d397bf
2 changed files with 10 additions and 10 deletions

View File

@@ -160,13 +160,3 @@ extern pthread_mutex_t log_mutex;
LOG_PRINTF(COLOR_GRAY, "DEBUG", COLOR_GRAY, _msg, ##__VA_ARGS__); \
} \
}
INLINE char *errno_to_string(int error, char *buf, size_t size) {
# if defined(__GLIBC__) && defined(_GNU_SOURCE)
return strerror_r(error, buf, size);
# else
strerror_r(error, buf, size);
return buf;
# endif
}

View File

@@ -26,6 +26,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <math.h>
@@ -143,3 +144,12 @@ INLINE int flock_timedwait_monotonic(int fd, long double timeout) {
}
return retval;
}
INLINE char *errno_to_string(int error, char *buf, size_t size) {
# if defined(__GLIBC__) && defined(_GNU_SOURCE)
return strerror_r(error, buf, size);
# else
strerror_r(error, buf, size);
return buf;
# endif
}