Skip to content

Commit

Permalink
Define an __errno_location function. (#347)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sunfishcode authored Nov 28, 2022
1 parent a00bf32 commit 2bb5abe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions expected/wasm32-wasi/posix/defined-symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ __do_des
__do_orphaned_stdio_locks
__duplocale
__env_rm_add
__errno_location
__exp2f_data
__exp_data
__expo2
Expand Down
1 change: 1 addition & 0 deletions expected/wasm32-wasi/single/defined-symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ __des_setkey
__do_des
__duplocale
__env_rm_add
__errno_location
__exp2f_data
__exp_data
__expo2
Expand Down
5 changes: 5 additions & 0 deletions libc-bottom-half/sources/__errno_location.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <errno.h>

int *__errno_location(void) {
return &errno;
}

0 comments on commit 2bb5abe

Please sign in to comment.