Skip to content

Commit 0b3b1bb

Browse files
authored
__wasi_thread_spawn: stop truncating the return value (#353)
as __wasi_errno_t is uint16_t, with the current coding, __pthread_create will never see negative return values from wasi:thread_spawn. eg. (int)(uint16_t)-1 == 65535.
1 parent 3a261b0 commit 0b3b1bb

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

libc-bottom-half/headers/public/wasi/api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,7 @@ __wasi_errno_t __wasi_sock_shutdown(
20992099
*
21002100
* @see https://github.com/WebAssembly/wasi-threads/#readme
21012101
*/
2102-
__wasi_errno_t __wasi_thread_spawn(
2102+
int32_t __wasi_thread_spawn(
21032103
/**
21042104
* A pointer to an opaque struct to be passed to the module's entry
21052105
* function.

libc-bottom-half/sources/__wasilibc_real.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,7 @@ int32_t __imported_wasi_thread_spawn(int32_t arg0) __attribute__((
665665
__import_name__("thread_spawn")
666666
));
667667

668-
__wasi_errno_t __wasi_thread_spawn(void* start_arg) {
669-
int32_t ret = __imported_wasi_thread_spawn((int32_t) start_arg);
670-
return (uint16_t) ret;
668+
int32_t __wasi_thread_spawn(void* start_arg) {
669+
return __imported_wasi_thread_spawn((int32_t) start_arg);
671670
}
672671
#endif

0 commit comments

Comments
 (0)