File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
core/iwasm/libraries/lib-socket/src/wasi Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1212#include <wasi/api.h>
1313#include <wasi_socket_ext.h>
1414
15+ /*
16+ * Avoid direct TLS access to allow a single library to be
17+ * linked to both of threaded and non-threaded applications.
18+ *
19+ * wasi-libc's errno is a TLS variable, exposed directly via
20+ * errno.h. if we use it here, LLVM may lower it differently,
21+ * depending on enabled features like atomcs and bulk-memory.
22+ * we tweak the way to access errno here in order to make us
23+ * compatible with both of threaded and non-threaded applications.
24+ * __errno_location() should be reasonably stable because
25+ * it was introduced as an alternative ABI for non-C software.
26+ * https://github.com/WebAssembly/wasi-libc/pull/347
27+ */
28+ #if defined(errno )
29+ #undef errno
30+ #endif
31+ int *
32+ __errno_location (void );
33+ #define errno (*__errno_location())
34+
1535#define HANDLE_ERROR (error ) \
1636 if (error != __WASI_ERRNO_SUCCESS) { \
1737 errno = error; \
You can’t perform that action at this time.
0 commit comments