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 12
12
#include <wasi/api.h>
13
13
#include <wasi_socket_ext.h>
14
14
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
+
15
35
#define HANDLE_ERROR (error ) \
16
36
if (error != __WASI_ERRNO_SUCCESS) { \
17
37
errno = error; \
You can’t perform that action at this time.
0 commit comments