rm internal/runtime/c; mv internal/runtime/bdwgc => c/bdwgc
This commit is contained in:
@@ -23,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LLGoPackage = "link: $LLGO_LIB_BDWGC; $(pkg-config --libs bdw-gc); -lgc"
|
LLGoPackage = "link: $(pkg-config --libs bdw-gc); -lgc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -99,3 +99,5 @@ func StartIncrementalCollection()
|
|||||||
|
|
||||||
//go:linkname CollectALittle C.GC_collect_a_little
|
//go:linkname CollectALittle C.GC_collect_a_little
|
||||||
func CollectALittle()
|
func CollectALittle()
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
3
c/c.go
3
c/c.go
@@ -77,6 +77,9 @@ func Memset(s Pointer, c Int, n uintptr) Pointer
|
|||||||
//go:linkname GoStringData llgo.stringData
|
//go:linkname GoStringData llgo.stringData
|
||||||
func GoStringData(string) *Char
|
func GoStringData(string) *Char
|
||||||
|
|
||||||
|
//go:linkname GoDeferData llgo.deferData
|
||||||
|
func GoDeferData() Pointer
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
//go:linkname AllocaSigjmpBuf llgo.sigjmpbuf
|
//go:linkname AllocaSigjmpBuf llgo.sigjmpbuf
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func gwrite(b []byte) {
|
func gwrite(b []byte) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "github.com/goplus/llgo/internal/runtime/c"
|
import "github.com/goplus/llgo/c"
|
||||||
|
|
||||||
func test(a ...any) {
|
func test(a ...any) {
|
||||||
for _, v := range a {
|
for _, v := range a {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "github.com/goplus/llgo/internal/runtime/c"
|
import "github.com/goplus/llgo/c"
|
||||||
|
|
||||||
func f(s string) bool {
|
func f(s string) bool {
|
||||||
return len(s) > 2
|
return len(s) > 2
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func hello() string {
|
func hello() string {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func hi(a any) *c.Char {
|
func hi(a any) *c.Char {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func callback(msg *c.Char, f func(*c.Char)) {
|
func callback(msg *c.Char, f func(*c.Char)) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
//"github.com/goplus/llgo/internal/runtime/c"
|
//"github.com/goplus/llgo/c"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cvt64to8(0, 0)
|
cvt64to8(0, 0)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/goplus/llgo/c"
|
||||||
"github.com/goplus/llgo/internal/abi"
|
"github.com/goplus/llgo/internal/abi"
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Basic(kind abi.Kind) *abi.Type {
|
func Basic(kind abi.Kind) *abi.Type {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "github.com/goplus/llgo/internal/runtime/c"
|
import "github.com/goplus/llgo/c"
|
||||||
|
|
||||||
type point struct {
|
type point struct {
|
||||||
x int
|
x int
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
type generator struct {
|
type generator struct {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
_ "unsafe"
|
_ "unsafe"
|
||||||
|
|
||||||
|
"github.com/goplus/llgo/c"
|
||||||
_ "github.com/goplus/llgo/cl/internal/linktarget"
|
_ "github.com/goplus/llgo/cl/internal/linktarget"
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:linkname print github.com/goplus/llgo/cl/internal/linktarget.F
|
//go:linkname print github.com/goplus/llgo/cl/internal/linktarget.F
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "github.com/goplus/llgo/internal/runtime/c"
|
import "github.com/goplus/llgo/c"
|
||||||
|
|
||||||
type mSpanList struct {
|
type mSpanList struct {
|
||||||
first *mspan
|
first *mspan
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:linkname qsort C.qsort
|
//go:linkname qsort C.qsort
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func sum(args ...int) (ret int) {
|
func sum(args ...int) (ret int) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func foo() {
|
func foo() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package linktarget
|
package linktarget
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func F(a, b *c.Char) {
|
func F(a, b *c.Char) {
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 c
|
|
||||||
|
|
||||||
import "C"
|
|
||||||
import "unsafe"
|
|
||||||
|
|
||||||
const (
|
|
||||||
LLGoPackage = "decl"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
Char = int8
|
|
||||||
Int = C.int
|
|
||||||
Pointer = unsafe.Pointer
|
|
||||||
FilePtr = unsafe.Pointer
|
|
||||||
)
|
|
||||||
|
|
||||||
//go:linkname Str llgo.cstr
|
|
||||||
func Str(string) *Char
|
|
||||||
|
|
||||||
// llgo:link Advance llgo.advance
|
|
||||||
func Advance[PtrT any](ptr PtrT, offset int) PtrT { return ptr }
|
|
||||||
|
|
||||||
//go:linkname Alloca llgo.alloca
|
|
||||||
func Alloca(size uintptr) Pointer
|
|
||||||
|
|
||||||
//go:linkname AllocaCStr llgo.allocaCStr
|
|
||||||
func AllocaCStr(s string) *Char
|
|
||||||
|
|
||||||
//go:linkname GoDeferData llgo.deferData
|
|
||||||
func GoDeferData() Pointer
|
|
||||||
|
|
||||||
//go:linkname Unreachable llgo.unreachable
|
|
||||||
func Unreachable()
|
|
||||||
|
|
||||||
//go:linkname Exit C.exit
|
|
||||||
func Exit(Int)
|
|
||||||
|
|
||||||
//go:linkname AllocaSigjmpBuf llgo.sigjmpbuf
|
|
||||||
func AllocaSigjmpBuf() Pointer
|
|
||||||
|
|
||||||
//go:linkname Sigsetjmp llgo.sigsetjmp
|
|
||||||
func Sigsetjmp(jb Pointer, savemask Int) Int
|
|
||||||
|
|
||||||
//go:linkname Siglongjmp llgo.siglongjmp
|
|
||||||
func Siglongjmp(jb Pointer, retval Int)
|
|
||||||
|
|
||||||
//go:linkname Rand C.rand
|
|
||||||
func Rand() Int
|
|
||||||
|
|
||||||
//go:linkname Malloc C.malloc
|
|
||||||
func Malloc(size uintptr) Pointer
|
|
||||||
|
|
||||||
//go:linkname Free C.free
|
|
||||||
func Free(ptr Pointer)
|
|
||||||
|
|
||||||
//go:linkname Memcpy C.memcpy
|
|
||||||
func Memcpy(dst, src Pointer, n uintptr) Pointer
|
|
||||||
|
|
||||||
//go:linkname Memmove C.memmove
|
|
||||||
func Memmove(dst, src Pointer, n uintptr) Pointer
|
|
||||||
|
|
||||||
//go:linkname Memset C.memset
|
|
||||||
func Memset(s Pointer, c Int, n uintptr) Pointer
|
|
||||||
|
|
||||||
//go:linkname Printf C.printf
|
|
||||||
func Printf(format *Char, __llgo_va_list ...any) Int
|
|
||||||
|
|
||||||
//go:linkname Fprintf C.fprintf
|
|
||||||
func Fprintf(fp FilePtr, format *Char, __llgo_va_list ...any) Int
|
|
||||||
|
|
||||||
//go:linkname Fwrite C.fwrite
|
|
||||||
func Fwrite(data Pointer, size, count uintptr, fp FilePtr) uintptr
|
|
||||||
|
|
||||||
//go:linkname Fputc C.fputc
|
|
||||||
func Fputc(c Int, fp FilePtr) Int
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
//go:build !linux
|
|
||||||
// +build !linux
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 c
|
|
||||||
|
|
||||||
import _ "unsafe"
|
|
||||||
|
|
||||||
//go:linkname Stdin __stdinp
|
|
||||||
var Stdin FilePtr
|
|
||||||
|
|
||||||
//go:linkname Stdout __stdoutp
|
|
||||||
var Stdout FilePtr
|
|
||||||
|
|
||||||
//go:linkname Stderr __stderrp
|
|
||||||
var Stderr FilePtr
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
//go:build linux
|
|
||||||
// +build linux
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 c
|
|
||||||
|
|
||||||
import _ "unsafe"
|
|
||||||
|
|
||||||
//go:linkname Stdin stdin
|
|
||||||
var Stdin FilePtr
|
|
||||||
|
|
||||||
//go:linkname Stdout stdout
|
|
||||||
var Stdout FilePtr
|
|
||||||
|
|
||||||
//go:linkname Stderr stderr
|
|
||||||
var Stderr FilePtr
|
|
||||||
@@ -19,8 +19,8 @@ package runtime
|
|||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/goplus/llgo/c"
|
||||||
"github.com/goplus/llgo/internal/abi"
|
"github.com/goplus/llgo/internal/abi"
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type eface struct {
|
type eface struct {
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ package runtime
|
|||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/internal/runtime/bdwgc"
|
"github.com/goplus/llgo/c"
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c/bdwgc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AllocU allocates uninitialized memory.
|
// AllocU allocates uninitialized memory.
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package runtime
|
|||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AllocU allocates uninitialized memory.
|
// AllocU allocates uninitialized memory.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package runtime
|
|||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PrintByte(v byte) {
|
func PrintByte(v byte) {
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ package runtime
|
|||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/goplus/llgo/c"
|
||||||
"github.com/goplus/llgo/c/pthread"
|
"github.com/goplus/llgo/c/pthread"
|
||||||
"github.com/goplus/llgo/internal/abi"
|
"github.com/goplus/llgo/internal/abi"
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package runtime
|
|||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package runtime
|
|||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user