runtime: testing runtime

This commit is contained in:
Li Jie
2025-02-14 17:18:13 +08:00
parent 66909b3000
commit 5329f28580
83 changed files with 3376 additions and 2061 deletions

View File

@@ -0,0 +1,5 @@
package debug
func SetTraceback(level string) {
panic("todo: runtime/debug.SetTraceback")
}

View File

@@ -7,3 +7,7 @@ package runtime
func Caller(skip int) (pc uintptr, file string, line int, ok bool) {
panic("todo: runtime.Caller")
}
func Callers(skip int, pc []uintptr) int {
panic("todo: runtime.Callers")
}

View File

@@ -0,0 +1,6 @@
package syscall
import _ "unsafe"
// llgo:skipall
type _syscall6 struct{}

View File

@@ -0,0 +1,24 @@
package pprof
import (
"io"
)
// llgo:skipall
type Profile struct{}
func (p *Profile) WriteTo(w io.Writer, verbose bool) (int, error) {
panic("WriteTo not implemented")
}
func StartCPUProfile(w io.Writer) error {
panic("StartCPUProfile not implemented")
}
func StopCPUProfile() {
panic("StopCPUProfile not implemented")
}
func Lookup(name string) *Profile {
panic("Lookup not implemented")
}

View File

@@ -16,8 +16,22 @@
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"
"unsafe"
"github.com/goplus/llgo/runtime/internal/clite/pthread"
)
// llgo:skipall
@@ -27,12 +41,23 @@ type _runtime struct{}
// GOROOT environment variable, if set at process start,
// or else the root used during the Go build.
func GOROOT() string {
/*
s := gogetenv("GOROOT")
if s != "" {
return s
}
return defaultGOROOT
*/
panic("todo: GOROOT")
return ""
}
//go:linkname c_maxprocs C.llgo_maxprocs
func c_maxprocs() int32
func GOMAXPROCS(n int) int {
return int(c_maxprocs())
}
func Goexit() {
pthread.Exit(nil)
}
func KeepAlive(x any) {
}
func write(fd uintptr, p unsafe.Pointer, n int32) int32 {
return int32(C.write(C.int(fd), p, C.size_t(n)))
}

View File

@@ -4,6 +4,10 @@
package runtime
import (
"runtime"
)
// Layout of in-memory per-function information prepared by linker
// See https://golang.org/s/go12symtab.
// Keep in sync with linker (../cmd/link/internal/ld/pcln.go:/pclntab)
@@ -11,3 +15,33 @@ package runtime
type _func struct {
unused [8]byte
}
func Stack(buf []byte, all bool) int {
panic("todo: runtime.Stack")
}
func StartTrace() error {
panic("todo: runtime.StartTrace")
}
func ReadTrace() []byte {
panic("todo: runtime.ReadTrace")
}
func StopTrace() {
panic("todo: runtime.StopTrace")
}
func ReadMemStats(m *runtime.MemStats) {
panic("todo: runtime.ReadMemStats")
}
func SetMutexProfileFraction(rate int) int {
panic("todo: runtime.SetMutexProfileFraction")
}
func SetBlockProfileRate(rate int) {
panic("todo: runtime.SetBlockProfileRate")
}
var MemProfileRate int = 512 * 1024

View File

@@ -0,0 +1,9 @@
//go:build !nogc
package runtime
import "github.com/goplus/llgo/runtime/internal/clite/bdwgc"
func GC() {
bdwgc.Gcollect()
}

View File

@@ -0,0 +1,7 @@
//go:build nogc
package runtime
func GC() {
}

View File

@@ -0,0 +1,5 @@
package trace
func userTaskEnd(id uint64) {
panic("todo: runtime/trace.userTaskEnd")
}