]> git.proxmox.com Git - wasi-libc.git/commitdiff
__wasi_thread_spawn: stop truncating the return value (#353)
authorYAMAMOTO Takashi <yamamoto@midokura.com>
Wed, 7 Dec 2022 17:18:28 +0000 (02:18 +0900)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 2 Aug 2023 10:24:08 +0000 (12:24 +0200)
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.

libc-bottom-half/headers/public/wasi/api.h
libc-bottom-half/sources/__wasilibc_real.c

index 1ab76994ed177989ac7618d3c91178faac62d6a1..45a6506e2ffa022e081bea9aa8e14cf8b7c4da5a 100644 (file)
@@ -2099,7 +2099,7 @@ __wasi_errno_t __wasi_sock_shutdown(
  *
  * @see https://github.com/WebAssembly/wasi-threads/#readme
  */
-__wasi_errno_t __wasi_thread_spawn(
+int32_t __wasi_thread_spawn(
     /**
      * A pointer to an opaque struct to be passed to the module's entry
      * function.
index 855a2c6ddd2d878ea49fa8fc0ba057ea963bbdb5..d2e6b71c6467f8acd33e754ae780479758b81e47 100644 (file)
@@ -665,8 +665,7 @@ int32_t __imported_wasi_thread_spawn(int32_t arg0) __attribute__((
     __import_name__("thread_spawn")
 ));
 
-__wasi_errno_t __wasi_thread_spawn(void* start_arg) {
-       int32_t ret = __imported_wasi_thread_spawn((int32_t) start_arg);
-    return (uint16_t) ret;
+int32_t __wasi_thread_spawn(void* start_arg) {
+    return __imported_wasi_thread_spawn((int32_t) start_arg);
 }
 #endif