|
/* |
|
Package main - transpiled by c2go version: v0.25.9 Dubnium 2018-12-30 |
|
|
|
If you have found any issues, please raise an issue at: |
|
https://github.com/elliotchance/c2go/ |
|
*/ |
|
|
|
// Warning (FieldDecl): /usr/include/_stdio.h:137 : Cannot resolve type 'int ( * _Nullable)(void *)' : Cannot separate function 'int ( * _Nullable)(void *)' : Cannot resolve type 'int ( * _Nullable)' : Cannot separate function 'int ( * _Nullable)' : Cannot resolve type '* _Nullable' : I couldn't find an appropriate Go type for the C type '* _Nullable'. |
|
// Warning (FieldDecl): /usr/include/_stdio.h:138 : Cannot resolve type 'int ( * _Nullable)(void *, char *, int)' : Cannot separate function 'int ( * _Nullable)(void *, char *, int)' : Cannot resolve type 'int ( * _Nullable)' : Cannot separate function 'int ( * _Nullable)' : Cannot resolve type '* _Nullable' : I couldn't find an appropriate Go type for the C type '* _Nullable'. |
|
// Warning (FieldDecl): /usr/include/_stdio.h:139 : Cannot resolve type 'fpos_t ( * _Nullable)(void *, fpos_t, int)' : Cannot separate function 'fpos_t ( * _Nullable)(void *, fpos_t, int)' : Cannot resolve type 'fpos_t ( * _Nullable)' : Cannot separate function 'fpos_t ( * _Nullable)' : Cannot resolve type '* _Nullable' : I couldn't find an appropriate Go type for the C type '* _Nullable'. |
|
// Warning (FieldDecl): /usr/include/_stdio.h:140 : Cannot resolve type 'int ( * _Nullable)(void *, char *, int)' : Cannot separate function 'int ( * _Nullable)(void *, char *, int)' : Cannot resolve type 'int ( * _Nullable)' : Cannot separate function 'int ( * _Nullable)' : Cannot resolve type '* _Nullable' : I couldn't find an appropriate Go type for the C type '* _Nullable'. |
|
// Warning (FieldDecl): /usr/include/mach/i386/_structs.h:94 : Error : name of FieldDecl is empty |
|
|
|
package main |
|
|
|
import "os" |
|
import "github.com/elliotchance/c2go/noarch" |
|
import "unsafe" |
|
import "github.com/elliotchance/c2go/darwin" |
|
|
|
type __int8_t int8 |
|
type __uint8_t uint8 |
|
type __int16_t int16 |
|
type __uint16_t uint16 |
|
type __int32_t int32 |
|
type __uint32_t uint32 |
|
type __int64_t int64 |
|
type __uint64_t uint64 |
|
type __darwin_intptr_t int32 |
|
type __darwin_natural_t uint32 |
|
type __darwin_ct_rune_t darwin.CtRuneT |
|
type __mbstate_t struct{ memory unsafe.Pointer } |
|
|
|
func (unionVar *__mbstate_t) copy() __mbstate_t { |
|
var buffer [128]byte |
|
for i := range buffer { |
|
buffer[i] = (*((*[128]byte)(unionVar.memory)))[i] |
|
} |
|
var newUnion __mbstate_t |
|
newUnion.memory = unsafe.Pointer(&buffer) |
|
return newUnion |
|
} |
|
func (unionVar *__mbstate_t) __mbstate8() *[128]byte { |
|
if unionVar.memory == nil { |
|
var buffer [128]byte |
|
unionVar.memory = unsafe.Pointer(&buffer) |
|
} |
|
return (*[128]byte)(unionVar.memory) |
|
} |
|
func (unionVar *__mbstate_t) _mbstateL() *int64 { |
|
if unionVar.memory == nil { |
|
var buffer [128]byte |
|
unionVar.memory = unsafe.Pointer(&buffer) |
|
} |
|
return (*int64)(unionVar.memory) |
|
} |
|
|
|
type __darwin_mbstate_t int64 |
|
type __darwin_ptrdiff_t int32 |
|
type __darwin_size_t uint32 |
|
type __darwin_va_list int64 |
|
type __darwin_wchar_t int32 |
|
type __darwin_rune_t __darwin_wchar_t |
|
type __darwin_wint_t int32 |
|
type __darwin_clock_t uint32 |
|
type __darwin_socklen_t uint32 |
|
type __darwin_ssize_t int32 |
|
type __darwin_time_t int32 |
|
type __darwin_blkcnt_t int64 |
|
type __darwin_blksize_t int32 |
|
type __darwin_dev_t int32 |
|
type __darwin_fsblkcnt_t uint32 |
|
type __darwin_fsfilcnt_t uint32 |
|
type __darwin_gid_t uint32 |
|
type __darwin_id_t uint32 |
|
type __darwin_ino64_t uint64 |
|
type __darwin_ino_t __darwin_ino64_t |
|
type __darwin_mach_port_name_t __darwin_natural_t |
|
type __darwin_mach_port_t __darwin_mach_port_name_t |
|
type __darwin_mode_t uint16 |
|
type __darwin_off_t int64 |
|
type __darwin_pid_t int32 |
|
type __darwin_sigset_t uint32 |
|
type __darwin_suseconds_t int32 |
|
type __darwin_uid_t uint32 |
|
type __darwin_useconds_t uint32 |
|
type __darwin_uuid_t []uint8 |
|
type __darwin_uuid_string_t []byte |
|
type __darwin_pthread_handler_rec struct { |
|
__routine func(unsafe.Pointer) |
|
__arg unsafe.Pointer |
|
__next *int64 |
|
} |
|
type _opaque_pthread_attr_t struct { |
|
__sig int32 |
|
__opaque [56]byte |
|
} |
|
type _opaque_pthread_cond_t struct { |
|
__sig int32 |
|
__opaque [40]byte |
|
} |
|
type _opaque_pthread_condattr_t struct { |
|
__sig int32 |
|
__opaque [8]byte |
|
} |
|
type _opaque_pthread_mutex_t struct { |
|
__sig int32 |
|
__opaque [56]byte |
|
} |
|
type _opaque_pthread_mutexattr_t struct { |
|
__sig int32 |
|
__opaque [8]byte |
|
} |
|
type _opaque_pthread_once_t struct { |
|
__sig int32 |
|
__opaque [8]byte |
|
} |
|
type _opaque_pthread_rwlock_t struct { |
|
__sig int32 |
|
__opaque [192]byte |
|
} |
|
type _opaque_pthread_rwlockattr_t struct { |
|
__sig int32 |
|
__opaque [16]byte |
|
} |
|
type _opaque_pthread_t struct { |
|
__sig int32 |
|
__cleanup_stack *int64 |
|
__opaque [8176]byte |
|
} |
|
type __darwin_pthread_attr_t _opaque_pthread_attr_t |
|
type __darwin_pthread_cond_t _opaque_pthread_cond_t |
|
type __darwin_pthread_condattr_t _opaque_pthread_condattr_t |
|
type __darwin_pthread_key_t uint32 |
|
type __darwin_pthread_mutex_t _opaque_pthread_mutex_t |
|
type __darwin_pthread_mutexattr_t _opaque_pthread_mutexattr_t |
|
type __darwin_pthread_once_t _opaque_pthread_once_t |
|
type __darwin_pthread_rwlock_t _opaque_pthread_rwlock_t |
|
type __darwin_pthread_rwlockattr_t _opaque_pthread_rwlockattr_t |
|
type __darwin_pthread_t *_opaque_pthread_t |
|
type __darwin_nl_item int32 |
|
type __darwin_wctrans_t int32 |
|
type __darwin_wctype_t uint32 |
|
type int8_t int8 |
|
type int16_t int16 |
|
type int32_t int32 |
|
type int64_t int64 |
|
type u_int8_t uint8 |
|
type u_int16_t uint16 |
|
type u_int32_t uint32 |
|
type u_int64_t uint64 |
|
type register_t int64 |
|
type intptr_t __darwin_intptr_t |
|
type uintptr_t uint32 |
|
type user_addr_t uint64 |
|
type user_size_t uint64 |
|
type user_ssize_t int64 |
|
type user_long_t int64 |
|
type user_ulong_t uint64 |
|
type user_time_t int64 |
|
type user_off_t int64 |
|
type syscall_arg_t uint64 |
|
type va_list __darwin_va_list |
|
type size_t __darwin_size_t |
|
type fpos_t __darwin_off_t |
|
type __sbuf struct { |
|
_base *uint8 |
|
_size int32 |
|
} |
|
type __sFILEX struct { |
|
} |
|
type __sFILE struct { |
|
_p *uint8 |
|
_r int32 |
|
_w int32 |
|
_flags int16 |
|
_file int16 |
|
_bf int64 |
|
_lbfsize int32 |
|
_cookie unsafe.Pointer |
|
_close func(unsafe.Pointer) |
|
_read func(unsafe.Pointer, *byte, int32) |
|
_seek func(unsafe.Pointer, int32, int32) |
|
_write func(unsafe.Pointer, *byte, int32) |
|
_ub int64 |
|
_extra *unsafe.Pointer |
|
_ur int32 |
|
_ubuf [3]uint8 |
|
_nbuf [1]uint8 |
|
_lb int64 |
|
_blksize int32 |
|
_offset int32 |
|
} |
|
type FILE __sFILE |
|
|
|
var // Warning (FieldDecl): /usr/include/_stdio.h:137 : Cannot resolve type 'int ( * _Nullable)(void *)' : Cannot separate function 'int ( * _Nullable)(void *)' : Cannot resolve type 'int ( * _Nullable)' : Cannot separate function 'int ( * _Nullable)' : Cannot resolve type '* _Nullable' : I couldn't find an appropriate Go type for the C type '* _Nullable'. |
|
// Warning (FieldDecl): /usr/include/_stdio.h:138 : Cannot resolve type 'int ( * _Nullable)(void *, char *, int)' : Cannot separate function 'int ( * _Nullable)(void *, char *, int)' : Cannot resolve type 'int ( * _Nullable)' : Cannot separate function 'int ( * _Nullable)' : Cannot resolve type '* _Nullable' : I couldn't find an appropriate Go type for the C type '* _Nullable'. |
|
// Warning (FieldDecl): /usr/include/_stdio.h:139 : Cannot resolve type 'fpos_t ( * _Nullable)(void *, fpos_t, int)' : Cannot separate function 'fpos_t ( * _Nullable)(void *, fpos_t, int)' : Cannot resolve type 'fpos_t ( * _Nullable)' : Cannot separate function 'fpos_t ( * _Nullable)' : Cannot resolve type '* _Nullable' : I couldn't find an appropriate Go type for the C type '* _Nullable'. |
|
// Warning (FieldDecl): /usr/include/_stdio.h:140 : Cannot resolve type 'int ( * _Nullable)(void *, char *, int)' : Cannot separate function 'int ( * _Nullable)(void *, char *, int)' : Cannot resolve type 'int ( * _Nullable)' : Cannot separate function 'int ( * _Nullable)' : Cannot resolve type '* _Nullable' : I couldn't find an appropriate Go type for the C type '* _Nullable'. |
|
__stdinp *noarch.File |
|
var __stdoutp *noarch.File |
|
|
|
type off_t __darwin_off_t |
|
type ssize_t __darwin_ssize_t |
|
type float_t float32 |
|
type double_t float64 |
|
|
|
// __inline_isfinitef - transpiled function from /usr/include/math.h:204 |
|
func __inline_isfinitef(__x float32) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(__x == __x && darwin.Fabsf(__x) != darwin.Inff()) |
|
} |
|
|
|
// __inline_isfinited - transpiled function from /usr/include/math.h:207 |
|
func __inline_isfinited(__x float64) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(__x == __x && darwin.Fabs(__x) != darwin.Inf()) |
|
} |
|
|
|
// __inline_isfinitel - transpiled function from /usr/include/math.h:210 |
|
func __inline_isfinitel(__x float64) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(__x == __x && darwin.Fabsl(__x) != darwin.Infl()) |
|
} |
|
|
|
// __inline_isinff - transpiled function from /usr/include/math.h:213 |
|
func __inline_isinff(__x float32) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(darwin.Fabsf(__x) == darwin.Inff()) |
|
} |
|
|
|
// __inline_isinfd - transpiled function from /usr/include/math.h:216 |
|
func __inline_isinfd(__x float64) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(darwin.Fabs(__x) == darwin.Inf()) |
|
} |
|
|
|
// __inline_isinfl - transpiled function from /usr/include/math.h:219 |
|
func __inline_isinfl(__x float64) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(darwin.Fabsl(__x) == darwin.Infl()) |
|
} |
|
|
|
// __inline_isnanf - transpiled function from /usr/include/math.h:222 |
|
func __inline_isnanf(__x float32) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(__x != __x) |
|
} |
|
|
|
// __inline_isnand - transpiled function from /usr/include/math.h:225 |
|
func __inline_isnand(__x float64) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(__x != __x) |
|
} |
|
|
|
// __inline_isnanl - transpiled function from /usr/include/math.h:228 |
|
func __inline_isnanl(__x float64) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(__x != __x) |
|
} |
|
|
|
// __inline_isnormalf - transpiled function from /usr/include/math.h:257 |
|
func __inline_isnormalf(__x float32) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(__inline_isfinitef(__x) != 0 && darwin.Fabsf(__x) >= float32(1.17549435e-38)) |
|
} |
|
|
|
// __inline_isnormald - transpiled function from /usr/include/math.h:260 |
|
func __inline_isnormald(__x float64) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(__inline_isfinited(__x) != 0 && darwin.Fabs(__x) >= 2.2250738585072014e-308) |
|
} |
|
|
|
// __inline_isnormall - transpiled function from /usr/include/math.h:263 |
|
func __inline_isnormall(__x float64) int32 { |
|
return func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(__inline_isfinitel(__x) != 0 && darwin.Fabsl(__x) >= 0) |
|
} |
|
|
|
type __float2 struct { |
|
__sinval float32 |
|
__cosval float32 |
|
} |
|
type __double2 struct { |
|
__sinval float64 |
|
__cosval float64 |
|
} |
|
|
|
// __sincosf - transpiled function from /usr/include/math.h:661 |
|
func __sincosf(__x float32, __sinp *float32, __cosp *float32) { |
|
var __stret darwin.Float2 = darwin.SincosfStret(__x) |
|
*__sinp = __stret.Sinval |
|
*__cosp = __stret.Cosval |
|
} |
|
|
|
// __sincos - transpiled function from /usr/include/math.h:666 |
|
func __sincos(__x float64, __sinp *float64, __cosp *float64) { |
|
var __stret darwin.Double2 = darwin.SincosStret(__x) |
|
*__sinp = __stret.Sinval |
|
*__cosp = __stret.Cosval |
|
} |
|
|
|
// __sincospif - transpiled function from /usr/include/math.h:671 |
|
func __sincospif(__x float32, __sinp *float32, __cosp *float32) { |
|
var __stret darwin.Float2 = darwin.SincospifStret(__x) |
|
*__sinp = __stret.Sinval |
|
*__cosp = __stret.Cosval |
|
} |
|
|
|
// __sincospi - transpiled function from /usr/include/math.h:676 |
|
func __sincospi(__x float64, __sinp *float64, __cosp *float64) { |
|
var __stret darwin.Double2 = darwin.SincospiStret(__x) |
|
*__sinp = __stret.Sinval |
|
*__cosp = __stret.Cosval |
|
} |
|
|
|
type exception struct { |
|
type_ int32 |
|
name *byte |
|
arg1 float64 |
|
arg2 float64 |
|
retval float64 |
|
} |
|
type rsize_t __darwin_size_t |
|
type errno_t int32 |
|
|
|
const P_ALL int32 = 0 |
|
const P_PID int32 = 1 |
|
const P_PGID int32 = 2 |
|
|
|
type idtype_t int32 |
|
type pid_t __darwin_pid_t |
|
type id_t __darwin_id_t |
|
type sig_atomic_t int32 |
|
type __darwin_i386_thread_state struct { |
|
__eax uint32 |
|
__ebx uint32 |
|
__ecx uint32 |
|
__edx uint32 |
|
__edi uint32 |
|
__esi uint32 |
|
__ebp uint32 |
|
__esp uint32 |
|
__ss uint32 |
|
__eflags uint32 |
|
__eip uint32 |
|
__cs uint32 |
|
__ds uint32 |
|
__es uint32 |
|
__fs uint32 |
|
__gs uint32 |
|
} |
|
type __darwin_fp_control struct { |
|
__invalid uint16 |
|
__denorm uint16 |
|
__zdiv uint16 |
|
__ovrfl uint16 |
|
__undfl uint16 |
|
__precis uint16 |
|
__pc uint16 |
|
__rc uint16 |
|
} |
|
type __darwin_fp_control_t __darwin_fp_control |
|
type __darwin_fp_status struct { |
|
__invalid uint16 |
|
__denorm uint16 |
|
__zdiv uint16 |
|
__ovrfl uint16 |
|
__undfl uint16 |
|
__precis uint16 |
|
__stkflt uint16 |
|
__errsumm uint16 |
|
__c0 uint16 |
|
__c1 uint16 |
|
__c2 uint16 |
|
__tos uint16 |
|
__c3 uint16 |
|
__busy uint16 |
|
} |
|
type __darwin_fp_status_t __darwin_fp_status |
|
type __darwin_mmst_reg struct { |
|
__mmst_reg [10]byte |
|
__mmst_rsrv [6]byte |
|
} |
|
type __darwin_xmm_reg struct { |
|
__xmm_reg [16]byte |
|
} |
|
type __darwin_ymm_reg struct { |
|
__ymm_reg [32]byte |
|
} |
|
type __darwin_zmm_reg struct { |
|
__zmm_reg [64]byte |
|
} |
|
type __darwin_opmask_reg struct { |
|
__opmask_reg [8]byte |
|
} |
|
type __darwin_i386_float_state struct { |
|
__fpu_reserved [2]int32 |
|
__fpu_fcw __darwin_fp_control |
|
__fpu_fsw __darwin_fp_status |
|
__fpu_ftw uint8 |
|
__fpu_rsrv1 uint8 |
|
__fpu_fop uint16 |
|
__fpu_ip uint32 |
|
__fpu_cs uint16 |
|
__fpu_rsrv2 uint16 |
|
__fpu_dp uint32 |
|
__fpu_ds uint16 |
|
__fpu_rsrv3 uint16 |
|
__fpu_mxcsr uint32 |
|
__fpu_mxcsrmask uint32 |
|
__fpu_stmm0 __darwin_mmst_reg |
|
__fpu_stmm1 __darwin_mmst_reg |
|
__fpu_stmm2 __darwin_mmst_reg |
|
__fpu_stmm3 __darwin_mmst_reg |
|
__fpu_stmm4 __darwin_mmst_reg |
|
__fpu_stmm5 __darwin_mmst_reg |
|
__fpu_stmm6 __darwin_mmst_reg |
|
__fpu_stmm7 __darwin_mmst_reg |
|
__fpu_xmm0 __darwin_xmm_reg |
|
__fpu_xmm1 __darwin_xmm_reg |
|
__fpu_xmm2 __darwin_xmm_reg |
|
__fpu_xmm3 __darwin_xmm_reg |
|
__fpu_xmm4 __darwin_xmm_reg |
|
__fpu_xmm5 __darwin_xmm_reg |
|
__fpu_xmm6 __darwin_xmm_reg |
|
__fpu_xmm7 __darwin_xmm_reg |
|
__fpu_rsrv4 [224]byte |
|
__fpu_reserved1 int32 |
|
} |
|
type __darwin_i386_avx_state struct { |
|
__fpu_reserved [2]int32 |
|
__fpu_fcw __darwin_fp_control |
|
__fpu_fsw __darwin_fp_status |
|
__fpu_ftw uint8 |
|
__fpu_rsrv1 uint8 |
|
__fpu_fop uint16 |
|
__fpu_ip uint32 |
|
__fpu_cs uint16 |
|
__fpu_rsrv2 uint16 |
|
__fpu_dp uint32 |
|
__fpu_ds uint16 |
|
__fpu_rsrv3 uint16 |
|
__fpu_mxcsr uint32 |
|
__fpu_mxcsrmask uint32 |
|
__fpu_stmm0 __darwin_mmst_reg |
|
__fpu_stmm1 __darwin_mmst_reg |
|
__fpu_stmm2 __darwin_mmst_reg |
|
__fpu_stmm3 __darwin_mmst_reg |
|
__fpu_stmm4 __darwin_mmst_reg |
|
__fpu_stmm5 __darwin_mmst_reg |
|
__fpu_stmm6 __darwin_mmst_reg |
|
__fpu_stmm7 __darwin_mmst_reg |
|
__fpu_xmm0 __darwin_xmm_reg |
|
__fpu_xmm1 __darwin_xmm_reg |
|
__fpu_xmm2 __darwin_xmm_reg |
|
__fpu_xmm3 __darwin_xmm_reg |
|
__fpu_xmm4 __darwin_xmm_reg |
|
__fpu_xmm5 __darwin_xmm_reg |
|
__fpu_xmm6 __darwin_xmm_reg |
|
__fpu_xmm7 __darwin_xmm_reg |
|
__fpu_rsrv4 [224]byte |
|
__fpu_reserved1 int32 |
|
__avx_reserved1 [64]byte |
|
__fpu_ymmh0 __darwin_xmm_reg |
|
__fpu_ymmh1 __darwin_xmm_reg |
|
__fpu_ymmh2 __darwin_xmm_reg |
|
__fpu_ymmh3 __darwin_xmm_reg |
|
__fpu_ymmh4 __darwin_xmm_reg |
|
__fpu_ymmh5 __darwin_xmm_reg |
|
__fpu_ymmh6 __darwin_xmm_reg |
|
__fpu_ymmh7 __darwin_xmm_reg |
|
} |
|
type __darwin_i386_avx512_state struct { |
|
__fpu_reserved [2]int32 |
|
__fpu_fcw __darwin_fp_control |
|
__fpu_fsw __darwin_fp_status |
|
__fpu_ftw uint8 |
|
__fpu_rsrv1 uint8 |
|
__fpu_fop uint16 |
|
__fpu_ip uint32 |
|
__fpu_cs uint16 |
|
__fpu_rsrv2 uint16 |
|
__fpu_dp uint32 |
|
__fpu_ds uint16 |
|
__fpu_rsrv3 uint16 |
|
__fpu_mxcsr uint32 |
|
__fpu_mxcsrmask uint32 |
|
__fpu_stmm0 __darwin_mmst_reg |
|
__fpu_stmm1 __darwin_mmst_reg |
|
__fpu_stmm2 __darwin_mmst_reg |
|
__fpu_stmm3 __darwin_mmst_reg |
|
__fpu_stmm4 __darwin_mmst_reg |
|
__fpu_stmm5 __darwin_mmst_reg |
|
__fpu_stmm6 __darwin_mmst_reg |
|
__fpu_stmm7 __darwin_mmst_reg |
|
__fpu_xmm0 __darwin_xmm_reg |
|
__fpu_xmm1 __darwin_xmm_reg |
|
__fpu_xmm2 __darwin_xmm_reg |
|
__fpu_xmm3 __darwin_xmm_reg |
|
__fpu_xmm4 __darwin_xmm_reg |
|
__fpu_xmm5 __darwin_xmm_reg |
|
__fpu_xmm6 __darwin_xmm_reg |
|
__fpu_xmm7 __darwin_xmm_reg |
|
__fpu_rsrv4 [224]byte |
|
__fpu_reserved1 int32 |
|
__avx_reserved1 [64]byte |
|
__fpu_ymmh0 __darwin_xmm_reg |
|
__fpu_ymmh1 __darwin_xmm_reg |
|
__fpu_ymmh2 __darwin_xmm_reg |
|
__fpu_ymmh3 __darwin_xmm_reg |
|
__fpu_ymmh4 __darwin_xmm_reg |
|
__fpu_ymmh5 __darwin_xmm_reg |
|
__fpu_ymmh6 __darwin_xmm_reg |
|
__fpu_ymmh7 __darwin_xmm_reg |
|
__fpu_k0 __darwin_opmask_reg |
|
__fpu_k1 __darwin_opmask_reg |
|
__fpu_k2 __darwin_opmask_reg |
|
__fpu_k3 __darwin_opmask_reg |
|
__fpu_k4 __darwin_opmask_reg |
|
__fpu_k5 __darwin_opmask_reg |
|
__fpu_k6 __darwin_opmask_reg |
|
__fpu_k7 __darwin_opmask_reg |
|
__fpu_zmmh0 __darwin_ymm_reg |
|
__fpu_zmmh1 __darwin_ymm_reg |
|
__fpu_zmmh2 __darwin_ymm_reg |
|
__fpu_zmmh3 __darwin_ymm_reg |
|
__fpu_zmmh4 __darwin_ymm_reg |
|
__fpu_zmmh5 __darwin_ymm_reg |
|
__fpu_zmmh6 __darwin_ymm_reg |
|
__fpu_zmmh7 __darwin_ymm_reg |
|
} |
|
type __darwin_i386_exception_state struct { |
|
__trapno uint16 |
|
__cpu uint16 |
|
__err uint32 |
|
__faultvaddr uint32 |
|
} |
|
type __darwin_x86_debug_state32 struct { |
|
__dr0 uint32 |
|
__dr1 uint32 |
|
__dr2 uint32 |
|
__dr3 uint32 |
|
__dr4 uint32 |
|
__dr5 uint32 |
|
__dr6 uint32 |
|
__dr7 uint32 |
|
} |
|
type __darwin_x86_thread_state64 struct { |
|
__rax uint64 |
|
__rbx uint64 |
|
__rcx uint64 |
|
__rdx uint64 |
|
__rdi uint64 |
|
__rsi uint64 |
|
__rbp uint64 |
|
__rsp uint64 |
|
__r8 uint64 |
|
__r9 uint64 |
|
__r10 uint64 |
|
__r11 uint64 |
|
__r12 uint64 |
|
__r13 uint64 |
|
__r14 uint64 |
|
__r15 uint64 |
|
__rip uint64 |
|
__rflags uint64 |
|
__cs uint64 |
|
__fs uint64 |
|
__gs uint64 |
|
} |
|
type __darwin_x86_float_state64 struct { |
|
__fpu_reserved [2]int32 |
|
__fpu_fcw __darwin_fp_control |
|
__fpu_fsw __darwin_fp_status |
|
__fpu_ftw uint8 |
|
__fpu_rsrv1 uint8 |
|
__fpu_fop uint16 |
|
__fpu_ip uint32 |
|
__fpu_cs uint16 |
|
__fpu_rsrv2 uint16 |
|
__fpu_dp uint32 |
|
__fpu_ds uint16 |
|
__fpu_rsrv3 uint16 |
|
__fpu_mxcsr uint32 |
|
__fpu_mxcsrmask uint32 |
|
__fpu_stmm0 __darwin_mmst_reg |
|
__fpu_stmm1 __darwin_mmst_reg |
|
__fpu_stmm2 __darwin_mmst_reg |
|
__fpu_stmm3 __darwin_mmst_reg |
|
__fpu_stmm4 __darwin_mmst_reg |
|
__fpu_stmm5 __darwin_mmst_reg |
|
__fpu_stmm6 __darwin_mmst_reg |
|
__fpu_stmm7 __darwin_mmst_reg |
|
__fpu_xmm0 __darwin_xmm_reg |
|
__fpu_xmm1 __darwin_xmm_reg |
|
__fpu_xmm2 __darwin_xmm_reg |
|
__fpu_xmm3 __darwin_xmm_reg |
|
__fpu_xmm4 __darwin_xmm_reg |
|
__fpu_xmm5 __darwin_xmm_reg |
|
__fpu_xmm6 __darwin_xmm_reg |
|
__fpu_xmm7 __darwin_xmm_reg |
|
__fpu_xmm8 __darwin_xmm_reg |
|
__fpu_xmm9 __darwin_xmm_reg |
|
__fpu_xmm10 __darwin_xmm_reg |
|
__fpu_xmm11 __darwin_xmm_reg |
|
__fpu_xmm12 __darwin_xmm_reg |
|
__fpu_xmm13 __darwin_xmm_reg |
|
__fpu_xmm14 __darwin_xmm_reg |
|
__fpu_xmm15 __darwin_xmm_reg |
|
__fpu_rsrv4 [96]byte |
|
__fpu_reserved1 int32 |
|
} |
|
type __darwin_x86_avx_state64 struct { |
|
__fpu_reserved [2]int32 |
|
__fpu_fcw __darwin_fp_control |
|
__fpu_fsw __darwin_fp_status |
|
__fpu_ftw uint8 |
|
__fpu_rsrv1 uint8 |
|
__fpu_fop uint16 |
|
__fpu_ip uint32 |
|
__fpu_cs uint16 |
|
__fpu_rsrv2 uint16 |
|
__fpu_dp uint32 |
|
__fpu_ds uint16 |
|
__fpu_rsrv3 uint16 |
|
__fpu_mxcsr uint32 |
|
__fpu_mxcsrmask uint32 |
|
__fpu_stmm0 __darwin_mmst_reg |
|
__fpu_stmm1 __darwin_mmst_reg |
|
__fpu_stmm2 __darwin_mmst_reg |
|
__fpu_stmm3 __darwin_mmst_reg |
|
__fpu_stmm4 __darwin_mmst_reg |
|
__fpu_stmm5 __darwin_mmst_reg |
|
__fpu_stmm6 __darwin_mmst_reg |
|
__fpu_stmm7 __darwin_mmst_reg |
|
__fpu_xmm0 __darwin_xmm_reg |
|
__fpu_xmm1 __darwin_xmm_reg |
|
__fpu_xmm2 __darwin_xmm_reg |
|
__fpu_xmm3 __darwin_xmm_reg |
|
__fpu_xmm4 __darwin_xmm_reg |
|
__fpu_xmm5 __darwin_xmm_reg |
|
__fpu_xmm6 __darwin_xmm_reg |
|
__fpu_xmm7 __darwin_xmm_reg |
|
__fpu_xmm8 __darwin_xmm_reg |
|
__fpu_xmm9 __darwin_xmm_reg |
|
__fpu_xmm10 __darwin_xmm_reg |
|
__fpu_xmm11 __darwin_xmm_reg |
|
__fpu_xmm12 __darwin_xmm_reg |
|
__fpu_xmm13 __darwin_xmm_reg |
|
__fpu_xmm14 __darwin_xmm_reg |
|
__fpu_xmm15 __darwin_xmm_reg |
|
__fpu_rsrv4 [96]byte |
|
__fpu_reserved1 int32 |
|
__avx_reserved1 [64]byte |
|
__fpu_ymmh0 __darwin_xmm_reg |
|
__fpu_ymmh1 __darwin_xmm_reg |
|
__fpu_ymmh2 __darwin_xmm_reg |
|
__fpu_ymmh3 __darwin_xmm_reg |
|
__fpu_ymmh4 __darwin_xmm_reg |
|
__fpu_ymmh5 __darwin_xmm_reg |
|
__fpu_ymmh6 __darwin_xmm_reg |
|
__fpu_ymmh7 __darwin_xmm_reg |
|
__fpu_ymmh8 __darwin_xmm_reg |
|
__fpu_ymmh9 __darwin_xmm_reg |
|
__fpu_ymmh10 __darwin_xmm_reg |
|
__fpu_ymmh11 __darwin_xmm_reg |
|
__fpu_ymmh12 __darwin_xmm_reg |
|
__fpu_ymmh13 __darwin_xmm_reg |
|
__fpu_ymmh14 __darwin_xmm_reg |
|
__fpu_ymmh15 __darwin_xmm_reg |
|
} |
|
type __darwin_x86_avx512_state64 struct { |
|
__fpu_reserved [2]int32 |
|
__fpu_fcw __darwin_fp_control |
|
__fpu_fsw __darwin_fp_status |
|
__fpu_ftw uint8 |
|
__fpu_rsrv1 uint8 |
|
__fpu_fop uint16 |
|
__fpu_ip uint32 |
|
__fpu_cs uint16 |
|
__fpu_rsrv2 uint16 |
|
__fpu_dp uint32 |
|
__fpu_ds uint16 |
|
__fpu_rsrv3 uint16 |
|
__fpu_mxcsr uint32 |
|
__fpu_mxcsrmask uint32 |
|
__fpu_stmm0 __darwin_mmst_reg |
|
__fpu_stmm1 __darwin_mmst_reg |
|
__fpu_stmm2 __darwin_mmst_reg |
|
__fpu_stmm3 __darwin_mmst_reg |
|
__fpu_stmm4 __darwin_mmst_reg |
|
__fpu_stmm5 __darwin_mmst_reg |
|
__fpu_stmm6 __darwin_mmst_reg |
|
__fpu_stmm7 __darwin_mmst_reg |
|
__fpu_xmm0 __darwin_xmm_reg |
|
__fpu_xmm1 __darwin_xmm_reg |
|
__fpu_xmm2 __darwin_xmm_reg |
|
__fpu_xmm3 __darwin_xmm_reg |
|
__fpu_xmm4 __darwin_xmm_reg |
|
__fpu_xmm5 __darwin_xmm_reg |
|
__fpu_xmm6 __darwin_xmm_reg |
|
__fpu_xmm7 __darwin_xmm_reg |
|
__fpu_xmm8 __darwin_xmm_reg |
|
__fpu_xmm9 __darwin_xmm_reg |
|
__fpu_xmm10 __darwin_xmm_reg |
|
__fpu_xmm11 __darwin_xmm_reg |
|
__fpu_xmm12 __darwin_xmm_reg |
|
__fpu_xmm13 __darwin_xmm_reg |
|
__fpu_xmm14 __darwin_xmm_reg |
|
__fpu_xmm15 __darwin_xmm_reg |
|
__fpu_rsrv4 [96]byte |
|
__fpu_reserved1 int32 |
|
__avx_reserved1 [64]byte |
|
__fpu_ymmh0 __darwin_xmm_reg |
|
__fpu_ymmh1 __darwin_xmm_reg |
|
__fpu_ymmh2 __darwin_xmm_reg |
|
__fpu_ymmh3 __darwin_xmm_reg |
|
__fpu_ymmh4 __darwin_xmm_reg |
|
__fpu_ymmh5 __darwin_xmm_reg |
|
__fpu_ymmh6 __darwin_xmm_reg |
|
__fpu_ymmh7 __darwin_xmm_reg |
|
__fpu_ymmh8 __darwin_xmm_reg |
|
__fpu_ymmh9 __darwin_xmm_reg |
|
__fpu_ymmh10 __darwin_xmm_reg |
|
__fpu_ymmh11 __darwin_xmm_reg |
|
__fpu_ymmh12 __darwin_xmm_reg |
|
__fpu_ymmh13 __darwin_xmm_reg |
|
__fpu_ymmh14 __darwin_xmm_reg |
|
__fpu_ymmh15 __darwin_xmm_reg |
|
__fpu_k0 __darwin_opmask_reg |
|
__fpu_k1 __darwin_opmask_reg |
|
__fpu_k2 __darwin_opmask_reg |
|
__fpu_k3 __darwin_opmask_reg |
|
__fpu_k4 __darwin_opmask_reg |
|
__fpu_k5 __darwin_opmask_reg |
|
__fpu_k6 __darwin_opmask_reg |
|
__fpu_k7 __darwin_opmask_reg |
|
__fpu_zmmh0 __darwin_ymm_reg |
|
__fpu_zmmh1 __darwin_ymm_reg |
|
__fpu_zmmh2 __darwin_ymm_reg |
|
__fpu_zmmh3 __darwin_ymm_reg |
|
__fpu_zmmh4 __darwin_ymm_reg |
|
__fpu_zmmh5 __darwin_ymm_reg |
|
__fpu_zmmh6 __darwin_ymm_reg |
|
__fpu_zmmh7 __darwin_ymm_reg |
|
__fpu_zmmh8 __darwin_ymm_reg |
|
__fpu_zmmh9 __darwin_ymm_reg |
|
__fpu_zmmh10 __darwin_ymm_reg |
|
__fpu_zmmh11 __darwin_ymm_reg |
|
__fpu_zmmh12 __darwin_ymm_reg |
|
__fpu_zmmh13 __darwin_ymm_reg |
|
__fpu_zmmh14 __darwin_ymm_reg |
|
__fpu_zmmh15 __darwin_ymm_reg |
|
__fpu_zmm16 __darwin_zmm_reg |
|
__fpu_zmm17 __darwin_zmm_reg |
|
__fpu_zmm18 __darwin_zmm_reg |
|
__fpu_zmm19 __darwin_zmm_reg |
|
__fpu_zmm20 __darwin_zmm_reg |
|
__fpu_zmm21 __darwin_zmm_reg |
|
__fpu_zmm22 __darwin_zmm_reg |
|
__fpu_zmm23 __darwin_zmm_reg |
|
__fpu_zmm24 __darwin_zmm_reg |
|
__fpu_zmm25 __darwin_zmm_reg |
|
__fpu_zmm26 __darwin_zmm_reg |
|
__fpu_zmm27 __darwin_zmm_reg |
|
__fpu_zmm28 __darwin_zmm_reg |
|
__fpu_zmm29 __darwin_zmm_reg |
|
__fpu_zmm30 __darwin_zmm_reg |
|
__fpu_zmm31 __darwin_zmm_reg |
|
} |
|
type __darwin_x86_exception_state64 struct { |
|
__trapno uint16 |
|
__cpu uint16 |
|
__err uint32 |
|
__faultvaddr uint64 |
|
} |
|
type __darwin_x86_debug_state64 struct { |
|
__dr0 uint64 |
|
__dr1 uint64 |
|
__dr2 uint64 |
|
__dr3 uint64 |
|
__dr4 uint64 |
|
__dr5 uint64 |
|
__dr6 uint64 |
|
__dr7 uint64 |
|
} |
|
type __darwin_x86_cpmu_state64 struct { |
|
__ctrs [16]uint64 |
|
} |
|
type __darwin_mcontext32 struct { |
|
__es __darwin_i386_exception_state |
|
__ss __darwin_i386_thread_state |
|
__fs __darwin_i386_float_state |
|
} |
|
type __darwin_mcontext_avx32 struct { |
|
__es __darwin_i386_exception_state |
|
__ss __darwin_i386_thread_state |
|
__fs __darwin_i386_avx_state |
|
} |
|
type __darwin_mcontext_avx512_32 struct { |
|
__es __darwin_i386_exception_state |
|
__ss __darwin_i386_thread_state |
|
__fs __darwin_i386_avx512_state |
|
} |
|
type __darwin_mcontext64 struct { |
|
__es __darwin_x86_exception_state64 |
|
__ss __darwin_x86_thread_state64 |
|
__fs __darwin_x86_float_state64 |
|
} |
|
type __darwin_mcontext_avx64 struct { |
|
__es __darwin_x86_exception_state64 |
|
__ss __darwin_x86_thread_state64 |
|
__fs __darwin_x86_avx_state64 |
|
} |
|
type __darwin_mcontext_avx512_64 struct { |
|
__es __darwin_x86_exception_state64 |
|
__ss __darwin_x86_thread_state64 |
|
__fs __darwin_x86_avx512_state64 |
|
} |
|
type mcontext_t *__darwin_mcontext64 |
|
type pthread_attr_t __darwin_pthread_attr_t |
|
type __darwin_sigaltstack struct { |
|
ss_sp unsafe.Pointer |
|
ss_size __darwin_size_t |
|
ss_flags int32 |
|
} |
|
type stack_t __darwin_sigaltstack |
|
type __darwin_ucontext struct { |
|
uc_onstack int32 |
|
uc_sigmask __darwin_sigset_t |
|
uc_stack __darwin_sigaltstack |
|
uc_link *__darwin_ucontext |
|
uc_mcsize __darwin_size_t |
|
uc_mcontext *__darwin_mcontext64 |
|
__mcontext_data __darwin_mcontext64 |
|
} |
|
type ucontext_t __darwin_ucontext |
|
type sigset_t __darwin_sigset_t |
|
type uid_t __darwin_uid_t |
|
type sigval struct{ memory unsafe.Pointer } |
|
|
|
func (unionVar *sigval) copy() sigval { |
|
var buffer [8]byte |
|
for i := range buffer { |
|
buffer[i] = (*((*[8]byte)(unionVar.memory)))[i] |
|
} |
|
var newUnion sigval |
|
newUnion.memory = unsafe.Pointer(&buffer) |
|
return newUnion |
|
} |
|
func (unionVar *sigval) sival_int() *int32 { |
|
if unionVar.memory == nil { |
|
var buffer [8]byte |
|
unionVar.memory = unsafe.Pointer(&buffer) |
|
} |
|
return (*int32)(unionVar.memory) |
|
} |
|
func (unionVar *sigval) sival_ptr() *unsafe.Pointer { |
|
if unionVar.memory == nil { |
|
var buffer [8]byte |
|
unionVar.memory = unsafe.Pointer(&buffer) |
|
} |
|
return (*unsafe.Pointer)(unionVar.memory) |
|
} |
|
|
|
type sigevent struct { |
|
sigev_notify int32 |
|
sigev_signo int32 |
|
sigev_value sigval |
|
sigev_notify_function func(sigval) |
|
sigev_notify_attributes *pthread_attr_t |
|
} |
|
type __siginfo struct { |
|
si_signo int32 |
|
si_errno int32 |
|
si_code int32 |
|
si_pid pid_t |
|
si_uid uid_t |
|
si_status int32 |
|
si_addr unsafe.Pointer |
|
si_value sigval |
|
si_band int32 |
|
__pad [7]uint32 |
|
} |
|
type siginfo_t __siginfo |
|
type __sigaction_u struct{ memory unsafe.Pointer } |
|
|
|
func (unionVar *__sigaction_u) copy() __sigaction_u { |
|
var buffer [8]byte |
|
for i := range buffer { |
|
buffer[i] = (*((*[8]byte)(unionVar.memory)))[i] |
|
} |
|
var newUnion __sigaction_u |
|
newUnion.memory = unsafe.Pointer(&buffer) |
|
return newUnion |
|
} |
|
func (unionVar *__sigaction_u) __sa_handler() *func(int32) { |
|
if unionVar.memory == nil { |
|
var buffer [8]byte |
|
unionVar.memory = unsafe.Pointer(&buffer) |
|
} |
|
return (*func(int32))(unionVar.memory) |
|
} |
|
func (unionVar *__sigaction_u) __sa_sigaction() *func(int32, *__siginfo, unsafe.Pointer) { |
|
if unionVar.memory == nil { |
|
var buffer [8]byte |
|
unionVar.memory = unsafe.Pointer(&buffer) |
|
} |
|
return (*func(int32, *__siginfo, unsafe.Pointer))(unionVar.memory) |
|
} |
|
|
|
type sig_t func(int32) |
|
type sigvec struct { |
|
sv_handler func(int32) |
|
sv_mask int32 |
|
sv_flags int32 |
|
} |
|
type sigstack struct { |
|
ss_sp *byte |
|
ss_onstack int32 |
|
} |
|
type uint8_t uint8 |
|
type uint16_t uint16 |
|
type uint32_t uint32 |
|
type uint64_t uint64 |
|
type int_least8_t int8 |
|
type int_least16_t int16 |
|
type int_least32_t int32 |
|
type int_least64_t int64 |
|
type uint_least8_t uint8 |
|
type uint_least16_t uint16 |
|
type uint_least32_t uint32 |
|
type uint_least64_t uint64 |
|
type int_fast8_t int8 |
|
type int_fast16_t int16 |
|
type int_fast32_t int32 |
|
type int_fast64_t int64 |
|
type uint_fast8_t uint8 |
|
type uint_fast16_t uint16 |
|
type uint_fast32_t uint32 |
|
type uint_fast64_t uint64 |
|
type intmax_t int32 |
|
type uintmax_t uint32 |
|
type timeval struct { |
|
tv_sec __darwin_time_t |
|
tv_usec __darwin_suseconds_t |
|
} |
|
type rlim_t uint64 |
|
type rusage struct { |
|
ru_utime timeval |
|
ru_stime timeval |
|
ru_maxrss int32 |
|
ru_ixrss int32 |
|
ru_idrss int32 |
|
ru_isrss int32 |
|
ru_minflt int32 |
|
ru_majflt int32 |
|
ru_nswap int32 |
|
ru_inblock int32 |
|
ru_oublock int32 |
|
ru_msgsnd int32 |
|
ru_msgrcv int32 |
|
ru_nsignals int32 |
|
ru_nvcsw int32 |
|
ru_nivcsw int32 |
|
} |
|
type rusage_info_t unsafe.Pointer |
|
type rusage_info_v0 struct { |
|
ri_uuid [16]uint8 |
|
ri_user_time uint64 |
|
ri_system_time uint64 |
|
ri_pkg_idle_wkups uint64 |
|
ri_interrupt_wkups uint64 |
|
ri_pageins uint64 |
|
ri_wired_size uint64 |
|
ri_resident_size uint64 |
|
ri_phys_footprint uint64 |
|
ri_proc_start_abstime uint64 |
|
ri_proc_exit_abstime uint64 |
|
} |
|
type rusage_info_v1 struct { |
|
ri_uuid [16]uint8 |
|
ri_user_time uint64 |
|
ri_system_time uint64 |
|
ri_pkg_idle_wkups uint64 |
|
ri_interrupt_wkups uint64 |
|
ri_pageins uint64 |
|
ri_wired_size uint64 |
|
ri_resident_size uint64 |
|
ri_phys_footprint uint64 |
|
ri_proc_start_abstime uint64 |
|
ri_proc_exit_abstime uint64 |
|
ri_child_user_time uint64 |
|
ri_child_system_time uint64 |
|
ri_child_pkg_idle_wkups uint64 |
|
ri_child_interrupt_wkups uint64 |
|
ri_child_pageins uint64 |
|
ri_child_elapsed_abstime uint64 |
|
} |
|
type rusage_info_v2 struct { |
|
ri_uuid [16]uint8 |
|
ri_user_time uint64 |
|
ri_system_time uint64 |
|
ri_pkg_idle_wkups uint64 |
|
ri_interrupt_wkups uint64 |
|
ri_pageins uint64 |
|
ri_wired_size uint64 |
|
ri_resident_size uint64 |
|
ri_phys_footprint uint64 |
|
ri_proc_start_abstime uint64 |
|
ri_proc_exit_abstime uint64 |
|
ri_child_user_time uint64 |
|
ri_child_system_time uint64 |
|
ri_child_pkg_idle_wkups uint64 |
|
ri_child_interrupt_wkups uint64 |
|
ri_child_pageins uint64 |
|
ri_child_elapsed_abstime uint64 |
|
ri_diskio_bytesread uint64 |
|
ri_diskio_byteswritten uint64 |
|
} |
|
type rusage_info_v3 struct { |
|
ri_uuid [16]uint8 |
|
ri_user_time uint64 |
|
ri_system_time uint64 |
|
ri_pkg_idle_wkups uint64 |
|
ri_interrupt_wkups uint64 |
|
ri_pageins uint64 |
|
ri_wired_size uint64 |
|
ri_resident_size uint64 |
|
ri_phys_footprint uint64 |
|
ri_proc_start_abstime uint64 |
|
ri_proc_exit_abstime uint64 |
|
ri_child_user_time uint64 |
|
ri_child_system_time uint64 |
|
ri_child_pkg_idle_wkups uint64 |
|
ri_child_interrupt_wkups uint64 |
|
ri_child_pageins uint64 |
|
ri_child_elapsed_abstime uint64 |
|
ri_diskio_bytesread uint64 |
|
ri_diskio_byteswritten uint64 |
|
ri_cpu_time_qos_default uint64 |
|
ri_cpu_time_qos_maintenance uint64 |
|
ri_cpu_time_qos_background uint64 |
|
ri_cpu_time_qos_utility uint64 |
|
ri_cpu_time_qos_legacy uint64 |
|
ri_cpu_time_qos_user_initiated uint64 |
|
ri_cpu_time_qos_user_interactive uint64 |
|
ri_billed_system_time uint64 |
|
ri_serviced_system_time uint64 |
|
} |
|
type rusage_info_v4 struct { |
|
ri_uuid [16]uint8 |
|
ri_user_time uint64 |
|
ri_system_time uint64 |
|
ri_pkg_idle_wkups uint64 |
|
ri_interrupt_wkups uint64 |
|
ri_pageins uint64 |
|
ri_wired_size uint64 |
|
ri_resident_size uint64 |
|
ri_phys_footprint uint64 |
|
ri_proc_start_abstime uint64 |
|
ri_proc_exit_abstime uint64 |
|
ri_child_user_time uint64 |
|
ri_child_system_time uint64 |
|
ri_child_pkg_idle_wkups uint64 |
|
ri_child_interrupt_wkups uint64 |
|
ri_child_pageins uint64 |
|
ri_child_elapsed_abstime uint64 |
|
ri_diskio_bytesread uint64 |
|
ri_diskio_byteswritten uint64 |
|
ri_cpu_time_qos_default uint64 |
|
ri_cpu_time_qos_maintenance uint64 |
|
ri_cpu_time_qos_background uint64 |
|
ri_cpu_time_qos_utility uint64 |
|
ri_cpu_time_qos_legacy uint64 |
|
ri_cpu_time_qos_user_initiated uint64 |
|
ri_cpu_time_qos_user_interactive uint64 |
|
ri_billed_system_time uint64 |
|
ri_serviced_system_time uint64 |
|
ri_logical_writes uint64 |
|
ri_lifetime_max_phys_footprint uint64 |
|
ri_instructions uint64 |
|
ri_cycles uint64 |
|
ri_billed_energy uint64 |
|
ri_serviced_energy uint64 |
|
ri_unused [2]uint64 |
|
} |
|
type rusage_info_current rusage_info_v4 |
|
type rlimit struct { |
|
rlim_cur rlim_t |
|
rlim_max rlim_t |
|
} |
|
type proc_rlimit_control_wakeupmon struct { |
|
wm_flags uint32 |
|
wm_rate int32 |
|
} |
|
|
|
// _OSSwapInt16 - transpiled function from /usr/include/libkern/i386/_OSByteOrder.h:44 |
|
// Warning (FieldDecl): /usr/include/mach/i386/_structs.h:94 : Error : name of FieldDecl is empty |
|
func _OSSwapInt16(_data uint16) uint16 { |
|
return (uint16((int32(uint16((_data)))<<uint64(int32(8)) | int32(uint16((_data)))>>uint64(int32(8))))) |
|
} |
|
|
|
// _OSSwapInt32 - transpiled function from /usr/include/libkern/i386/_OSByteOrder.h:53 |
|
func _OSSwapInt32(_data uint32) uint32 { |
|
return uint32((darwin.BSwap32(uint32((uint32(_data)))))) |
|
} |
|
|
|
// _OSSwapInt64 - transpiled function from /usr/include/libkern/i386/_OSByteOrder.h:68 |
|
func _OSSwapInt64(_data uint64) uint64 { |
|
return uint64((darwin.BSwap64(uint64((uint64(_data)))))) |
|
} |
|
|
|
type BSstructSatSSusrSincludeSsysSwaitPhD199D2E struct { |
|
w_Termsig uint32 |
|
w_Coredump uint32 |
|
w_Retcode uint32 |
|
w_Filler uint32 |
|
} |
|
type BSstructSatSSusrSincludeSsysSwaitPhD218D2E struct { |
|
w_Stopval uint32 |
|
w_Stopsig uint32 |
|
w_Filler uint32 |
|
} |
|
type wait struct{ memory unsafe.Pointer } |
|
|
|
func (unionVar *wait) copy() wait { |
|
var buffer [16]byte |
|
for i := range buffer { |
|
buffer[i] = (*((*[16]byte)(unionVar.memory)))[i] |
|
} |
|
var newUnion wait |
|
newUnion.memory = unsafe.Pointer(&buffer) |
|
return newUnion |
|
} |
|
func (unionVar *wait) w_status() *int32 { |
|
if unionVar.memory == nil { |
|
var buffer [16]byte |
|
unionVar.memory = unsafe.Pointer(&buffer) |
|
} |
|
return (*int32)(unionVar.memory) |
|
} |
|
func (unionVar *wait) w_T() *BSstructSatSSusrSincludeSsysSwaitPhD199D2E { |
|
if unionVar.memory == nil { |
|
var buffer [16]byte |
|
unionVar.memory = unsafe.Pointer(&buffer) |
|
} |
|
return (*BSstructSatSSusrSincludeSsysSwaitPhD199D2E)(unionVar.memory) |
|
} |
|
func (unionVar *wait) w_S() *BSstructSatSSusrSincludeSsysSwaitPhD218D2E { |
|
if unionVar.memory == nil { |
|
var buffer [16]byte |
|
unionVar.memory = unsafe.Pointer(&buffer) |
|
} |
|
return (*BSstructSatSSusrSincludeSsysSwaitPhD218D2E)(unionVar.memory) |
|
} |
|
|
|
type ct_rune_t darwin.CtRuneT |
|
type rune_t __darwin_rune_t |
|
type wchar_t __darwin_wchar_t |
|
type div_t struct { |
|
quot int32 |
|
rem int32 |
|
} |
|
type ldiv_t struct { |
|
quot int32 |
|
rem int32 |
|
} |
|
type lldiv_t struct { |
|
quot int64 |
|
rem int64 |
|
} |
|
type dev_t __darwin_dev_t |
|
type mode_t __darwin_mode_t |
|
|
|
var n int32 |
|
var fn int32 |
|
var nfactor int32 |
|
var maxDec int32 |
|
var maxW int32 |
|
var curstr *byte |
|
var max_perm int32 |
|
var mperm_res *int32 |
|
var nBest *int32 |
|
var bestLen *int32 |
|
var bestStrings **int32 |
|
var tot_bl int32 |
|
var unvisited *byte |
|
var valid *byte |
|
var outputFileName []byte = make([]byte, 256, 256) |
|
|
|
// main - transpiled function from /Users/john/tmp/superperm/ChaffinMethod/ChaffinMethod.c:103 |
|
// |
|
// ChaffinMethod.c |
|
// |
|
// A program based on Benjamin Chaffin's algorithm for finding minimal superpermutations. |
|
/* |
|
|
|
From the original version: |
|
-------------------------- |
|
|
|
This script is used to show that minimal superpermutations on 5 symbols have 153 characters |
|
(it can also compute the length of minimal superpermutations on 3 or 4 symbols). |
|
More specifically, it computes the values in the table from the following blog post: |
|
http://www.njohnston.ca/2014/08/all-minimal-superpermutations-on-five-symbols-have-been-found/ |
|
|
|
Author: Nathaniel Johnston ([email protected]), based on an algorithm by Benjamin Chaffin |
|
Version: 1.00 |
|
Last Updated: Aug. 13, 2014 |
|
|
|
This version: |
|
------------- |
|
|
|
This version aspires to give a result for n=6 before the death of the sun, |
|
but whether it can or not is yet to be confirmed. |
|
|
|
Author: Greg Egan |
|
Version: 2.1 |
|
Last Updated: 28 March 2019 |
|
|
|
Usage: |
|
|
|
ChaffinMethod n |
|
|
|
Computes all strings (starting with 123...n) that contain the maximum possible number of permutations on n symbols while wasting w |
|
characters, for all values of w from 1 up to the point where all permutations are visited (i.e. these strings become |
|
superpermutations). |
|
|
|
The strings for each value of w are written to files of the form: |
|
|
|
Chaffin_<n>_W_<w>.txt |
|
|
|
If the program is halted for some reason, when it is run again it will read back any files it finds with names of this form, |
|
and restart computations for the w value of the last such file that it finds. |
|
*/ // |
|
// Constants |
|
// --------- |
|
// Logical truth values |
|
// Smallest and largest values of n accepted |
|
// Macros |
|
// ------ |
|
// Global variables |
|
// ---------------- |
|
// The number of symbols in the permutations we are considering |
|
// n! |
|
// 10^(n-1) |
|
// Highest decimal representation of a digit sequence we can encounter, plus 1 |
|
// Largest number of wasted characters we allow for |
|
// Current string |
|
// Maximum number of permutations visited by any string seen so far |
|
// For each number of wasted characters, the maximum number of permutations that can be visited |
|
// For each number of wasted characters, the number of strings that achieve mperm_res permutations |
|
// For each number of wasted characters, the lengths of the strings that visit mperm_res permutations |
|
// For each number of wasted characters, a list of all strings that visit mperm_res permutations |
|
// The total number of wasted characters we are allowing in strings, in current search |
|
// Flags set FALSE when we visit a permutation, indexed by decimal rep of permutation |
|
// Flags saying whether decimal rep of digit sequence corresponds to a valid permutation |
|
// Function definitions |
|
// -------------------- |
|
// Main program |
|
// ------------ |
|
// Storage for current string |
|
// Storage for things associated with different numbers of wasted characters |
|
// Compute 10^(n-1) |
|
// We represent permutations as p_1 + 10 p_2 + 100 p_3 + .... 10^(n-1) p_n |
|
// maxDec is the highest value this can take (allowing for non-permutations as well), plus 1 |
|
// Generate a table of all permutations of n symbols |
|
// Set up flags that say whether each number is a valid permutation or not, |
|
// and whether we have visited a given permutation |
|
// With no wasted characters, we can visit n permutations |
|
// Any new maximum (for however many wasted characters) must exceed that; |
|
// we don't reset this within the loop, as the true maximum will increase as we increase tot_bl |
|
// Set up the zero-wasted-characters string that visits n permutations: 1 2 3 ... n 1 2 3 (n-1) |
|
// Fill the first n entries of the string with [1...n], and compute the |
|
// associated decimal, as well as the partial decimal for [2...n] |
|
// Check for any pre-existing files |
|
// tot_bl is the total number of wasted characters we are allowing in strings; |
|
// we loop through increasing the value |
|
// We guess that max_perm will increase by at least this much at each step |
|
// Gamble on max_perm increasing by at least expectedInc; if it doesn't, we will decrement it and retry |
|
// Recursively fill in the string |
|
// Record maximum number of permutations visited with this many wasted characters |
|
// Read back list of best strings |
|
// |
|
func main() { |
|
argc := int32(len(os.Args)) |
|
argv__multiarray := [][]byte{} |
|
argv__array := []*byte{} |
|
for _, argvSingle := range os.Args { |
|
argv__multiarray = append(argv__multiarray, append([]byte(argvSingle), 0)) |
|
} |
|
for _, argvSingle := range argv__multiarray { |
|
argv__array = append(argv__array, &argvSingle[0]) |
|
} |
|
argv := *(***byte)(unsafe.Pointer(&argv__array)) |
|
if argc == int32(2) && int32(**((**byte)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + (uintptr)(int32(1))*unsafe.Sizeof(*argv))))) >= int32('0'+byte(int32(3))) && int32(**((**byte)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + (uintptr)(int32(1))*unsafe.Sizeof(*argv))))) <= int32('0'+byte(int32(7))) { |
|
n = int32(**((**byte)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + (uintptr)(int32(1))*unsafe.Sizeof(*argv))))) - int32('0') |
|
} else { |
|
noarch.Printf((&[]byte("Please specify n from %d to %d on the command line\n\x00")[0]), int32(3), int32(7)) |
|
noarch.Exit(int32(1)) |
|
} |
|
fn = fac(n) |
|
if (func() *byte { |
|
tempVar := (*byte)(noarch.Malloc(int32(uint32(int32(2)*fn) * 1))) |
|
curstr = tempVar |
|
return tempVar |
|
}()) == nil { |
|
noarch.Printf((&[]byte("Insufficient memory\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} |
|
maxW = fn |
|
if (func() *int32 { |
|
tempVar := (*int32)(noarch.Malloc(int32(uint32(maxW) * 4))) |
|
nBest = tempVar |
|
return tempVar |
|
}()) == nil { |
|
noarch.Printf((&[]byte("Insufficient memory\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} |
|
if (func() *int32 { |
|
tempVar := (*int32)(noarch.Malloc(int32(uint32(maxW) * 4))) |
|
mperm_res = tempVar |
|
return tempVar |
|
}()) == nil { |
|
noarch.Printf((&[]byte("Insufficient memory\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} |
|
if (func() *int32 { |
|
tempVar := (*int32)(noarch.Malloc(int32(uint32(maxW) * 4))) |
|
bestLen = tempVar |
|
return tempVar |
|
}()) == nil { |
|
noarch.Printf((&[]byte("Insufficient memory\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} |
|
if (func() **int32 { |
|
tempVar := (**int32)(noarch.Malloc(int32(uint32(maxW) * 8))) |
|
bestStrings = tempVar |
|
return tempVar |
|
}()) == nil { |
|
noarch.Printf((&[]byte("Insufficient memory\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} |
|
nfactor = int32(10) |
|
{ |
|
var k int32 = int32(0) |
|
for ; k < n-int32(2); k++ { |
|
nfactor *= int32(10) |
|
} |
|
} |
|
maxDec = n |
|
{ |
|
var k int32 = int32(0) |
|
for ; k < n-int32(1); k++ { |
|
maxDec = int32(10)*maxDec + n |
|
} |
|
} |
|
maxDec += 1 |
|
var permTab **int32 |
|
if (func() **int32 { |
|
tempVar := (**int32)(noarch.Malloc(int32(uint32(n) * 8))) |
|
permTab = tempVar |
|
return tempVar |
|
}()) == nil { |
|
noarch.Printf((&[]byte("Insufficient memory\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} |
|
makePerms(n, ((**int32)(func() unsafe.Pointer { |
|
tempVar := ((**int32)(unsafe.Pointer(uintptr(unsafe.Pointer(permTab)) + (uintptr)(n)*unsafe.Sizeof(*permTab)))) |
|
return unsafe.Pointer(uintptr(unsafe.Pointer(tempVar)) - (uintptr)(int32(1))*unsafe.Sizeof(*tempVar)) |
|
}()))) |
|
var p0 *int32 = *((**int32)(unsafe.Pointer(uintptr(unsafe.Pointer(permTab)) + (uintptr)(n-int32(1))*unsafe.Sizeof(*permTab)))) |
|
if (func() *byte { |
|
tempVar := (*byte)(noarch.Malloc(int32(uint32(maxDec) * 1))) |
|
valid = tempVar |
|
return tempVar |
|
}()) == nil { |
|
noarch.Printf((&[]byte("Insufficient memory\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} |
|
if (func() *byte { |
|
tempVar := (*byte)(noarch.Malloc(int32(uint32(maxDec) * 1))) |
|
unvisited = tempVar |
|
return tempVar |
|
}()) == nil { |
|
noarch.Printf((&[]byte("Insufficient memory\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} |
|
{ |
|
var i int32 = int32(0) |
|
for ; i < maxDec; i++ { |
|
*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(valid)) + (uintptr)(i)*unsafe.Sizeof(*valid)))) = byte(func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(0))) |
|
} |
|
} |
|
{ |
|
var i int32 = int32(0) |
|
for ; i < fn; i++ { |
|
var tperm int32 = int32(0) |
|
var factor int32 = int32(1) |
|
{ |
|
var j0 int32 = int32(0) |
|
for ; j0 < n; j0++ { |
|
tperm += factor * *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(p0)) + (uintptr)(n*i+j0)*unsafe.Sizeof(*p0)))) |
|
factor *= int32(10) |
|
} |
|
} |
|
*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(valid)) + (uintptr)(tperm)*unsafe.Sizeof(*valid)))) = byte(func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(1))) |
|
} |
|
} |
|
*mperm_res = n |
|
max_perm = n |
|
*bestLen = int32(2)*n - int32(1) |
|
*nBest = int32(1) |
|
if (func() *int32 { |
|
tempVar := (*int32)(noarch.Malloc(int32(uint32(*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestLen)) + (uintptr)(tot_bl)*unsafe.Sizeof(*bestLen))))**((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest))))) * 4))) |
|
*bestStrings = tempVar |
|
return tempVar |
|
}()) == nil { |
|
noarch.Printf((&[]byte("Insufficient memory\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} |
|
{ |
|
var i int32 = int32(0) |
|
for ; i < n; i++ { |
|
*((*int32)(func() unsafe.Pointer { |
|
tempVar := *bestStrings |
|
return unsafe.Pointer(uintptr(unsafe.Pointer(tempVar)) + (uintptr)(i)*unsafe.Sizeof(*tempVar)) |
|
}())) = i + int32(1) |
|
} |
|
} |
|
{ |
|
var i int32 = n |
|
for ; i < int32(2)*n-int32(1); i++ { |
|
*((*int32)(func() unsafe.Pointer { |
|
tempVar := *bestStrings |
|
return unsafe.Pointer(uintptr(unsafe.Pointer(tempVar)) + (uintptr)(i)*unsafe.Sizeof(*tempVar)) |
|
}())) = i - n + int32(1) |
|
} |
|
} |
|
var tperm0 int32 = int32(0) |
|
var factor int32 = int32(1) |
|
{ |
|
var j0 int32 = int32(0) |
|
for ; j0 < n; j0++ { |
|
*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(curstr)) + (uintptr)(j0)*unsafe.Sizeof(*curstr)))) = byte(j0 + int32(1)) |
|
tperm0 += factor * (j0 + int32(1)) |
|
factor *= int32(10) |
|
} |
|
} |
|
var partNum0 int32 = tperm0 / int32(10) |
|
var resumeFrom int32 = int32(1) |
|
var didResume int32 = func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(0)) |
|
for tot_bl = int32(1); tot_bl < maxW; tot_bl++ { |
|
darwin.BuiltinSprintfChk(&outputFileName[0], int32(0), darwin.BuiltinObjectSize(&outputFileName[0], func() int32 { |
|
if int32(2) > int32(1) { |
|
return int32(1) |
|
} else { |
|
return int32(0) |
|
} |
|
}()), (&[]byte("Chaffin_%d_W_%d.txt\x00")[0]), n, tot_bl) |
|
var fp *noarch.File = noarch.Fopen(&outputFileName[0], (&[]byte("a+\x00")[0])) |
|
if fp == nil { |
|
break |
|
} |
|
noarch.Printf((&[]byte("Reading pre-existing file %s ...\n\x00")[0]), &outputFileName[0]) |
|
var fsize uint32 = getFileSize(fp) |
|
var len int32 = int32(0) |
|
for uint32(len) < uint32((__darwin_size_t((fsize)))) { |
|
var c int32 = noarch.Fgetc(fp) |
|
if c == -int32(1) { |
|
noarch.Printf((&[]byte("Unexpected EOF encountered reading file %s\n\x00")[0]), &outputFileName[0]) |
|
noarch.Exit(int32(1)) |
|
} |
|
if c == int32('\n') { |
|
break |
|
} |
|
len += 1 |
|
} |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestLen)) + (uintptr)(tot_bl)*unsafe.Sizeof(*bestLen)))) = len |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest)))) = int32((uint32((__darwin_size_t((fsize / uint32((__darwin_size_t((uint32(len + int32(1)))))))))))) |
|
if fsize != uint32((__darwin_size_t((uint32(*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest)))) * (len + int32(1))))))) { |
|
noarch.Printf((&[]byte("Size of file %s is %ld, which is not exactly divisible by line length %d\n\x00")[0]), &outputFileName[0], uint32(fsize), len+int32(1)) |
|
noarch.Exit(int32(1)) |
|
} |
|
noarch.Fseek(fp, int32(0), int32(0)) |
|
readBackFile(fp, tot_bl) |
|
noarch.Fclose(fp) |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(mperm_res)) + (uintptr)(tot_bl)*unsafe.Sizeof(*mperm_res)))) = len - tot_bl - (n - int32(1)) |
|
noarch.Printf((&[]byte("Found %d strings of length %d, implying %d permutations, in file %s\n\x00")[0]), *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest)))), *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestLen)) + (uintptr)(tot_bl)*unsafe.Sizeof(*bestLen)))), *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(mperm_res)) + (uintptr)(tot_bl)*unsafe.Sizeof(*mperm_res)))), &outputFileName[0]) |
|
resumeFrom = tot_bl |
|
didResume = func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(1)) |
|
} |
|
var expectedInc int32 = int32(2) * (n - int32(4)) |
|
for tot_bl = resumeFrom; tot_bl < maxW; tot_bl++ { |
|
darwin.BuiltinSprintfChk(&outputFileName[0], int32(0), darwin.BuiltinObjectSize(&outputFileName[0], func() int32 { |
|
if int32(2) > int32(1) { |
|
return int32(1) |
|
} else { |
|
return int32(0) |
|
} |
|
}()), (&[]byte("Chaffin_%d_W_%d.txt\x00")[0]), n, tot_bl) |
|
var old_max int32 = *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(mperm_res)) + (uintptr)(tot_bl-int32(1))*unsafe.Sizeof(*mperm_res)))) |
|
max_perm = old_max + expectedInc |
|
if didResume != 0 && tot_bl == resumeFrom { |
|
max_perm = *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(mperm_res)) + (uintptr)(resumeFrom)*unsafe.Sizeof(*mperm_res)))) |
|
} |
|
if max_perm > fn { |
|
max_perm = fn |
|
} |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest)))) = int32(0) |
|
for max_perm > int32(0) { |
|
clearFlags(tperm0) |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestLen)) + (uintptr)(tot_bl)*unsafe.Sizeof(*bestLen)))) = max_perm + tot_bl + n - int32(1) |
|
fillStr(n, int32(1), partNum0, (func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(1)))) |
|
if *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest)))) > int32(0) { |
|
break |
|
} |
|
noarch.Printf((&[]byte("Backtracking, reducing max_perm from %d to %d\n\x00")[0]), max_perm, max_perm-int32(1)) |
|
max_perm -= 1 |
|
} |
|
if max_perm-old_max < expectedInc { |
|
noarch.Printf((&[]byte("Reduced default increment in max_perm from %d to \x00")[0]), expectedInc) |
|
expectedInc = max_perm - old_max |
|
if expectedInc <= int32(0) { |
|
expectedInc = int32(1) |
|
} |
|
noarch.Printf((&[]byte("%d\n\x00")[0]), expectedInc) |
|
} |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(mperm_res)) + (uintptr)(tot_bl)*unsafe.Sizeof(*mperm_res)))) = max_perm |
|
noarch.Printf((&[]byte("%d wasted characters: at most %d permutations, in %d characters, %d examples\n\x00")[0]), tot_bl, max_perm, *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestLen)) + (uintptr)(tot_bl)*unsafe.Sizeof(*bestLen)))), *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest))))) |
|
if max_perm >= fn { |
|
noarch.Printf((&[]byte("\n-----\nDONE!\n-----\nMinimal superpermutations on %d symbols have %d wasted characters and a length of %d.\n\n\x00")[0]), n, tot_bl, fn+tot_bl+n-int32(1)) |
|
break |
|
} |
|
var fp *noarch.File = noarch.Fopen(&outputFileName[0], (&[]byte("a+\x00")[0])) |
|
if fp == nil { |
|
noarch.Printf((&[]byte("Unable to open file %s to read\n\x00")[0]), &outputFileName[0]) |
|
noarch.Exit(int32(1)) |
|
} |
|
readBackFile(fp, tot_bl) |
|
noarch.Fclose(fp) |
|
} |
|
return |
|
} |
|
|
|
// fillStr - transpiled function from /Users/john/tmp/superperm/ChaffinMethod/ChaffinMethod.c:307 |
|
// this function recursively fills the string |
|
// Number of character wasted so far |
|
// Maximum number of further characters we can waste while not exceeding tot_bl |
|
// If we can only match the current max_perm by using an optimal string for our remaining quota of wasted characters, |
|
// we try using those strings (swapping digits to make them start from the permutation we just visited). |
|
// Loop to try each possible next character we could append |
|
// there is never any benefit to having 2 of the same character next to each other |
|
// Check to see if this contributes a new permutation or not |
|
// now go to the next level of the recursion |
|
// the quantity alreadyWasted = pos - pfound - n + 1 is the number of already-used blanks |
|
// |
|
func fillStr(pos int32, pfound int32, partNum int32, leftPerm int32) { |
|
var j1 int32 |
|
var newperm int32 |
|
var tperm int32 |
|
var alreadyWasted int32 = pos - pfound - n + int32(1) |
|
var spareW int32 = tot_bl - alreadyWasted |
|
if leftPerm != 0 && spareW < tot_bl && *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(mperm_res)) + (uintptr)(spareW)*unsafe.Sizeof(*mperm_res))))+pfound-int32(1) == max_perm { |
|
{ |
|
var i int32 = int32(0) |
|
for ; i < *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(spareW)*unsafe.Sizeof(*nBest)))); i++ { |
|
var len int32 = *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestLen)) + (uintptr)(spareW)*unsafe.Sizeof(*bestLen)))) |
|
var bestStr *int32 = ((*int32)(func() unsafe.Pointer { |
|
tempVar := *((**int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestStrings)) + (uintptr)(spareW)*unsafe.Sizeof(*bestStrings)))) |
|
return unsafe.Pointer(uintptr(unsafe.Pointer(tempVar)) + (uintptr)(i*len)*unsafe.Sizeof(*tempVar)) |
|
}())) |
|
var swap *byte = ((*byte)(func() unsafe.Pointer { |
|
tempVar := ((*byte)(func() unsafe.Pointer { |
|
tempVar := ((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(curstr)) + (uintptr)(pos)*unsafe.Sizeof(*curstr)))) |
|
return unsafe.Pointer(uintptr(unsafe.Pointer(tempVar)) - (uintptr)(n)*unsafe.Sizeof(*tempVar)) |
|
}())) |
|
return unsafe.Pointer(uintptr(unsafe.Pointer(tempVar)) - (uintptr)(int32(1))*unsafe.Sizeof(*tempVar)) |
|
}())) |
|
fillStr2(pos, pfound, partNum, swap, ((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestStr)) + (uintptr)(n)*unsafe.Sizeof(*bestStr)))), len-n) |
|
} |
|
} |
|
return |
|
} |
|
for j1 = int32(1); j1 <= n; j1++ { |
|
if j1 != int32(*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(curstr)) + (uintptr)(pos-int32(1))*unsafe.Sizeof(*curstr))))) { |
|
*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(curstr)) + (uintptr)(pos)*unsafe.Sizeof(*curstr)))) = byte(j1) |
|
tperm = partNum + nfactor*j1 |
|
newperm = func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(valid)) + (uintptr)(tperm)*unsafe.Sizeof(*valid))))) != 0 && int32(*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(unvisited)) + (uintptr)(tperm)*unsafe.Sizeof(*unvisited))))) != 0) |
|
if newperm != 0 { |
|
if pfound+int32(1) > max_perm { |
|
writeCurrentString((func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(1))), pos+int32(1)) |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest)))) = int32(1) |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestLen)) + (uintptr)(tot_bl)*unsafe.Sizeof(*bestLen)))) = pos + int32(1) |
|
max_perm = pfound + int32(1) |
|
} else if pfound+int32(1) == max_perm { |
|
writeCurrentString(func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest)))) == int32(0)), pos+int32(1)) |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest)))) += int32(1) |
|
} |
|
*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(unvisited)) + (uintptr)(tperm)*unsafe.Sizeof(*unvisited)))) = byte(func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(0))) |
|
fillStr(pos+int32(1), pfound+int32(1), tperm/int32(10), (func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(1)))) |
|
*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(unvisited)) + (uintptr)(tperm)*unsafe.Sizeof(*unvisited)))) = byte(func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(1))) |
|
} else if alreadyWasted < tot_bl { |
|
if *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(mperm_res)) + (uintptr)(tot_bl-(alreadyWasted+int32(1)))*unsafe.Sizeof(*mperm_res))))+pfound >= max_perm { |
|
fillStr(pos+int32(1), pfound, tperm/int32(10), int32(*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(valid)) + (uintptr)(tperm)*unsafe.Sizeof(*valid)))))) |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
// fillStr2 - transpiled function from /Users/john/tmp/superperm/ChaffinMethod/ChaffinMethod.c:380 |
|
// Version that fills in the string when we are following a previously computed best string |
|
// rather than trying all digits. |
|
// No more digits left in the template we are following |
|
// Get the next digit from the template, swapped to make it start at our chosen permutation |
|
// there is never any benefit to having 2 of the same character next to each other |
|
// Check to see if this contributes a new permutation or not |
|
// now go to the next level of the recursion |
|
// the quantity alreadyWasted = pos - pfound - n + 1 is the number of already-used blanks |
|
// |
|
func fillStr2(pos int32, pfound int32, partNum int32, swap *byte, bestStr *int32, len int32) { |
|
if len <= int32(0) { |
|
return |
|
} |
|
var j1 int32 |
|
var newperm int32 |
|
var tperm int32 |
|
var alreadyWasted int32 = pos - pfound - n + int32(1) |
|
j1 = int32(*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(swap)) + (uintptr)(*bestStr)*unsafe.Sizeof(*swap))))) |
|
if j1 != int32(*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(curstr)) + (uintptr)(pos-int32(1))*unsafe.Sizeof(*curstr))))) { |
|
*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(curstr)) + (uintptr)(pos)*unsafe.Sizeof(*curstr)))) = byte(j1) |
|
tperm = partNum + nfactor*j1 |
|
newperm = func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(valid)) + (uintptr)(tperm)*unsafe.Sizeof(*valid))))) != 0 && int32(*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(unvisited)) + (uintptr)(tperm)*unsafe.Sizeof(*unvisited))))) != 0) |
|
if newperm != 0 { |
|
if pfound+int32(1) > max_perm { |
|
noarch.Printf((&[]byte("Reached a point in the code that should be impossible!\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} else if pfound+int32(1) == max_perm { |
|
writeCurrentString(func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest)))) == int32(0)), pos+int32(1)) |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(tot_bl)*unsafe.Sizeof(*nBest)))) += int32(1) |
|
} |
|
*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(unvisited)) + (uintptr)(tperm)*unsafe.Sizeof(*unvisited)))) = byte(func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(0))) |
|
fillStr2(pos+int32(1), pfound+int32(1), tperm/int32(10), swap, ((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestStr)) + (uintptr)(int32(1))*unsafe.Sizeof(*bestStr)))), len-int32(1)) |
|
*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(unvisited)) + (uintptr)(tperm)*unsafe.Sizeof(*unvisited)))) = byte(func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(1))) |
|
} else if alreadyWasted < tot_bl { |
|
if *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(mperm_res)) + (uintptr)(tot_bl-(alreadyWasted+int32(1)))*unsafe.Sizeof(*mperm_res))))+pfound >= max_perm { |
|
fillStr2(pos+int32(1), pfound, tperm/int32(10), swap, ((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestStr)) + (uintptr)(int32(1))*unsafe.Sizeof(*bestStr)))), len-int32(1)) |
|
} |
|
} |
|
} |
|
} |
|
|
|
// fac - transpiled function from /Users/john/tmp/superperm/ChaffinMethod/ChaffinMethod.c:435 |
|
// this function computes the factorial of a number |
|
// |
|
func fac(k int32) (c2goDefaultReturn int32) { |
|
if k <= int32(1) { |
|
return int32(1) |
|
} else { |
|
return k * fac(k-int32(1)) |
|
} |
|
return |
|
} |
|
|
|
// makePerms - transpiled function from /Users/john/tmp/superperm/ChaffinMethod/ChaffinMethod.c:445 |
|
// Generate all permutations of 1 ... n; |
|
// generates lists for lower values of n |
|
// in the process. |
|
// |
|
func makePerms(n int32, permTab **int32) { |
|
var fn int32 = fac(n) |
|
var size int32 = n * fn |
|
var res *int32 |
|
if (func() *int32 { |
|
tempVar := (*int32)(noarch.Malloc(int32(uint32(size) * 4))) |
|
res = tempVar |
|
return tempVar |
|
}()) == nil { |
|
noarch.Printf((&[]byte("Insufficient memory\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} |
|
if n == int32(1) { |
|
*res = int32(1) |
|
} else { |
|
makePerms(n-int32(1), ((**int32)(unsafe.Pointer(uintptr(unsafe.Pointer(permTab)) - (uintptr)(int32(1))*unsafe.Sizeof(*permTab))))) |
|
var prev *int32 = *((**int32)(unsafe.Pointer(uintptr(unsafe.Pointer(permTab)) - (uintptr)(1)*unsafe.Sizeof(*permTab)))) |
|
var p int32 = int32(0) |
|
var pf int32 = fac(n - int32(1)) |
|
{ |
|
var k int32 = int32(0) |
|
for ; k < pf; k++ { |
|
{ |
|
var q int32 = n - int32(1) |
|
for ; q >= int32(0); q-- { |
|
var r int32 = int32(0) |
|
{ |
|
var s int32 = int32(0) |
|
for ; s < n; s++ { |
|
if s == q { |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(res)) + (uintptr)(func() int32 { |
|
defer func() { |
|
p += 1 |
|
}() |
|
return p |
|
}())*unsafe.Sizeof(*res)))) = n |
|
} else { |
|
*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(res)) + (uintptr)(func() int32 { |
|
defer func() { |
|
p += 1 |
|
}() |
|
return p |
|
}())*unsafe.Sizeof(*res)))) = *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(prev)) + (uintptr)(k*(n-int32(1))+func() int32 { |
|
defer func() { |
|
r += 1 |
|
}() |
|
return r |
|
}())*unsafe.Sizeof(*prev)))) |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
*permTab = res |
|
} |
|
|
|
// writeCurrentString - transpiled function from /Users/john/tmp/superperm/ChaffinMethod/ChaffinMethod.c:480 |
|
func writeCurrentString(newFile int32, size int32) { |
|
var fp *noarch.File |
|
fp = noarch.Fopen(&outputFileName[0], func() *byte { |
|
if newFile != 0 { |
|
return (&[]byte("w\x00")[0]) |
|
} else { |
|
return (&[]byte("w\x00")[0]) |
|
} |
|
}()) |
|
if fp == nil { |
|
noarch.Printf((&[]byte("Unable to open file %s to %s\n\x00")[0]), &outputFileName[0], func() *byte { |
|
if newFile != 0 { |
|
return (&[]byte("write\x00")[0]) |
|
} else { |
|
return (&[]byte("append\x00")[0]) |
|
} |
|
}()) |
|
noarch.Exit(int32(1)) |
|
} |
|
{ |
|
var k int32 = int32(0) |
|
for ; k < size; k++ { |
|
noarch.Fprintf(fp, (&[]byte("%c\x00")[0]), '0'+byte(int32(*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(curstr)) + (uintptr)(k)*unsafe.Sizeof(*curstr))))))) |
|
} |
|
} |
|
noarch.Fprintf(fp, (&[]byte("\n\x00")[0])) |
|
noarch.Fclose(fp) |
|
} |
|
|
|
// clearFlags - transpiled function from /Users/john/tmp/superperm/ChaffinMethod/ChaffinMethod.c:494 |
|
func clearFlags(tperm0 int32) { |
|
{ |
|
var i int32 = int32(0) |
|
for ; i < maxDec; i++ { |
|
*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(unvisited)) + (uintptr)(i)*unsafe.Sizeof(*unvisited)))) = byte(func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(1))) |
|
} |
|
} |
|
*((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(unvisited)) + (uintptr)(tperm0)*unsafe.Sizeof(*unvisited)))) = byte(func(val bool) int32 { |
|
if val { |
|
return 1 |
|
} else { |
|
return 0 |
|
} |
|
}(int32(1) == int32(0))) |
|
} |
|
|
|
// getFileSize - transpiled function from /Users/john/tmp/superperm/ChaffinMethod/ChaffinMethod.c:502 |
|
// Get file size, then reset pointer to start |
|
// |
|
func getFileSize(fc *noarch.File) uint32 { |
|
noarch.Fseek(fc, int32(0), int32(2)) |
|
var fileSizeBytes uint32 = uint32((__darwin_size_t((uint32(noarch.Ftell(fc)))))) |
|
noarch.Fseek(fc, int32(0), int32(0)) |
|
return uint32(fileSizeBytes) |
|
} |
|
|
|
// readBackFile - transpiled function from /Users/john/tmp/superperm/ChaffinMethod/ChaffinMethod.c:510 |
|
func readBackFile(fp *noarch.File, w int32) { |
|
if (func() *int32 { |
|
tempVar := (*int32)(noarch.Malloc(int32(uint32(*((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestLen)) + (uintptr)(w)*unsafe.Sizeof(*bestLen))))**((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(w)*unsafe.Sizeof(*nBest))))) * 4))) |
|
*((**int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestStrings)) + (uintptr)(w)*unsafe.Sizeof(*bestStrings)))) = tempVar |
|
return tempVar |
|
}()) == nil { |
|
noarch.Printf((&[]byte("Insufficient memory\n\x00")[0])) |
|
noarch.Exit(int32(1)) |
|
} |
|
var ptr int32 = int32(0) |
|
{ |
|
var i int32 = int32(0) |
|
for ; i < *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(nBest)) + (uintptr)(w)*unsafe.Sizeof(*nBest)))); i++ { |
|
var c byte |
|
{ |
|
var j int32 = int32(0) |
|
for ; j < *((*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestLen)) + (uintptr)(w)*unsafe.Sizeof(*bestLen)))); j++ { |
|
noarch.Fscanf(fp, (&[]byte("%c\x00")[0]), &c) |
|
*((*int32)(func() unsafe.Pointer { |
|
tempVar := *((**int32)(unsafe.Pointer(uintptr(unsafe.Pointer(bestStrings)) + (uintptr)(w)*unsafe.Sizeof(*bestStrings)))) |
|
return unsafe.Pointer(uintptr(unsafe.Pointer(tempVar)) + (uintptr)(func() int32 { |
|
defer func() { |
|
ptr += 1 |
|
}() |
|
return ptr |
|
}())*unsafe.Sizeof(*tempVar)) |
|
}())) = int32(c) - int32('0') |
|
} |
|
} |
|
noarch.Fscanf(fp, (&[]byte("%c\x00")[0]), &c) |
|
} |
|
} |
|
} |
|
func init() { |
|
__stdinp = noarch.Stdin |
|
__stdoutp = noarch.Stdout |
|
} |