Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ endif
endif
endif

CFLAGS += -D_BUILDING_WASI_LIBC
ifeq ($(WASI_SNAPSHOT), p2)
CFLAGS += -D__wasilibc_use_wasip2
endif
Expand Down Expand Up @@ -971,7 +972,7 @@ check-symbols: $(STARTUP_FILES) libc
@# TODO: Undefine __wasm_nontrapping_fptoint__, __wasm_bulk_memory__ and
@# __wasm_bulk_memory_opt__, that are new to clang 20.
@# TODO: As of clang 16, __GNUC_VA_LIST is #defined without a value.
$(CC) $(CFLAGS) "$(SYSROOT_SHARE)/include-all.c" \
$(CC) $(CFLAGS) -U_BUILDING_WASI_LIBC "$(SYSROOT_SHARE)/include-all.c" \
-isystem $(SYSROOT_INC) \
-std=gnu17 \
-E -dM -Wno-\#warnings \
Expand Down
2 changes: 1 addition & 1 deletion expected/wasm32-wasip1-threads/predefined-macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3255,7 +3255,7 @@
#define dirent64 dirent
#define erf(x) __tg_real(erf, (x))
#define erfc(x) __tg_real(erfc, (x))
#define errno errno
#define errno (*__errno_location())
#define exp(x) __tg_real_complex(exp, (x))
#define exp2(x) __tg_real(exp2, (x))
#define expm1(x) __tg_real(expm1, (x))
Expand Down
2 changes: 1 addition & 1 deletion expected/wasm32-wasip1/predefined-macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3250,7 +3250,7 @@
#define dirent64 dirent
#define erf(x) __tg_real(erf, (x))
#define erfc(x) __tg_real(erfc, (x))
#define errno errno
#define errno (*__errno_location())
#define exp(x) __tg_real_complex(exp, (x))
#define exp2(x) __tg_real(exp2, (x))
#define expm1(x) __tg_real(expm1, (x))
Expand Down
2 changes: 1 addition & 1 deletion expected/wasm32-wasip2/predefined-macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3403,7 +3403,7 @@
#define dirent64 dirent
#define erf(x) __tg_real(erf, (x))
#define erfc(x) __tg_real(erfc, (x))
#define errno errno
#define errno (*__errno_location())
#define exp(x) __tg_real_complex(exp, (x))
#define exp2(x) __tg_real(exp2, (x))
#define expm1(x) __tg_real(expm1, (x))
Expand Down
8 changes: 7 additions & 1 deletion libc-bottom-half/headers/public/__errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
extern "C" {
#endif

#ifdef _BUILDING_WASI_LIBC
/* libc internal access */
extern _Thread_local int errno;

#define errno errno
#else
/* user exposed ABI */
__attribute__((__const__)) int *__errno_location(void);
#define errno (*__errno_location())
#endif

#ifdef __cplusplus
}
Expand Down
Loading