From ae2c5820a1515b7f52ee570b206d1559654aec5d Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 25 May 2024 13:24:01 -0500 Subject: [PATCH] Fix janet_strerror when _GNU_SOURCE defined. --- src/core/util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/util.c b/src/core/util.c index 9d7aab3a..09cf36f2 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -958,6 +958,9 @@ const char *janet_strerror(int e) { #ifdef JANET_WINDOWS /* Microsoft strerror seems sane here and is thread safe by default */ return strerror(e); +#elif defined(_GNU_SOURCE) + /* See https://linux.die.net/man/3/strerror_r */ + return strerror_r(e, janet_vm.strerror_buf, sizeof(janet_vm.strerror_buf)); #else strerror_r(e, janet_vm.strerror_buf, sizeof(janet_vm.strerror_buf)); return janet_vm.strerror_buf;