void-packages/srcpkgs/simgear/patches/musl-strerror_r.patch
2016-11-25 06:30:20 +01:00

25 lines
1,009 B
Diff

--- simgear/misc/strutils.cxx 2016-11-22 10:06:52.000000000 +0100
+++ simgear/misc/strutils.cxx 2016-11-25 05:16:59.264676966 +0100
@@ -648,8 +648,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) || defined(__FreeBSD__)
int retcode;
// POSIX.1-2001 and POSIX.1-2008
@@ -658,7 +662,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()