From 0087d4c6bf13a1bac648b0e61459d717bae87b02 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 18 Nov 2024 11:49:30 +0100 Subject: syscall: use wasi-libc tables for wasm/js target Instead of using fake tables for errno and others, use the ones that correspond to wasi-libc. --- src/syscall/errno_other.go | 2 +- src/syscall/errno_wasilibc.go | 8 ++++++++ src/syscall/errno_wasip1.go | 8 -------- src/syscall/syscall_libc.go | 2 +- src/syscall/syscall_libc_wasi.go | 4 +++- src/syscall/syscall_nonhosted.go | 2 +- src/syscall/tables_nonhosted.go | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 src/syscall/errno_wasilibc.go delete mode 100644 src/syscall/errno_wasip1.go (limited to 'src') diff --git a/src/syscall/errno_other.go b/src/syscall/errno_other.go index 3a06ac018..8c58f5f01 100644 --- a/src/syscall/errno_other.go +++ b/src/syscall/errno_other.go @@ -1,4 +1,4 @@ -//go:build !wasip1 && !wasip2 +//go:build !js && !wasip1 && !wasip2 package syscall diff --git a/src/syscall/errno_wasilibc.go b/src/syscall/errno_wasilibc.go new file mode 100644 index 000000000..efb97260f --- /dev/null +++ b/src/syscall/errno_wasilibc.go @@ -0,0 +1,8 @@ +//go:build wasip1 || js + +package syscall + +// Use a go:extern definition to access the errno from wasi-libc +// +//go:extern errno +var libcErrno Errno diff --git a/src/syscall/errno_wasip1.go b/src/syscall/errno_wasip1.go deleted file mode 100644 index c494d7da0..000000000 --- a/src/syscall/errno_wasip1.go +++ /dev/null @@ -1,8 +0,0 @@ -//go:build wasip1 - -package syscall - -// Use a go:extern definition to access the errno from wasi-libc -// -//go:extern errno -var libcErrno Errno diff --git a/src/syscall/syscall_libc.go b/src/syscall/syscall_libc.go index d8293efde..0ef978428 100644 --- a/src/syscall/syscall_libc.go +++ b/src/syscall/syscall_libc.go @@ -1,4 +1,4 @@ -//go:build nintendoswitch || wasip1 || wasip2 +//go:build js || nintendoswitch || wasip1 || wasip2 package syscall diff --git a/src/syscall/syscall_libc_wasi.go b/src/syscall/syscall_libc_wasi.go index 06169bb2b..bbf81cd05 100644 --- a/src/syscall/syscall_libc_wasi.go +++ b/src/syscall/syscall_libc_wasi.go @@ -1,4 +1,6 @@ -//go:build wasip1 || wasip2 +//go:build js || wasip1 || wasip2 + +// Note: also including js in here because it also uses wasi-libc. package syscall diff --git a/src/syscall/syscall_nonhosted.go b/src/syscall/syscall_nonhosted.go index 4867d70f6..a0965692f 100644 --- a/src/syscall/syscall_nonhosted.go +++ b/src/syscall/syscall_nonhosted.go @@ -1,4 +1,4 @@ -//go:build baremetal || js || wasm_unknown +//go:build baremetal || wasm_unknown package syscall diff --git a/src/syscall/tables_nonhosted.go b/src/syscall/tables_nonhosted.go index e66620cbf..a45834827 100644 --- a/src/syscall/tables_nonhosted.go +++ b/src/syscall/tables_nonhosted.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build baremetal || nintendoswitch || js || wasm_unknown +//go:build baremetal || nintendoswitch || wasm_unknown package syscall -- cgit v1.2.3