]> git.proxmox.com Git - wasi-libc.git/commitdiff
Define an `__errno_location` function. (#347)
authorDan Gohman <dev@sunfishcode.online>
Mon, 28 Nov 2022 21:50:04 +0000 (13:50 -0800)
committerGitHub <noreply@github.com>
Mon, 28 Nov 2022 21:50:04 +0000 (13:50 -0800)
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
expected/wasm32-wasi/single/defined-symbols.txt
libc-bottom-half/sources/__errno_location.c [new file with mode: 0644]

index d92bcbd88a8c6edf75777e20ade1864591237765..645e44c64190c39f9259ed81394681f4ea1c8309 100644 (file)
@@ -48,6 +48,7 @@ __do_des
 __do_orphaned_stdio_locks
 __duplocale
 __env_rm_add
+__errno_location
 __exp2f_data
 __exp_data
 __expo2
index f8f4457076edfcbc1ae352f5224cd38045a8fa63..2e890a049b843fab22c0fe944366060ec75f0125 100644 (file)
@@ -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 (file)
index 0000000..5e6ef5e
--- /dev/null
@@ -0,0 +1,5 @@
+#include <errno.h>
+
+int *__errno_location(void) {
+    return &errno;
+}