1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-24 07:20:27 +00:00

Fix janet_strerror when _GNU_SOURCE defined.

This commit is contained in:
Calvin Rose 2024-05-25 13:24:01 -05:00
parent 60e0c8ea92
commit ae2c5820a1

View File

@ -958,6 +958,9 @@ const char *janet_strerror(int e) {
#ifdef JANET_WINDOWS #ifdef JANET_WINDOWS
/* Microsoft strerror seems sane here and is thread safe by default */ /* Microsoft strerror seems sane here and is thread safe by default */
return strerror(e); 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 #else
strerror_r(e, janet_vm.strerror_buf, sizeof(janet_vm.strerror_buf)); strerror_r(e, janet_vm.strerror_buf, sizeof(janet_vm.strerror_buf));
return janet_vm.strerror_buf; return janet_vm.strerror_buf;