make runtime compatible with wasm
This commit is contained in:
10
runtime/internal/lib/runtime/_wrap/runtime.c
Normal file
10
runtime/internal/lib/runtime/_wrap/runtime.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <unistd.h>
|
||||
|
||||
int llgo_maxprocs()
|
||||
{
|
||||
#ifdef _SC_NPROCESSORS_ONLN
|
||||
return (int)sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
5
runtime/internal/lib/runtime/malloc.go
Normal file
5
runtime/internal/lib/runtime/malloc.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package runtime
|
||||
|
||||
// const (
|
||||
// heapAddrBits = (_64bit*(1-goarch.IsWasm)*(1-goos.IsIos*goarch.IsArm64))*48 + (1-_64bit+goarch.IsWasm)*(32-(goarch.IsMips+goarch.IsMipsle)) + 40*goos.IsIos*goarch.IsArm64
|
||||
// )
|
||||
@@ -16,27 +16,21 @@
|
||||
|
||||
package runtime
|
||||
|
||||
/*
|
||||
#include <unistd.h>
|
||||
|
||||
int llgo_maxprocs() {
|
||||
#ifdef _SC_NPROCESSORS_ONLN
|
||||
return (int)sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
"github.com/goplus/llgo/runtime/internal/runtime"
|
||||
)
|
||||
|
||||
// llgo:skipall
|
||||
type _runtime struct{}
|
||||
|
||||
const (
|
||||
LLGoPackage = "link"
|
||||
LLGoFiles = "_wrap/runtime.c"
|
||||
)
|
||||
|
||||
// GOROOT returns the root of the Go tree. It uses the
|
||||
// GOROOT environment variable, if set at process start,
|
||||
// or else the root used during the Go build.
|
||||
@@ -58,6 +52,11 @@ func Goexit() {
|
||||
func KeepAlive(x any) {
|
||||
}
|
||||
|
||||
//go:linkname c_write C.write
|
||||
func c_write(fd c.Int, p unsafe.Pointer, n c.SizeT) int32
|
||||
|
||||
func write(fd uintptr, p unsafe.Pointer, n int32) int32 {
|
||||
return int32(C.write(C.int(fd), p, C.size_t(n)))
|
||||
return int32(c_write(c.Int(fd), p, c.SizeT(n)))
|
||||
}
|
||||
|
||||
const heapArenaBytes = 1024 * 1024
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
)
|
||||
import "runtime"
|
||||
|
||||
// Layout of in-memory per-function information prepared by linker
|
||||
// See https://golang.org/s/go12symtab.
|
||||
|
||||
Reference in New Issue
Block a user