From 087db249a268b603a5fd7440157a349f049c62aa Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 15 Aug 2022 20:45:41 +0200 Subject: [PATCH] Fix uname() machine on wasm64 (#17589) Correct a typo in `__syscall_uname` code. wasm64 builds now correctly report `utsname->machine` as `"wasm64"`. --- system/lib/libc/emscripten_syscall_stubs.c | 2 +- test/core/test_uname.c | 8 ++++++++ test/core/test_uname.out | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/system/lib/libc/emscripten_syscall_stubs.c b/system/lib/libc/emscripten_syscall_stubs.c index 2a6d5d5267ec8..6152a8424db8c 100644 --- a/system/lib/libc/emscripten_syscall_stubs.c +++ b/system/lib/libc/emscripten_syscall_stubs.c @@ -60,7 +60,7 @@ int __syscall_uname(intptr_t buf) { strcpy(utsname->nodename, "emscripten"); strcpy(utsname->release, full_version); strcpy(utsname->version, "#1"); -#ifdef __wams64__ +#ifdef __wasm64__ strcpy(utsname->machine, "wasm64"); #else strcpy(utsname->machine, "wasm32"); diff --git a/test/core/test_uname.c b/test/core/test_uname.c index 4ca20f36eced9..2ae1bac65c843 100644 --- a/test/core/test_uname.c +++ b/test/core/test_uname.c @@ -5,7 +5,9 @@ * found in the LICENSE file. */ +#include #include +#include #include int main() { @@ -16,6 +18,12 @@ int main() { printf("release: %s\n", u.release); printf("version: %s\n", u.version); printf("machine: %s\n", u.machine); +#ifdef __wasm64__ + assert(strcmp(u.machine, "wasm64") == 0); +#else + assert(strcmp(u.machine, "wasm32") == 0); +#endif printf("invalid: %d\n", uname(0)); + return 0; } diff --git a/test/core/test_uname.out b/test/core/test_uname.out index 3806f84dbb5c3..a9ad77efd74aa 100644 --- a/test/core/test_uname.out +++ b/test/core/test_uname.out @@ -3,4 +3,4 @@ sysname: Emscripten nodename: emscripten release: \d+.\d+.\d+ version: #1 -machine: wasm32 +machine: wasm(32|64)