Skip to content

Commit 72599b8

Browse files
authored
Fix version reported by uname (#17026)
Fixes: #16977
1 parent 02ef167 commit 72599b8

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

system/lib/libc/emscripten_syscall_stubs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <time.h>
2323
#include <sys/utsname.h>
2424
#include <emscripten/console.h>
25+
#include <emscripten/version.h>
2526

2627
static int g_pid = 42;
2728
static int g_pgid = 42;
@@ -42,15 +43,22 @@ static mode_t g_umask = S_IRWXU | S_IRWXG | S_IRWXO;
4243
return -ENOSYS; \
4344
}
4445

46+
#define STRINGIFY(s) #s
47+
#define STR(s) STRINGIFY(s)
48+
4549
int __syscall_uname(intptr_t buf) {
4650
if (!buf) {
4751
return -EFAULT;
4852
}
53+
const char* full_version = STR(__EMSCRIPTEN_major__) "." \
54+
STR(__EMSCRIPTEN_minor__) "." \
55+
STR(__EMSCRIPTEN_tiny__);
56+
4957
struct utsname *utsname = (struct utsname *)buf;
5058

5159
strcpy(utsname->sysname, "Emscripten");
5260
strcpy(utsname->nodename, "emscripten");
53-
strcpy(utsname->release, "1.0");
61+
strcpy(utsname->release, full_version);
5462
strcpy(utsname->version, "#1");
5563
#ifdef __wams64__
5664
strcpy(utsname->machine, "wasm64");

tests/core/test_uname.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ret: 0
22
sysname: Emscripten
33
nodename: emscripten
4-
release: 1.0
4+
release: \d+.\d+.\d+
55
version: #1
66
machine: wasm32

tests/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6062,7 +6062,7 @@ def test_posixtime(self):
60626062
self.do_core_test('test_posixtime.c')
60636063

60646064
def test_uname(self):
6065-
self.do_core_test('test_uname.c')
6065+
self.do_core_test('test_uname.c', regex=True)
60666066

60676067
def test_unary_literal(self):
60686068
self.do_core_test('test_unary_literal.cpp')

0 commit comments

Comments
 (0)