diff --git a/testdata/operator/libc_unix.go b/testdata/operator/libc_unix.go index 200d611..0380b32 100644 --- a/testdata/operator/libc_unix.go +++ b/testdata/operator/libc_unix.go @@ -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] diff --git a/testdata/printf/libc_unix.go b/testdata/printf/libc_unix.go index ea9e7f4..a94cfe7 100644 --- a/testdata/printf/libc_unix.go +++ b/testdata/printf/libc_unix.go @@ -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...) } @@ -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 +) diff --git a/testdata/qsort/libc.go b/testdata/qsort/libc.go index c25e3cb..a59fe6f 100644 --- a/testdata/qsort/libc.go +++ b/testdata/qsort/libc.go @@ -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) @@ -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] } @@ -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 } diff --git a/testdata/qsort/libc_unix.go b/testdata/qsort/libc_unix.go index c2bbc18..e0afddb 100644 --- a/testdata/qsort/libc_unix.go +++ b/testdata/qsort/libc_unix.go @@ -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{}