void-packages/srcpkgs/simgear/patches/musl-strerror_r.patch

26 lines
967 B
Diff

--- simgear/misc/strutils.cxx 2020-06-26 00:07:33.000000000 +0200
+++ simgear/misc/strutils.cxx 2020-08-22 19:50:07.043076612 +0200
@@ -1137,7 +1137,13 @@
// Always makes the string in 'buf' null-terminated
retcode = strerror_s(buf, sizeof(buf), errnum);
#elif defined(_GNU_SOURCE)
+#if defined(__GLIBC__)
return std::string(strerror_r(errnum, buf, sizeof(buf)));
+#else
+ int retcode;
+ // Musl libc support
+ retcode = strerror_r(errnum, buf, sizeof(buf));
+#endif
#elif (_POSIX_C_SOURCE >= 200112L) || defined(SG_MAC) || defined(__FreeBSD__) || defined(__OpenBSD__)
int retcode;
// POSIX.1-2001 and POSIX.1-2008
@@ -1146,7 +1152,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()