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

26 lines
971 B
Diff

--- a/simgear/misc/strutils.cxx 2020-06-26 00:07:33.000000000 +0200
+++ b/simgear/misc/strutils.cxx 2020-08-22 19:50:07.043076612 +0200
@@ -1169,7 +1175,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
@@ -1178,7 +1184,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()