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

Commit

Permalink
testdata: libc_darwin/libc_windows
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Nov 18, 2022
1 parent 7ac949d commit c5ac1c7
Show file tree
Hide file tree
Showing 50 changed files with 1,684 additions and 265 deletions.
File renamed without changes.
85 changes: 78 additions & 7 deletions testdata/atomic/libc_windows.go
Original file line number Diff line number Diff line change
@@ -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")
}
8 changes: 4 additions & 4 deletions testdata/bitfield/bitfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
File renamed without changes.
73 changes: 73 additions & 0 deletions testdata/bitfield/libc_windows.go
Original file line number Diff line number Diff line change
@@ -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")
}
File renamed without changes.
81 changes: 81 additions & 0 deletions testdata/complex/libc_windows.go
Original file line number Diff line number Diff line change
@@ -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")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
73 changes: 73 additions & 0 deletions testdata/compoundlit/libc_windows.go
Original file line number Diff line number Diff line change
@@ -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")
}
2 changes: 1 addition & 1 deletion testdata/flow/libc.go → testdata/flow/libc_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit c5ac1c7

Please sign in to comment.