Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
testdata
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Nov 22, 2022
1 parent 517a160 commit b11ef18
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 50 deletions.
1 change: 1 addition & 0 deletions testdata/operator/libc_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type struct___sFILEX struct{}
type struct__IO_marker struct{} // Linux
type struct__IO_codecvt struct{}
type struct__IO_wide_data struct{}
type struct___locale_data struct{}

func sliceOf(v unsafe.Pointer, bytes uint) []byte {
return (*[1 << 20]byte)(v)[:bytes]
Expand Down
9 changes: 7 additions & 2 deletions testdata/printf/libc_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package main

func printf(format *int8, args ...interface{}) int32 {
func vfprintf(fp *FILE, format *int8, args []interface{}) int32 {
return goprintf(format, args...)
}

Expand All @@ -13,6 +13,11 @@ func __swbuf(_c int32, _p *FILE) int32 {

type struct___sFILEX struct{}

type struct__IO_marker struct{} // Linux
type struct__IO_marker struct{}
type struct__IO_codecvt struct{}
type struct__IO_wide_data struct{}

var (
stdout *FILE
__stdoutp *FILE
)
38 changes: 23 additions & 15 deletions testdata/qsort/libc.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package main

import (
"fmt"
"strings"
"log"
"unsafe"

c "github.com/goplus/c2go/clang"
)

func a_cas(p *int32, t, s int32) int32 {
log.Panicln("a_cas: notimpl")
return 0
}

func C(s string) *int8 {
n := len(s)
ret := make([]byte, n+1)
Expand All @@ -24,17 +28,6 @@ func gostring(s *int8) string {
return string(arr[:n])
}

func goprintf(format *int8, args ...interface{}) int32 {
goformat := strings.ReplaceAll(gostring(format), "%lld", "%d")
for i, arg := range args {
if v, ok := arg.(*int8); ok {
args[i] = gostring(v)
}
}
fmt.Printf(goformat, args...)
return 0
}

func sliceOf(v unsafe.Pointer, bytes c.SizeT) []byte {
return (*[1 << 20]byte)(v)[:bytes]
}
Expand All @@ -44,6 +37,21 @@ func memcpy(dst unsafe.Pointer, src unsafe.Pointer, n c.SizeT) unsafe.Pointer {
return dst
}

func a_cas(p *int32, t int32, s int32) int32 {
panic("notimpl")
func __builtin___memcpy_chk(dst unsafe.Pointer, src unsafe.Pointer, n c.SizeT, elem c.SizeT) unsafe.Pointer {
copy(sliceOf(dst, n), sliceOf(src, n))
return dst
}

func __builtin_object_size(unsafe.Pointer, int32) c.SizeT {
return 1
}

func __builtin_bswap32(v uint32) uint32 {
log.Panicln("__builtin_bswap32: notimpl")
return v
}

func __builtin_bswap64(v uint64) uint64 {
log.Panicln("__builtin_bswap32: notimpl")
return v
}
34 changes: 1 addition & 33 deletions testdata/qsort/libc_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,10 @@

package main

import (
"log"
"unsafe"

c "github.com/goplus/c2go/clang"
)

func printf(format *int8, args ...interface{}) int32 {
return goprintf(format, args...)
}

func __swbuf(_c int32, _p *FILE) int32 {
return _c
}

type struct___sFILEX struct{}

type struct__IO_marker struct{} // Linux
type struct__IO_codecvt struct{}
type struct__IO_wide_data struct{}

func __builtin___memcpy_chk(dst unsafe.Pointer, src unsafe.Pointer, n c.SizeT, elem c.SizeT) unsafe.Pointer {
copy(sliceOf(dst, n), sliceOf(src, n))
return dst
}

func __builtin_object_size(unsafe.Pointer, int32) c.SizeT {
return 1
}

func __builtin_bswap32(v uint32) uint32 {
log.Panicln("__builtin_bswap32: notimpl")
return v
}

func __builtin_bswap64(v uint64) uint64 {
log.Panicln("__builtin_bswap32: notimpl")
return v
}
type struct___locale_data struct{}

0 comments on commit b11ef18

Please sign in to comment.