From 2bb5abedbdeed964adb81d2a0284db872e25a329 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 28 Nov 2022 13:50:04 -0800 Subject: [PATCH] Define an `__errno_location` function. (#347) This function returns the address of `errno`, which makes it easier to access from non-C languages since `errno` is a thread-local variable which requires a special ABI. --- expected/wasm32-wasi/posix/defined-symbols.txt | 1 + expected/wasm32-wasi/single/defined-symbols.txt | 1 + libc-bottom-half/sources/__errno_location.c | 5 +++++ 3 files changed, 7 insertions(+) create mode 100644 libc-bottom-half/sources/__errno_location.c diff --git a/expected/wasm32-wasi/posix/defined-symbols.txt b/expected/wasm32-wasi/posix/defined-symbols.txt index d92bcbd88..645e44c64 100644 --- a/expected/wasm32-wasi/posix/defined-symbols.txt +++ b/expected/wasm32-wasi/posix/defined-symbols.txt @@ -48,6 +48,7 @@ __do_des __do_orphaned_stdio_locks __duplocale __env_rm_add +__errno_location __exp2f_data __exp_data __expo2 diff --git a/expected/wasm32-wasi/single/defined-symbols.txt b/expected/wasm32-wasi/single/defined-symbols.txt index f8f445707..2e890a049 100644 --- a/expected/wasm32-wasi/single/defined-symbols.txt +++ b/expected/wasm32-wasi/single/defined-symbols.txt @@ -38,6 +38,7 @@ __des_setkey __do_des __duplocale __env_rm_add +__errno_location __exp2f_data __exp_data __expo2 diff --git a/libc-bottom-half/sources/__errno_location.c b/libc-bottom-half/sources/__errno_location.c new file mode 100644 index 000000000..5e6ef5e6b --- /dev/null +++ b/libc-bottom-half/sources/__errno_location.c @@ -0,0 +1,5 @@ +#include + +int *__errno_location(void) { + return &errno; +}