From c5ac1c74f650c1a5e3cd14db2bf1731b35ecc284 Mon Sep 17 00:00:00 2001 From: visualfc Date: Fri, 18 Nov 2022 19:42:45 +0800 Subject: [PATCH] testdata: libc_darwin/libc_windows --- testdata/atomic/{libc.go => libc_darwin.go} | 0 testdata/atomic/libc_windows.go | 85 ++++++++++++++++-- testdata/bitfield/bitfield.c | 8 +- testdata/bitfield/{libc.go => libc_darwin.go} | 0 testdata/bitfield/libc_windows.go | 73 ++++++++++++++++ testdata/complex/{libc.go => libc_darwin.go} | 0 testdata/complex/libc_windows.go | 81 +++++++++++++++++ .../compoundlit/{libc.go => libc_darwin.go} | 2 +- testdata/compoundlit/libc_windows.go | 73 ++++++++++++++++ testdata/flow/{libc.go => libc_darwin.go} | 2 +- testdata/flow/libc_windows.go | 73 ++++++++++++++++ testdata/forceeval/libc.go | 37 -------- .../libc.go => forceeval/libc_darwin.go} | 2 +- testdata/forceeval/libc_windows.go | 73 ++++++++++++++++ testdata/hello/{libc.go => libc_darwin.go} | 2 +- testdata/hello/libc_windows.go | 73 ++++++++++++++++ testdata/incdec/libc_darwin.go | 35 ++++++++ testdata/incdec/libc_windows.go | 73 ++++++++++++++++ testdata/init/libc.go | 35 -------- testdata/init/libc_darwin.go | 35 ++++++++ testdata/init/libc_windows.go | 73 ++++++++++++++++ testdata/libc/{libc.go => libc_darwin.go} | 0 testdata/libc/libc_windows.go | 73 ++++++++++++++++ testdata/operator/{libc.go => libc_darwin.go} | 0 testdata/operator/libc_windows.go | 79 +++++++++++++++++ testdata/printf/{libc.go => libc_darwin.go} | 0 testdata/printf/libc_windows.go | 87 +++++++++++++++++++ testdata/printf/main.go | 2 +- testdata/printf/printf.c | 2 +- testdata/strlen/{libc.go => libc_darwin.go} | 0 testdata/strlen/libc_windows.go | 47 ++++++++++ testdata/struct/libc.go | 35 -------- testdata/struct/libc_darwin.go | 35 ++++++++ testdata/struct/libc_windows.go | 73 ++++++++++++++++ testdata/switch/libc.go | 35 -------- testdata/switch/libc_darwin.go | 35 ++++++++ testdata/switch/libc_windows.go | 73 ++++++++++++++++ testdata/typecast/libc.go | 35 -------- testdata/typecast/libc_darwin.go | 35 ++++++++ testdata/typecast/libc_windows.go | 73 ++++++++++++++++ testdata/union/libc.go | 35 -------- testdata/union/libc_darwin.go | 35 ++++++++ testdata/union/libc_windows.go | 73 ++++++++++++++++ testdata/vaexpr/{libc.go => libc_darwin.go} | 2 +- testdata/vaexpr/libc_windows.go | 81 +++++++++++++++++ testdata/vappendf/{libc.go => libc_darwin.go} | 0 testdata/vappendf/libc_windows.go | 26 ++++++ testdata/xdigits/libc.go | 35 -------- testdata/xdigits/libc_darwin.go | 35 ++++++++ testdata/xdigits/libc_windows.go | 73 ++++++++++++++++ 50 files changed, 1684 insertions(+), 265 deletions(-) rename testdata/atomic/{libc.go => libc_darwin.go} (100%) rename testdata/bitfield/{libc.go => libc_darwin.go} (100%) create mode 100644 testdata/bitfield/libc_windows.go rename testdata/complex/{libc.go => libc_darwin.go} (100%) create mode 100644 testdata/complex/libc_windows.go rename testdata/compoundlit/{libc.go => libc_darwin.go} (90%) create mode 100644 testdata/compoundlit/libc_windows.go rename testdata/flow/{libc.go => libc_darwin.go} (90%) create mode 100644 testdata/flow/libc_windows.go delete mode 100644 testdata/forceeval/libc.go rename testdata/{incdec/libc.go => forceeval/libc_darwin.go} (90%) create mode 100644 testdata/forceeval/libc_windows.go rename testdata/hello/{libc.go => libc_darwin.go} (90%) create mode 100644 testdata/hello/libc_windows.go create mode 100644 testdata/incdec/libc_darwin.go create mode 100644 testdata/incdec/libc_windows.go delete mode 100644 testdata/init/libc.go create mode 100644 testdata/init/libc_darwin.go create mode 100644 testdata/init/libc_windows.go rename testdata/libc/{libc.go => libc_darwin.go} (100%) create mode 100644 testdata/libc/libc_windows.go rename testdata/operator/{libc.go => libc_darwin.go} (100%) create mode 100644 testdata/operator/libc_windows.go rename testdata/printf/{libc.go => libc_darwin.go} (100%) create mode 100644 testdata/printf/libc_windows.go rename testdata/strlen/{libc.go => libc_darwin.go} (100%) create mode 100644 testdata/strlen/libc_windows.go delete mode 100644 testdata/struct/libc.go create mode 100644 testdata/struct/libc_darwin.go create mode 100644 testdata/struct/libc_windows.go delete mode 100644 testdata/switch/libc.go create mode 100644 testdata/switch/libc_darwin.go create mode 100644 testdata/switch/libc_windows.go delete mode 100644 testdata/typecast/libc.go create mode 100644 testdata/typecast/libc_darwin.go create mode 100644 testdata/typecast/libc_windows.go delete mode 100644 testdata/union/libc.go create mode 100644 testdata/union/libc_darwin.go create mode 100644 testdata/union/libc_windows.go rename testdata/vaexpr/{libc.go => libc_darwin.go} (92%) create mode 100644 testdata/vaexpr/libc_windows.go rename testdata/vappendf/{libc.go => libc_darwin.go} (100%) create mode 100644 testdata/vappendf/libc_windows.go delete mode 100644 testdata/xdigits/libc.go create mode 100644 testdata/xdigits/libc_darwin.go create mode 100644 testdata/xdigits/libc_windows.go diff --git a/testdata/atomic/libc.go b/testdata/atomic/libc_darwin.go similarity index 100% rename from testdata/atomic/libc.go rename to testdata/atomic/libc_darwin.go diff --git a/testdata/atomic/libc_windows.go b/testdata/atomic/libc_windows.go index a4a2ac1..00b103c 100644 --- a/testdata/atomic/libc_windows.go +++ b/testdata/atomic/libc_windows.go @@ -1,18 +1,89 @@ package main -func __swbuf_r(_ptr *struct__reent, _c int32, _p *FILE) int32 { - return _c +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) } -func __srget_r(_ptr *struct__reent, _p *FILE) int32 { +func printf(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 __getreent() *struct__reent { - return nil +func __atomic_store_n_i32(p *int32, memorder int32, v int32) { + *p = v +} + +func __atomic_store_n_i64(p *int64, memorder int32, v int64) { + *p = v +} + +func __atomic_load_n_i32(p *int32, memorder int32) int32 { + return *p } -func ungetc(_c int32, _p *FILE) { +func __atomic_load_n_i64(p *int64, memorder int32) int64 { + return *p } -type struct___locale_t struct{} // Windows +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/bitfield/bitfield.c b/testdata/bitfield/bitfield.c index 153e833..05a0cd7 100644 --- a/testdata/bitfield/bitfield.c +++ b/testdata/bitfield/bitfield.c @@ -11,13 +11,13 @@ typedef struct { z :5; } foo; -typedef long time_t; +typedef long time_x; typedef struct { - time_t tv_sec; - int :8*(sizeof(time_t)-sizeof(long))*(1234==4321); + time_x tv_sec; + int :8*(sizeof(time_x)-sizeof(long))*(1234==4321); long tv_nsec; - int :8*(sizeof(time_t)-sizeof(long))*(1234!=4321); + int :8*(sizeof(time_x)-sizeof(long))*(1234!=4321); } timespec_t; int main() { diff --git a/testdata/bitfield/libc.go b/testdata/bitfield/libc_darwin.go similarity index 100% rename from testdata/bitfield/libc.go rename to testdata/bitfield/libc_darwin.go diff --git a/testdata/bitfield/libc_windows.go b/testdata/bitfield/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/bitfield/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/complex/libc.go b/testdata/complex/libc_darwin.go similarity index 100% rename from testdata/complex/libc.go rename to testdata/complex/libc_darwin.go diff --git a/testdata/complex/libc_windows.go b/testdata/complex/libc_windows.go new file mode 100644 index 0000000..d66d0bf --- /dev/null +++ b/testdata/complex/libc_windows.go @@ -0,0 +1,81 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func creal(v complex128) float64 { + return real(v) +} + +func cimag(v complex128) float64 { + return imag(v) +} + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/compoundlit/libc.go b/testdata/compoundlit/libc_darwin.go similarity index 90% rename from testdata/compoundlit/libc.go rename to testdata/compoundlit/libc_darwin.go index ffbce4a..df1ef80 100644 --- a/testdata/compoundlit/libc.go +++ b/testdata/compoundlit/libc_darwin.go @@ -13,7 +13,7 @@ func gostring(s *int8) string { return string(arr[:n]) } -func printf(format *int8, args ...interface{}) int32 { +func printf(format *int8, args ...interface{}) int { goformat := gostring(format) for i, arg := range args { if v, ok := arg.(*int8); ok { diff --git a/testdata/compoundlit/libc_windows.go b/testdata/compoundlit/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/compoundlit/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/flow/libc.go b/testdata/flow/libc_darwin.go similarity index 90% rename from testdata/flow/libc.go rename to testdata/flow/libc_darwin.go index ffbce4a..df1ef80 100644 --- a/testdata/flow/libc.go +++ b/testdata/flow/libc_darwin.go @@ -13,7 +13,7 @@ func gostring(s *int8) string { return string(arr[:n]) } -func printf(format *int8, args ...interface{}) int32 { +func printf(format *int8, args ...interface{}) int { goformat := gostring(format) for i, arg := range args { if v, ok := arg.(*int8); ok { diff --git a/testdata/flow/libc_windows.go b/testdata/flow/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/flow/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/forceeval/libc.go b/testdata/forceeval/libc.go deleted file mode 100644 index bb5b73c..0000000 --- a/testdata/forceeval/libc.go +++ /dev/null @@ -1,37 +0,0 @@ -package main - -import ( - "fmt" - "strings" - "unsafe" -) - -func gostring(s *int8) string { - n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) - for arr[n] != 0 { - n++ - } - return string(arr[:n]) -} - -func printf(format *int8, args ...interface{}) int32 { - goformat := gostring(format) - for i, arg := range args { - if v, ok := arg.(*int8); ok { - args[i] = gostring(v) - } - } - s := strings.ToLower(fmt.Sprintf(goformat, args...)) - fmt.Print(s) - return 0 -} - -func __swbuf(_c int32, _p *FILE) int32 { - return _c -} - -type struct___sFILEX struct{} - -type struct__IO_marker struct{} -type struct__IO_codecvt struct{} -type struct__IO_wide_data struct{} diff --git a/testdata/incdec/libc.go b/testdata/forceeval/libc_darwin.go similarity index 90% rename from testdata/incdec/libc.go rename to testdata/forceeval/libc_darwin.go index ffbce4a..df1ef80 100644 --- a/testdata/incdec/libc.go +++ b/testdata/forceeval/libc_darwin.go @@ -13,7 +13,7 @@ func gostring(s *int8) string { return string(arr[:n]) } -func printf(format *int8, args ...interface{}) int32 { +func printf(format *int8, args ...interface{}) int { goformat := gostring(format) for i, arg := range args { if v, ok := arg.(*int8); ok { diff --git a/testdata/forceeval/libc_windows.go b/testdata/forceeval/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/forceeval/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/hello/libc.go b/testdata/hello/libc_darwin.go similarity index 90% rename from testdata/hello/libc.go rename to testdata/hello/libc_darwin.go index ffbce4a..df1ef80 100644 --- a/testdata/hello/libc.go +++ b/testdata/hello/libc_darwin.go @@ -13,7 +13,7 @@ func gostring(s *int8) string { return string(arr[:n]) } -func printf(format *int8, args ...interface{}) int32 { +func printf(format *int8, args ...interface{}) int { goformat := gostring(format) for i, arg := range args { if v, ok := arg.(*int8); ok { diff --git a/testdata/hello/libc_windows.go b/testdata/hello/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/hello/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/incdec/libc_darwin.go b/testdata/incdec/libc_darwin.go new file mode 100644 index 0000000..df1ef80 --- /dev/null +++ b/testdata/incdec/libc_darwin.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(format *int8, args ...interface{}) int { + goformat := gostring(format) + for i, arg := range args { + if v, ok := arg.(*int8); ok { + args[i] = gostring(v) + } + } + fmt.Printf(goformat, args...) + return 0 +} + +func __swbuf(_c int32, _p *FILE) int32 { + return _c +} + +type struct___sFILEX struct{} + +type struct__IO_marker struct{} +type struct__IO_codecvt struct{} +type struct__IO_wide_data struct{} diff --git a/testdata/incdec/libc_windows.go b/testdata/incdec/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/incdec/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/init/libc.go b/testdata/init/libc.go deleted file mode 100644 index ffbce4a..0000000 --- a/testdata/init/libc.go +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - "fmt" - "unsafe" -) - -func gostring(s *int8) string { - n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) - for arr[n] != 0 { - n++ - } - return string(arr[:n]) -} - -func printf(format *int8, args ...interface{}) int32 { - goformat := gostring(format) - for i, arg := range args { - if v, ok := arg.(*int8); ok { - args[i] = gostring(v) - } - } - fmt.Printf(goformat, args...) - return 0 -} - -func __swbuf(_c int32, _p *FILE) int32 { - return _c -} - -type struct___sFILEX struct{} - -type struct__IO_marker struct{} -type struct__IO_codecvt struct{} -type struct__IO_wide_data struct{} diff --git a/testdata/init/libc_darwin.go b/testdata/init/libc_darwin.go new file mode 100644 index 0000000..df1ef80 --- /dev/null +++ b/testdata/init/libc_darwin.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(format *int8, args ...interface{}) int { + goformat := gostring(format) + for i, arg := range args { + if v, ok := arg.(*int8); ok { + args[i] = gostring(v) + } + } + fmt.Printf(goformat, args...) + return 0 +} + +func __swbuf(_c int32, _p *FILE) int32 { + return _c +} + +type struct___sFILEX struct{} + +type struct__IO_marker struct{} +type struct__IO_codecvt struct{} +type struct__IO_wide_data struct{} diff --git a/testdata/init/libc_windows.go b/testdata/init/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/init/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/libc/libc.go b/testdata/libc/libc_darwin.go similarity index 100% rename from testdata/libc/libc.go rename to testdata/libc/libc_darwin.go diff --git a/testdata/libc/libc_windows.go b/testdata/libc/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/libc/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/operator/libc.go b/testdata/operator/libc_darwin.go similarity index 100% rename from testdata/operator/libc.go rename to testdata/operator/libc_darwin.go diff --git a/testdata/operator/libc_windows.go b/testdata/operator/libc_windows.go new file mode 100644 index 0000000..bb62c7f --- /dev/null +++ b/testdata/operator/libc_windows.go @@ -0,0 +1,79 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func strnlen(_Str *int8, _MaxCount uint64) uint64 { + panic("notimpl") +} +func wcsnlen(_Src *uint16, _MaxCount uint64) uint64 { + panic("notimpl") +} diff --git a/testdata/printf/libc.go b/testdata/printf/libc_darwin.go similarity index 100% rename from testdata/printf/libc.go rename to testdata/printf/libc_darwin.go diff --git a/testdata/printf/libc_windows.go b/testdata/printf/libc_windows.go new file mode 100644 index 0000000..8d94e7f --- /dev/null +++ b/testdata/printf/libc_windows.go @@ -0,0 +1,87 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func C(s string) *int8 { + n := len(s) + ret := make([]byte, n+1) + copy(ret, s) + ret[n] = '\x00' + return (*int8)(unsafe.Pointer(&ret[0])) +} + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func strnlen(_Str *int8, _MaxCount uint64) uint64 { + panic("notimpl") +} +func wcsnlen(_Src *uint16, _MaxCount uint64) uint64 { + panic("notimpl") +} diff --git a/testdata/printf/main.go b/testdata/printf/main.go index 42ce3d3..de19879 100644 --- a/testdata/printf/main.go +++ b/testdata/printf/main.go @@ -1,5 +1,5 @@ package main func main() { - printf(C("Hello, world\n")) + _printf(C("Hello, world\n")) } diff --git a/testdata/printf/printf.c b/testdata/printf/printf.c index cebfe40..f86008a 100644 --- a/testdata/printf/printf.c +++ b/testdata/printf/printf.c @@ -1,7 +1,7 @@ #include #include -int printf(const char *restrict fmt, ...) +int _printf(const char *restrict fmt, ...) { int ret; va_list ap; diff --git a/testdata/strlen/libc.go b/testdata/strlen/libc_darwin.go similarity index 100% rename from testdata/strlen/libc.go rename to testdata/strlen/libc_darwin.go diff --git a/testdata/strlen/libc_windows.go b/testdata/strlen/libc_windows.go new file mode 100644 index 0000000..a83c10d --- /dev/null +++ b/testdata/strlen/libc_windows.go @@ -0,0 +1,47 @@ +package main + +import ( + "fmt" + "unsafe" +) + +func C(s string) *int8 { + n := len(s) + ret := make([]byte, n+1) + copy(ret, s) + ret[n] = '\x00' + return (*int8)(unsafe.Pointer(&ret[0])) +} + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(format *int8, args ...interface{}) int32 { + goformat := gostring(format) + for i, arg := range args { + if v, ok := arg.(*int8); ok { + args[i] = gostring(v) + } + } + fmt.Printf(goformat, args...) + return 0 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func strnlen(_Str *int8, _MaxCount uint64) uint64 { + panic("notimpl") +} +func wcsnlen(_Src *uint16, _MaxCount uint64) uint64 { + panic("notimpl") +} diff --git a/testdata/struct/libc.go b/testdata/struct/libc.go deleted file mode 100644 index ffbce4a..0000000 --- a/testdata/struct/libc.go +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - "fmt" - "unsafe" -) - -func gostring(s *int8) string { - n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) - for arr[n] != 0 { - n++ - } - return string(arr[:n]) -} - -func printf(format *int8, args ...interface{}) int32 { - goformat := gostring(format) - for i, arg := range args { - if v, ok := arg.(*int8); ok { - args[i] = gostring(v) - } - } - fmt.Printf(goformat, args...) - return 0 -} - -func __swbuf(_c int32, _p *FILE) int32 { - return _c -} - -type struct___sFILEX struct{} - -type struct__IO_marker struct{} -type struct__IO_codecvt struct{} -type struct__IO_wide_data struct{} diff --git a/testdata/struct/libc_darwin.go b/testdata/struct/libc_darwin.go new file mode 100644 index 0000000..df1ef80 --- /dev/null +++ b/testdata/struct/libc_darwin.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(format *int8, args ...interface{}) int { + goformat := gostring(format) + for i, arg := range args { + if v, ok := arg.(*int8); ok { + args[i] = gostring(v) + } + } + fmt.Printf(goformat, args...) + return 0 +} + +func __swbuf(_c int32, _p *FILE) int32 { + return _c +} + +type struct___sFILEX struct{} + +type struct__IO_marker struct{} +type struct__IO_codecvt struct{} +type struct__IO_wide_data struct{} diff --git a/testdata/struct/libc_windows.go b/testdata/struct/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/struct/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/switch/libc.go b/testdata/switch/libc.go deleted file mode 100644 index ffbce4a..0000000 --- a/testdata/switch/libc.go +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - "fmt" - "unsafe" -) - -func gostring(s *int8) string { - n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) - for arr[n] != 0 { - n++ - } - return string(arr[:n]) -} - -func printf(format *int8, args ...interface{}) int32 { - goformat := gostring(format) - for i, arg := range args { - if v, ok := arg.(*int8); ok { - args[i] = gostring(v) - } - } - fmt.Printf(goformat, args...) - return 0 -} - -func __swbuf(_c int32, _p *FILE) int32 { - return _c -} - -type struct___sFILEX struct{} - -type struct__IO_marker struct{} -type struct__IO_codecvt struct{} -type struct__IO_wide_data struct{} diff --git a/testdata/switch/libc_darwin.go b/testdata/switch/libc_darwin.go new file mode 100644 index 0000000..df1ef80 --- /dev/null +++ b/testdata/switch/libc_darwin.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(format *int8, args ...interface{}) int { + goformat := gostring(format) + for i, arg := range args { + if v, ok := arg.(*int8); ok { + args[i] = gostring(v) + } + } + fmt.Printf(goformat, args...) + return 0 +} + +func __swbuf(_c int32, _p *FILE) int32 { + return _c +} + +type struct___sFILEX struct{} + +type struct__IO_marker struct{} +type struct__IO_codecvt struct{} +type struct__IO_wide_data struct{} diff --git a/testdata/switch/libc_windows.go b/testdata/switch/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/switch/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/typecast/libc.go b/testdata/typecast/libc.go deleted file mode 100644 index ffbce4a..0000000 --- a/testdata/typecast/libc.go +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - "fmt" - "unsafe" -) - -func gostring(s *int8) string { - n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) - for arr[n] != 0 { - n++ - } - return string(arr[:n]) -} - -func printf(format *int8, args ...interface{}) int32 { - goformat := gostring(format) - for i, arg := range args { - if v, ok := arg.(*int8); ok { - args[i] = gostring(v) - } - } - fmt.Printf(goformat, args...) - return 0 -} - -func __swbuf(_c int32, _p *FILE) int32 { - return _c -} - -type struct___sFILEX struct{} - -type struct__IO_marker struct{} -type struct__IO_codecvt struct{} -type struct__IO_wide_data struct{} diff --git a/testdata/typecast/libc_darwin.go b/testdata/typecast/libc_darwin.go new file mode 100644 index 0000000..df1ef80 --- /dev/null +++ b/testdata/typecast/libc_darwin.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(format *int8, args ...interface{}) int { + goformat := gostring(format) + for i, arg := range args { + if v, ok := arg.(*int8); ok { + args[i] = gostring(v) + } + } + fmt.Printf(goformat, args...) + return 0 +} + +func __swbuf(_c int32, _p *FILE) int32 { + return _c +} + +type struct___sFILEX struct{} + +type struct__IO_marker struct{} +type struct__IO_codecvt struct{} +type struct__IO_wide_data struct{} diff --git a/testdata/typecast/libc_windows.go b/testdata/typecast/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/typecast/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/union/libc.go b/testdata/union/libc.go deleted file mode 100644 index ffbce4a..0000000 --- a/testdata/union/libc.go +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - "fmt" - "unsafe" -) - -func gostring(s *int8) string { - n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) - for arr[n] != 0 { - n++ - } - return string(arr[:n]) -} - -func printf(format *int8, args ...interface{}) int32 { - goformat := gostring(format) - for i, arg := range args { - if v, ok := arg.(*int8); ok { - args[i] = gostring(v) - } - } - fmt.Printf(goformat, args...) - return 0 -} - -func __swbuf(_c int32, _p *FILE) int32 { - return _c -} - -type struct___sFILEX struct{} - -type struct__IO_marker struct{} -type struct__IO_codecvt struct{} -type struct__IO_wide_data struct{} diff --git a/testdata/union/libc_darwin.go b/testdata/union/libc_darwin.go new file mode 100644 index 0000000..df1ef80 --- /dev/null +++ b/testdata/union/libc_darwin.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(format *int8, args ...interface{}) int { + goformat := gostring(format) + for i, arg := range args { + if v, ok := arg.(*int8); ok { + args[i] = gostring(v) + } + } + fmt.Printf(goformat, args...) + return 0 +} + +func __swbuf(_c int32, _p *FILE) int32 { + return _c +} + +type struct___sFILEX struct{} + +type struct__IO_marker struct{} +type struct__IO_codecvt struct{} +type struct__IO_wide_data struct{} diff --git a/testdata/union/libc_windows.go b/testdata/union/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/union/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/vaexpr/libc.go b/testdata/vaexpr/libc_darwin.go similarity index 92% rename from testdata/vaexpr/libc.go rename to testdata/vaexpr/libc_darwin.go index b542d67..a06bc6a 100644 --- a/testdata/vaexpr/libc.go +++ b/testdata/vaexpr/libc_darwin.go @@ -21,7 +21,7 @@ func gostring(s *int8) string { return string(arr[:n]) } -func printf(format *int8, args ...interface{}) int32 { +func printf(format *int8, args ...interface{}) int { goformat := gostring(format) for i, arg := range args { if v, ok := arg.(*int8); ok { diff --git a/testdata/vaexpr/libc_windows.go b/testdata/vaexpr/libc_windows.go new file mode 100644 index 0000000..44a70fb --- /dev/null +++ b/testdata/vaexpr/libc_windows.go @@ -0,0 +1,81 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func C(s string) *int8 { + n := len(s) + ret := make([]byte, n+1) + copy(ret, s) + ret[n] = '\x00' + return (*int8)(unsafe.Pointer(&ret[0])) +} + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} diff --git a/testdata/vappendf/libc.go b/testdata/vappendf/libc_darwin.go similarity index 100% rename from testdata/vappendf/libc.go rename to testdata/vappendf/libc_darwin.go diff --git a/testdata/vappendf/libc_windows.go b/testdata/vappendf/libc_windows.go new file mode 100644 index 0000000..0b2a94f --- /dev/null +++ b/testdata/vappendf/libc_windows.go @@ -0,0 +1,26 @@ +package main + +import unsafe "unsafe" + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __builtin___memcpy_chk(unsafe.Pointer, unsafe.Pointer, uint64, uint64) unsafe.Pointer { + panic("notimpl") +} +func __builtin_object_size(unsafe.Pointer, int32) uint64 { + panic("notimpl") +} +func strlen(_Str *int8) uint64 { + panic("notimpl") +} +func strnlen(_Str *int8, _MaxCount uint64) uint64 { + panic("notimpl") +} +func wcsnlen(_Src *uint16, _MaxCount uint64) uint64 { + panic("notimpl") +} diff --git a/testdata/xdigits/libc.go b/testdata/xdigits/libc.go deleted file mode 100644 index ffbce4a..0000000 --- a/testdata/xdigits/libc.go +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - "fmt" - "unsafe" -) - -func gostring(s *int8) string { - n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) - for arr[n] != 0 { - n++ - } - return string(arr[:n]) -} - -func printf(format *int8, args ...interface{}) int32 { - goformat := gostring(format) - for i, arg := range args { - if v, ok := arg.(*int8); ok { - args[i] = gostring(v) - } - } - fmt.Printf(goformat, args...) - return 0 -} - -func __swbuf(_c int32, _p *FILE) int32 { - return _c -} - -type struct___sFILEX struct{} - -type struct__IO_marker struct{} -type struct__IO_codecvt struct{} -type struct__IO_wide_data struct{} diff --git a/testdata/xdigits/libc_darwin.go b/testdata/xdigits/libc_darwin.go new file mode 100644 index 0000000..df1ef80 --- /dev/null +++ b/testdata/xdigits/libc_darwin.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(format *int8, args ...interface{}) int { + goformat := gostring(format) + for i, arg := range args { + if v, ok := arg.(*int8); ok { + args[i] = gostring(v) + } + } + fmt.Printf(goformat, args...) + return 0 +} + +func __swbuf(_c int32, _p *FILE) int32 { + return _c +} + +type struct___sFILEX struct{} + +type struct__IO_marker struct{} +type struct__IO_codecvt struct{} +type struct__IO_wide_data struct{} diff --git a/testdata/xdigits/libc_windows.go b/testdata/xdigits/libc_windows.go new file mode 100644 index 0000000..cdc87a4 --- /dev/null +++ b/testdata/xdigits/libc_windows.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "strings" + "unsafe" +) + +func gostring(s *int8) string { + n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) + for arr[n] != 0 { + n++ + } + return string(arr[:n]) +} + +func printf(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 +} + +type struct___lc_time_data struct { +} +type struct_lconv struct { +} +type struct_threadmbcinfostruct struct { +} + +func __acrt_iob_func(index uint32) *struct__iobuf { + return nil +} +func __mingw_vfprintf(f *struct__iobuf, format *int8, args []interface { +}) int32 { + return printf(format, args...) +} +func __mingw_vfscanf(fp *struct__iobuf, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwprintf(_File *struct__iobuf, _Format *uint16, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vfwscanf(fp *struct__iobuf, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnprintf(_DstBuf *int8, _MaxCount uint64, _Format *int8, _ArgList []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsnwprintf(*uint16, uint64, *uint16, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsprintf(*int8, *int8, []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vsscanf(_Str *int8, Format *int8, argp []interface { +}) int32 { + panic("notimpl") +} +func __mingw_vswscanf(_Str *uint16, Format *uint16, argp []interface { +}) int32 { + panic("notimpl") +}