From ce984d44a0620096294bfe77f1613f270556914b Mon Sep 17 00:00:00 2001 From: visualfc Date: Wed, 11 Jun 2025 09:10:46 +0800 Subject: [PATCH] libffi: support wasm32 --- runtime/internal/clite/ffi/abi.go | 2 +- runtime/internal/clite/ffi/abi_wasm.go | 5 +++ .../clite/ffi/{ffi_other.go => ffi_link.go} | 2 -- runtime/internal/clite/ffi/ffi_wasm.go | 31 ------------------- 4 files changed, 6 insertions(+), 34 deletions(-) create mode 100644 runtime/internal/clite/ffi/abi_wasm.go rename runtime/internal/clite/ffi/{ffi_other.go => ffi_link.go} (98%) delete mode 100644 runtime/internal/clite/ffi/ffi_wasm.go diff --git a/runtime/internal/clite/ffi/abi.go b/runtime/internal/clite/ffi/abi.go index a20bfa9f..27cd488b 100644 --- a/runtime/internal/clite/ffi/abi.go +++ b/runtime/internal/clite/ffi/abi.go @@ -1,4 +1,4 @@ -//go:build !amd64 +//go:build !amd64 && !wasm package ffi diff --git a/runtime/internal/clite/ffi/abi_wasm.go b/runtime/internal/clite/ffi/abi_wasm.go new file mode 100644 index 00000000..c9656557 --- /dev/null +++ b/runtime/internal/clite/ffi/abi_wasm.go @@ -0,0 +1,5 @@ +package ffi + +const ( + DefaultAbi = 2 +) diff --git a/runtime/internal/clite/ffi/ffi_other.go b/runtime/internal/clite/ffi/ffi_link.go similarity index 98% rename from runtime/internal/clite/ffi/ffi_other.go rename to runtime/internal/clite/ffi/ffi_link.go index 6953dfdc..518213b8 100644 --- a/runtime/internal/clite/ffi/ffi_other.go +++ b/runtime/internal/clite/ffi/ffi_link.go @@ -1,5 +1,3 @@ -//go:build !wasm - package ffi import ( diff --git a/runtime/internal/clite/ffi/ffi_wasm.go b/runtime/internal/clite/ffi/ffi_wasm.go deleted file mode 100644 index 70531d98..00000000 --- a/runtime/internal/clite/ffi/ffi_wasm.go +++ /dev/null @@ -1,31 +0,0 @@ -package ffi - -import ( - "unsafe" - - c "github.com/goplus/llgo/runtime/internal/clite" -) - -func PrepCif(cif *Cif, abi c.Uint, nargs c.Uint, rtype *Type, atype **Type) c.Uint { - panic("not implemented") -} - -func PrepCifVar(cif *Cif, abi c.Uint, nfixedargs c.Uint, ntotalargs c.Uint, rtype *Type, atype **Type) c.Uint { - panic("not implemented") -} - -func Call(cif *Cif, fn unsafe.Pointer, rvalue unsafe.Pointer, avalue *unsafe.Pointer) { - panic("not implemented") -} - -func ClosureAlloc(code *unsafe.Pointer) unsafe.Pointer { - panic("not implemented") -} - -func ClosureFree(unsafe.Pointer) { - panic("not implemented") -} - -func PreClosureLoc(closure unsafe.Pointer, cif *Cif, fn ClosureFunc, userdata unsafe.Pointer, codeloc unsafe.Pointer) c.Uint { - panic("not implemented") -}