Files
llgo/runtime/internal/lib/runtime/runtime.go

68 lines
1.4 KiB
Go
Raw Normal View History

2024-06-16 23:07:42 +08:00
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package runtime
import (
2025-02-14 17:18:13 +08:00
"unsafe"
2025-04-08 16:50:47 +08:00
c "github.com/goplus/llgo/runtime/internal/clite"
2025-02-16 08:21:58 +08:00
"github.com/goplus/llgo/runtime/internal/runtime"
2024-06-16 23:07:42 +08:00
)
2024-06-26 17:17:10 +08:00
2025-01-10 18:17:40 +08:00
// llgo:skipall
type _runtime struct{}
2025-04-08 16:50:47 +08:00
const (
LLGoPackage = "link"
LLGoFiles = "_wrap/runtime.c"
)
var defaultGOROOT string // set by cmd/link
2024-06-26 17:17:10 +08:00
func GOROOT() string {
return defaultGOROOT
}
var buildVersion string
func Version() string {
return buildVersion
2025-02-14 17:18:13 +08:00
}
//go:linkname c_maxprocs C.llgo_maxprocs
func c_maxprocs() int32
func GOMAXPROCS(n int) int {
return int(c_maxprocs())
}
func Goexit() {
2025-02-16 08:21:58 +08:00
runtime.Goexit()
2025-02-14 17:18:13 +08:00
}
func KeepAlive(x any) {
}
2025-04-08 16:50:47 +08:00
//go:linkname c_write C.write
func c_write(fd c.Int, p unsafe.Pointer, n c.SizeT) int32
2025-02-14 17:18:13 +08:00
func write(fd uintptr, p unsafe.Pointer, n int32) int32 {
2025-04-08 16:50:47 +08:00
return int32(c_write(c.Int(fd), p, c.SizeT(n)))
2024-06-26 17:17:10 +08:00
}
2025-04-08 16:50:47 +08:00
const heapArenaBytes = 1024 * 1024