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

c2go: support local type #36

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 15 additions & 15 deletions fma.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ package libc

import unsafe "unsafe"

type struct_num struct {
type num_cgo22_fma struct {
m uint64
e int32
sign int32
}

func normalize_cgo22_fma(x float64) struct_num {
var ix uint64 = *(*uint64)(unsafe.Pointer(&_cgoz_23_fma{x}))
func normalize_cgo23_fma(x float64) num_cgo22_fma {
var ix uint64 = *(*uint64)(unsafe.Pointer(&_cgoz_24_fma{x}))
var e int32 = int32(ix >> int32(52))
var sign int32 = e & int32(2048)
e &= int32(2047)
if !(e != 0) {
ix = *(*uint64)(unsafe.Pointer(&_cgoz_24_fma{x * 9.2233720368547758e+18}))
ix = *(*uint64)(unsafe.Pointer(&_cgoz_25_fma{x * 9.2233720368547758e+18}))
e = int32(ix >> int32(52) & uint64(2047))
e = func() int32 {
if e != 0 {
Expand All @@ -28,17 +28,17 @@ func normalize_cgo22_fma(x float64) struct_num {
ix |= 4503599627370496
ix <<= int32(1)
e -= 1076
return struct_num{ix, e, sign}
return num_cgo22_fma{ix, e, sign}
}

type _cgoz_23_fma struct {
type _cgoz_24_fma struct {
f float64
}
type _cgoz_24_fma struct {
type _cgoz_25_fma struct {
f float64
}

func mul_cgo25_fma(hi *uint64, lo *uint64, x uint64, y uint64) {
func mul_cgo26_fma(hi *uint64, lo *uint64, x uint64, y uint64) {
var t1 uint64
var t2 uint64
var t3 uint64
Expand All @@ -59,12 +59,12 @@ func mul_cgo25_fma(hi *uint64, lo *uint64, x uint64, y uint64) {
}()
}
func Fma(x float64, y float64, z float64) float64 {
var nx struct_num
var ny struct_num
var nz struct_num
nx = normalize_cgo22_fma(x)
ny = normalize_cgo22_fma(y)
nz = normalize_cgo22_fma(z)
var nx num_cgo22_fma
var ny num_cgo22_fma
var nz num_cgo22_fma
nx = normalize_cgo23_fma(x)
ny = normalize_cgo23_fma(y)
nz = normalize_cgo23_fma(z)
if nx.e >= 971 || ny.e >= 971 {
return x*y + z
}
Expand All @@ -78,7 +78,7 @@ func Fma(x float64, y float64, z float64) float64 {
var rlo uint64
var zhi uint64
var zlo uint64
mul_cgo25_fma(&rhi, &rlo, nx.m, ny.m)
mul_cgo26_fma(&rhi, &rlo, nx.m, ny.m)
var e int32 = nx.e + ny.e
var d int32 = nz.e - e
if d > int32(0) {
Expand Down
34 changes: 17 additions & 17 deletions fmemopen.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ package libc

import unsafe "unsafe"

type struct_cookie_1 struct {
type cookie_cgo20_fmemopen struct {
pos uint64
len uint64
size uint64
buf *uint8
mode int32
}
type struct_mem_FILE struct {
type mem_FILE_cgo21_fmemopen struct {
f struct__IO_FILE
c struct_cookie_1
c cookie_cgo20_fmemopen
buf [1032]uint8
buf2 [0]uint8
}

func mseek_cgo20_fmemopen(f *struct__IO_FILE, off int64, whence int32) int64 {
func mseek_cgo22_fmemopen(f *struct__IO_FILE, off int64, whence int32) int64 {

var base int64
var c *struct_cookie_1 = (*struct_cookie_1)(f.cookie)
var c *cookie_cgo20_fmemopen = (*cookie_cgo20_fmemopen)(f.cookie)
if !(uint32(whence) > uint32(2)) {
goto _cgol_1
}
Expand All @@ -39,8 +39,8 @@ _cgol_2:
return *_cgo_addr
}())
}
func mread_cgo21_fmemopen(f *struct__IO_FILE, buf *uint8, len uint64) uint64 {
var c *struct_cookie_1 = (*struct_cookie_1)(f.cookie)
func mread_cgo23_fmemopen(f *struct__IO_FILE, buf *uint8, len uint64) uint64 {
var c *cookie_cgo20_fmemopen = (*cookie_cgo20_fmemopen)(f.cookie)
var rem uint64 = c.len - c.pos
if c.pos > c.len {
rem = uint64(0)
Expand All @@ -61,13 +61,13 @@ func mread_cgo21_fmemopen(f *struct__IO_FILE, buf *uint8, len uint64) uint64 {
c.pos += rem
return len
}
func mwrite_cgo22_fmemopen(f *struct__IO_FILE, buf *uint8, len uint64) uint64 {
var c *struct_cookie_1 = (*struct_cookie_1)(f.cookie)
func mwrite_cgo24_fmemopen(f *struct__IO_FILE, buf *uint8, len uint64) uint64 {
var c *cookie_cgo20_fmemopen = (*cookie_cgo20_fmemopen)(f.cookie)
var rem uint64
var len2 uint64 = uint64(uintptr(unsafe.Pointer(f.wpos)) - uintptr(unsafe.Pointer(f.wbase)))
if len2 != 0 {
f.wpos = f.wbase
if mwrite_cgo22_fmemopen(f, f.wpos, len2) < len2 {
if mwrite_cgo24_fmemopen(f, f.wpos, len2) < len2 {
return uint64(0)
}
}
Expand All @@ -90,11 +90,11 @@ func mwrite_cgo22_fmemopen(f *struct__IO_FILE, buf *uint8, len uint64) uint64 {
}
return len
}
func mclose_cgo23_fmemopen(m *struct__IO_FILE) int32 {
func mclose_cgo25_fmemopen(m *struct__IO_FILE) int32 {
return int32(0)
}
func Fmemopen(buf unsafe.Pointer, size uint64, mode *int8) *struct__IO_FILE {
var f *struct_mem_FILE
var f *mem_FILE_cgo21_fmemopen
var plus int32 = func() int32 {
if !!(Strchr(mode, '+') != nil) {
return 1
Expand All @@ -110,7 +110,7 @@ func Fmemopen(buf unsafe.Pointer, size uint64, mode *int8) *struct__IO_FILE {
*__errno_location() = int32(12)
return (*struct__IO_FILE)(nil)
}
f = (*struct_mem_FILE)(Malloc(1300 + func() uint64 {
f = (*mem_FILE_cgo21_fmemopen)(Malloc(1300 + func() uint64 {
if buf != nil {
return uint64(0)
} else {
Expand Down Expand Up @@ -153,10 +153,10 @@ func Fmemopen(buf unsafe.Pointer, size uint64, mode *int8) *struct__IO_FILE {
} else if plus != 0 {
*f.c.buf = uint8(0)
}
f.f.read = mread_cgo21_fmemopen
f.f.write = mwrite_cgo22_fmemopen
f.f.seek = mseek_cgo20_fmemopen
f.f.close = mclose_cgo23_fmemopen
f.f.read = mread_cgo23_fmemopen
f.f.write = mwrite_cgo24_fmemopen
f.f.seek = mseek_cgo22_fmemopen
f.f.close = mclose_cgo25_fmemopen
if !(__libc.threaded != 0) {
f.f.lock = -1
}
Expand Down
38 changes: 19 additions & 19 deletions fopencookie.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ package libc

import unsafe "unsafe"

type struct_fcookie struct {
type fcookie_cgo18_fopencookie struct {
cookie unsafe.Pointer
iofuncs struct__IO_cookie_io_functions_t
}
type struct_cookie_FILE struct {
type cookie_FILE_cgo19_fopencookie struct {
f struct__IO_FILE
fc struct_fcookie
fc fcookie_cgo18_fopencookie
buf [1032]uint8
}

func cookieread_cgo18_fopencookie(f *struct__IO_FILE, buf *uint8, len uint64) uint64 {
var fc *struct_fcookie = (*struct_fcookie)(f.cookie)
func cookieread_cgo20_fopencookie(f *struct__IO_FILE, buf *uint8, len uint64) uint64 {
var fc *fcookie_cgo18_fopencookie = (*fcookie_cgo18_fopencookie)(f.cookie)
var ret int64 = int64(-1)
var remain uint64 = len
var readlen uint64 = uint64(0)
Expand Down Expand Up @@ -77,16 +77,16 @@ bail:
}()
return readlen
}
func cookiewrite_cgo19_fopencookie(f *struct__IO_FILE, buf *uint8, len uint64) uint64 {
var fc *struct_fcookie = (*struct_fcookie)(f.cookie)
func cookiewrite_cgo21_fopencookie(f *struct__IO_FILE, buf *uint8, len uint64) uint64 {
var fc *fcookie_cgo18_fopencookie = (*fcookie_cgo18_fopencookie)(f.cookie)
var ret int64
var len2 uint64 = uint64(uintptr(unsafe.Pointer(f.wpos)) - uintptr(unsafe.Pointer(f.wbase)))
if !(fc.iofuncs.write != nil) {
return len
}
if len2 != 0 {
f.wpos = f.wbase
if cookiewrite_cgo19_fopencookie(f, f.wpos, len2) < len2 {
if cookiewrite_cgo21_fopencookie(f, f.wpos, len2) < len2 {
return uint64(0)
}
}
Expand All @@ -106,8 +106,8 @@ func cookiewrite_cgo19_fopencookie(f *struct__IO_FILE, buf *uint8, len uint64) u
}
return uint64(ret)
}
func cookieseek_cgo20_fopencookie(f *struct__IO_FILE, off int64, whence int32) int64 {
var fc *struct_fcookie = (*struct_fcookie)(f.cookie)
func cookieseek_cgo22_fopencookie(f *struct__IO_FILE, off int64, whence int32) int64 {
var fc *fcookie_cgo18_fopencookie = (*fcookie_cgo18_fopencookie)(f.cookie)
var res int32
if uint32(whence) > uint32(2) {
*__errno_location() = int32(22)
Expand All @@ -123,22 +123,22 @@ func cookieseek_cgo20_fopencookie(f *struct__IO_FILE, off int64, whence int32) i
}
return off
}
func cookieclose_cgo21_fopencookie(f *struct__IO_FILE) int32 {
var fc *struct_fcookie = (*struct_fcookie)(f.cookie)
func cookieclose_cgo23_fopencookie(f *struct__IO_FILE) int32 {
var fc *fcookie_cgo18_fopencookie = (*fcookie_cgo18_fopencookie)(f.cookie)
if fc.iofuncs.close != nil {
return fc.iofuncs.close(fc.cookie)
}
return int32(0)
}
func Fopencookie(cookie unsafe.Pointer, mode *int8, iofuncs struct__IO_cookie_io_functions_t) *struct__IO_FILE {
var f *struct_cookie_FILE
var f *cookie_FILE_cgo19_fopencookie
if !(Strchr((*int8)(unsafe.Pointer(&[4]int8{'r', 'w', 'a', '\x00'})), int32(*mode)) != nil) {
*__errno_location() = int32(22)
return (*struct__IO_FILE)(nil)
}
if !(func() (_cgo_ret *struct_cookie_FILE) {
if !(func() (_cgo_ret *cookie_FILE_cgo19_fopencookie) {
_cgo_addr := &f
*_cgo_addr = (*struct_cookie_FILE)(Malloc(1304))
*_cgo_addr = (*cookie_FILE_cgo19_fopencookie)(Malloc(1304))
return *_cgo_addr
}() != nil) {
return (*struct__IO_FILE)(nil)
Expand All @@ -160,9 +160,9 @@ func Fopencookie(cookie unsafe.Pointer, mode *int8, iofuncs struct__IO_cookie_io
f.f.buf = (*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer((*uint8)(unsafe.Pointer(&f.buf)))) + uintptr(int32(8))))
f.f.buf_size = 1024
f.f.lbf = -1
f.f.read = cookieread_cgo18_fopencookie
f.f.write = cookiewrite_cgo19_fopencookie
f.f.seek = cookieseek_cgo20_fopencookie
f.f.close = cookieclose_cgo21_fopencookie
f.f.read = cookieread_cgo20_fopencookie
f.f.write = cookiewrite_cgo21_fopencookie
f.f.seek = cookieseek_cgo22_fopencookie
f.f.close = cookieclose_cgo23_fopencookie
return __ofl_add(&f.f)
}