rm internal/runtime/c; mv internal/runtime/bdwgc => c/bdwgc

This commit is contained in:
xushiwei
2024-06-15 08:43:48 +08:00
parent 7b0ed42d3b
commit 98498c9180
33 changed files with 34 additions and 182 deletions

View File

@@ -23,7 +23,7 @@ import (
)
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
func CollectALittle()
// -----------------------------------------------------------------------------

3
c/c.go
View File

@@ -77,6 +77,9 @@ func Memset(s Pointer, c Int, n uintptr) Pointer
//go:linkname GoStringData llgo.stringData
func GoStringData(string) *Char
//go:linkname GoDeferData llgo.deferData
func GoDeferData() Pointer
// -----------------------------------------------------------------------------
//go:linkname AllocaSigjmpBuf llgo.sigjmpbuf

View File

@@ -3,7 +3,7 @@ package main
import (
"unsafe"
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func gwrite(b []byte) {

View File

@@ -1,6 +1,6 @@
package main
import "github.com/goplus/llgo/internal/runtime/c"
import "github.com/goplus/llgo/c"
func test(a ...any) {
for _, v := range a {

View File

@@ -1,6 +1,6 @@
package main
import "github.com/goplus/llgo/internal/runtime/c"
import "github.com/goplus/llgo/c"
func f(s string) bool {
return len(s) > 2

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func main() {

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func hello() string {

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func hi(a any) *c.Char {

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func callback(msg *c.Char, f func(*c.Char)) {

View File

@@ -1,6 +1,6 @@
package main
//"github.com/goplus/llgo/internal/runtime/c"
//"github.com/goplus/llgo/c"
func main() {
cvt64to8(0, 0)

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func main() {

View File

@@ -1,8 +1,8 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/internal/abi"
"github.com/goplus/llgo/internal/runtime/c"
)
func Basic(kind abi.Kind) *abi.Type {

View File

@@ -1,6 +1,6 @@
package main
import "github.com/goplus/llgo/internal/runtime/c"
import "github.com/goplus/llgo/c"
type point struct {
x int

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
type generator struct {

View File

@@ -3,8 +3,8 @@ package main
import (
_ "unsafe"
"github.com/goplus/llgo/c"
_ "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

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func main() {

View File

@@ -1,6 +1,6 @@
package main
import "github.com/goplus/llgo/internal/runtime/c"
import "github.com/goplus/llgo/c"
type mSpanList struct {
first *mspan

View File

@@ -3,7 +3,7 @@ package main
import (
"unsafe"
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
//go:linkname qsort C.qsort

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func main() {

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func sum(args ...int) (ret int) {

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func foo() {

View File

@@ -1,7 +1,7 @@
package linktarget
import (
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func F(a, b *c.Char) {

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -19,8 +19,8 @@ package runtime
import (
"unsafe"
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/internal/abi"
"github.com/goplus/llgo/internal/runtime/c"
)
type eface struct {

View File

@@ -22,8 +22,8 @@ package runtime
import (
"unsafe"
"github.com/goplus/llgo/internal/runtime/bdwgc"
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/bdwgc"
)
// AllocU allocates uninitialized memory.

View File

@@ -22,7 +22,7 @@ package runtime
import (
"unsafe"
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
// AllocU allocates uninitialized memory.

View File

@@ -19,7 +19,7 @@ package runtime
import (
"unsafe"
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
func PrintByte(v byte) {

View File

@@ -19,9 +19,9 @@ package runtime
import (
"unsafe"
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/pthread"
"github.com/goplus/llgo/internal/abi"
"github.com/goplus/llgo/internal/runtime/c"
)
// -----------------------------------------------------------------------------

View File

@@ -19,7 +19,7 @@ package runtime
import (
"unsafe"
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
// -----------------------------------------------------------------------------

View File

@@ -19,7 +19,7 @@ package runtime
import (
"unsafe"
"github.com/goplus/llgo/internal/runtime/c"
"github.com/goplus/llgo/c"
)
// -----------------------------------------------------------------------------