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

Commit

Permalink
autopub mtest.h, test.h
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Jul 16, 2022
1 parent 4cf4bf9 commit b83970c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 25 deletions.
13 changes: 13 additions & 0 deletions test/common/c2go.a.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
estr
rstr
t_choose
t_printf
t_randint
t_randn
t_randrange
t_randseed
t_shuffle
t_status
ulperr
ulperrf
ulperrl
8 changes: 4 additions & 4 deletions test/common/c2go.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
],
"public": {
"from": [
"../src/common/mtest.h",
"../src/common/test.h"
"common/mtest.h",
"common/test.h"
]
},
"target": {
Expand All @@ -15,9 +15,9 @@
},
"source": {
"files": [
"../src/common/rand.c",
"../src/common/mtest.c",
"../src/common/print.c"
"../src/common/print.c",
"../src/common/rand.c"
]
},
"include": [
Expand Down
12 changes: 6 additions & 6 deletions test/common/mtest.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func eulp(x float64) int32 {
func eulpl(x float64) int32 {
return eulp(float64(x))
}
func ulperrf(got float32, want float32, dwant float32) float32 {
func Ulperrf(got float32, want float32, dwant float32) float32 {
if func() int32 {
if 4 == 4 {
return func() int32 {
Expand Down Expand Up @@ -162,7 +162,7 @@ func ulperrf(got float32, want float32, dwant float32) float32 {
}
return float32(libc.Scalbn(float64(got-want), -eulpf(want)) + float64(dwant))
}
func ulperr(got float64, want float64, dwant float32) float32 {
func Ulperr(got float64, want float64, dwant float32) float32 {
if func() int32 {
if 8 == 4 {
return func() int32 {
Expand Down Expand Up @@ -292,8 +292,8 @@ func ulperr(got float64, want float64, dwant float32) float32 {
}
return float32(libc.Scalbn(got-want, -eulp(want)) + float64(dwant))
}
func ulperrl(got float64, want float64, dwant float32) float32 {
return ulperr(float64(got), float64(want), dwant)
func Ulperrl(got float64, want float64, dwant float32) float32 {
return Ulperr(float64(got), float64(want), dwant)
}

type _cgoa_3_mtest struct {
Expand All @@ -303,7 +303,7 @@ type _cgoa_3_mtest struct {

var eflags [5]_cgoa_3_mtest = [5]_cgoa_3_mtest{_cgoa_3_mtest{int32(0), (*int8)(unsafe.Pointer(&[8]int8{'I', 'N', 'E', 'X', 'A', 'C', 'T', '\x00'}))}, _cgoa_3_mtest{int32(0), (*int8)(unsafe.Pointer(&[8]int8{'I', 'N', 'V', 'A', 'L', 'I', 'D', '\x00'}))}, _cgoa_3_mtest{int32(0), (*int8)(unsafe.Pointer(&[10]int8{'D', 'I', 'V', 'B', 'Y', 'Z', 'E', 'R', 'O', '\x00'}))}, _cgoa_3_mtest{int32(0), (*int8)(unsafe.Pointer(&[10]int8{'U', 'N', 'D', 'E', 'R', 'F', 'L', 'O', 'W', '\x00'}))}, _cgoa_3_mtest{int32(0), (*int8)(unsafe.Pointer(&[9]int8{'O', 'V', 'E', 'R', 'F', 'L', 'O', 'W', '\x00'}))}}

func estr(f int32) *int8 {
func Estr(f int32) *int8 {
var p *int8 = (*int8)(unsafe.Pointer(&buf_cgo4_mtest))
var i int32
var all int32 = int32(0)
Expand Down Expand Up @@ -341,7 +341,7 @@ func estr(f int32) *int8 {

var buf_cgo4_mtest [256]int8

func rstr(r int32) *int8 {
func Rstr(r int32) *int8 {
switch r {
case int32(0):
return (*int8)(unsafe.Pointer(&[3]int8{'R', 'N', '\x00'}))
Expand Down
6 changes: 3 additions & 3 deletions test/common/print.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (
unsafe "unsafe"
)

var t_status int32 = int32(0)
var T_status int32 = int32(0)

func t_printf(s *int8, __cgo_args ...interface {
func T_printf(s *int8, __cgo_args ...interface {
}) int32 {
var ap []interface {
}
var buf [512]int8
var n int32
t_status = int32(1)
T_status = int32(1)
ap = __cgo_args
n = libc.Vsnprintf((*int8)(unsafe.Pointer(&buf)), 512, s, ap)
if n < int32(0) {
Expand Down
24 changes: 12 additions & 12 deletions test/common/rand.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ func frandf_cgo5_rand() float32 {
func frandl_cgo6_rand() float64 {
return float64(rand64_cgo3_rand()) * 5.42101086242752217004e-20
}
func t_randseed(s uint64) {
func T_randseed(s uint64) {
seed_cgo1_rand = s
}
func t_randn(n uint64) uint64 {
func T_randn(n uint64) uint64 {
var r uint64
var m uint64
m = uint64(18446744073709551615)
Expand All @@ -40,18 +40,18 @@ func t_randn(n uint64) uint64 {
}
return r % n
}
func t_randint(a uint64, b uint64) uint64 {
func T_randint(a uint64, b uint64) uint64 {
var n uint64 = b - a + uint64(1)
if n != 0 {
return a + t_randn(n)
return a + T_randn(n)
}
return rand64_cgo3_rand()
}
func shuffle2_cgo7_rand(p *uint64, q *uint64, np uint64, nq uint64) {
var r uint64
var t uint64
for np != 0 {
r = uint64(t_randn(uint64(nq + func() (_cgo_ret uint64) {
r = uint64(T_randn(uint64(nq + func() (_cgo_ret uint64) {
_cgo_addr := &np
_cgo_ret = *_cgo_addr
*_cgo_addr--
Expand All @@ -67,15 +67,15 @@ func shuffle2_cgo7_rand(p *uint64, q *uint64, np uint64, nq uint64) {
}
}
}
func t_shuffle(p *uint64, n uint64) {
func T_shuffle(p *uint64, n uint64) {
shuffle2_cgo7_rand(p, nil, n, uint64(0))
}
func t_randrange(p *uint64, n uint64) {
func T_randrange(p *uint64, n uint64) {
var i uint64
for i = uint64(0); i < n; i++ {
*(*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + uintptr(i)*8)) = uint64(i)
}
t_shuffle(p, n)
T_shuffle(p, n)
}
func insert_cgo8_rand(tab *uint64, len uint64, v uint64) int32 {
var i uint64 = uint64(v & uint64(len-uint64(1)))
Expand All @@ -95,7 +95,7 @@ func insert_cgo8_rand(tab *uint64, len uint64, v uint64) int32 {
*(*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(tab)) + uintptr(i)*8)) = v
return int32(0)
}
func t_choose(n uint64, k uint64, p *uint64) int32 {
func T_choose(n uint64, k uint64, p *uint64) int32 {
var tab *uint64
var i uint64
var j uint64
Expand All @@ -105,7 +105,7 @@ func t_choose(n uint64, k uint64, p *uint64) int32 {
}
if n < uint64(16) {
for k != 0 {
if t_randn(func() (_cgo_ret uint64) {
if T_randn(func() (_cgo_ret uint64) {
_cgo_addr := &n
_cgo_ret = *_cgo_addr
*_cgo_addr--
Expand All @@ -122,7 +122,7 @@ func t_choose(n uint64, k uint64, p *uint64) int32 {
}
if k < uint64(8) {
for i = uint64(0); i < k; {
*(*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + uintptr(i)*8)) = t_randn(n)
*(*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + uintptr(i)*8)) = T_randn(n)
for j = uint64(0); *(*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + uintptr(j)*8)) != *(*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + uintptr(i)*8)); j++ {
}
if j == i {
Expand Down Expand Up @@ -157,7 +157,7 @@ func t_choose(n uint64, k uint64, p *uint64) int32 {
return -1
}
for i = uint64(0); i < k; i++ {
for insert_cgo8_rand(tab, len, t_randn(n)+uint64(1)) != 0 {
for insert_cgo8_rand(tab, len, T_randn(n)+uint64(1)) != 0 {
}
}
for i = uint64(0); i < len; i++ {
Expand Down

0 comments on commit b83970c

Please sign in to comment.