void-packages/srcpkgs/simgear/patches/musl-strerror_r.patch
2016-06-18 16:42:13 +02:00

25 lines
985 B
Diff

--- simgear/misc/strutils.cxx 2016-05-17 10:36:36.000000000 +0200
+++ simgear/misc/strutils.cxx 2016-06-18 14:47:46.858731232 +0200
@@ -613,8 +613,12 @@
errno_t retcode;
// Always makes the string in 'buf' null-terminated
retcode = strerror_s(buf, sizeof(buf), errnum);
-#elif defined(_GNU_SOURCE)
+#elif defined(_GNU_SOURCE) && defined(__GLIBC__)
return std::string(strerror_r(errnum, buf, sizeof(buf)));
+#elif defined(_GNU_SOURCE)
+ int retcode;
+ // musl libc is posix compliant
+ retcode = strerror_r(errnum, buf, sizeof(buf));
#elif (_POSIX_C_SOURCE >= 200112L) || defined(SG_MAC)
int retcode;
// POSIX.1-2001 and POSIX.1-2008
@@ -623,7 +627,7 @@
#error "Could not find a thread-safe alternative to strerror()."
#endif
-#if !defined(_GNU_SOURCE)
+#if !defined(_GNU_SOURCE) || !defined(__GLIBC__)
if (retcode) {
std::string msg = "unable to get error message for a given error number";
// C++11 would make this shorter with std::to_string()