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

Commit

Permalink
public __errno_location
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Aug 5, 2022
1 parent 9e003b7 commit 5737a91
Show file tree
Hide file tree
Showing 31 changed files with 58 additions and 56 deletions.
1 change: 1 addition & 0 deletions c2go.a.pub
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ __builtin_nan
__builtin_nanf
__ctype_get_mb_cur_max
__environ
__errno_location
__fpclassify
__fpclassifyf
__fpclassifyl
Expand Down
1 change: 1 addition & 0 deletions c2go.pub
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ __builtin_inf
__builtin_inff
__builtin_nan
__builtin_nanf
__errno_location
__fpclassify
__fpclassifyl
__signbit
Expand Down
2 changes: 1 addition & 1 deletion fgetwc.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func _cgos___fgetwc_unlocked_internal_fgetwc(f *Struct__IO_FILE) uint32 {
if c < int32(0) {
if !(first != 0) {
f.Flags |= uint32(32)
*__errno_location() = int32(84)
*X__errno_location() = int32(84)
}
return uint32(4294967295)
}
Expand Down
4 changes: 2 additions & 2 deletions fgetws.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func fgetws(s *uint32, n int32, f *Struct__IO_FILE) *uint32 {
return int32(0)
}
}()
*__errno_location() = int32(11)
*X__errno_location() = int32(11)
for ; n != 0; n-- {
var c uint32 = __fgetwc_unlocked(f)
if c == uint32(4294967295) {
Expand All @@ -36,7 +36,7 @@ func fgetws(s *uint32, n int32, f *Struct__IO_FILE) *uint32 {
}
}
*p = uint32(0)
if f.Flags&uint32(32) != 0 || *__errno_location() == int32(84) {
if f.Flags&uint32(32) != 0 || *X__errno_location() == int32(84) {
p = s
}
for {
Expand Down
2 changes: 1 addition & 1 deletion fileno.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Fileno(f *Struct__IO_FILE) int32 {
}
}
if fd < int32(0) {
*__errno_location() = int32(9)
*X__errno_location() = int32(9)
return -1
}
return fd
Expand Down
18 changes: 9 additions & 9 deletions floatscan.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func _cgos_decfloat_floatscan(f *Struct__IO_FILE, c int32, bits int32, emin int3
}
}
if !(gotdig != 0) {
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
__shlim(f, int64(0))
return float64(int32(0))
}
Expand All @@ -320,11 +320,11 @@ func _cgos_decfloat_floatscan(f *Struct__IO_FILE, c int32, bits int32, emin int3
return float64(sign) * float64(*(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer((*uint32)(unsafe.Pointer(&x)))) + uintptr(int32(0))*4)))
}
if lrp > int64(-emin/int32(2)) {
*__errno_location() = int32(34)
*X__errno_location() = int32(34)
return float64(sign) * 1.79769313486231570815e+308 * 1.79769313486231570815e+308
}
if lrp < int64(emin-106) {
*__errno_location() = int32(34)
*X__errno_location() = int32(34)
return float64(sign) * 2.22507385850720138309e-308 * 2.22507385850720138309e-308
}
if j != 0 {
Expand Down Expand Up @@ -505,7 +505,7 @@ func _cgos_decfloat_floatscan(f *Struct__IO_FILE, c int32, bits int32, emin int3
e2++
}
if e2+int32(53) > emax || denormal != 0 && frac != 0 {
*__errno_location() = int32(34)
*X__errno_location() = int32(34)
}
}
return Scalbnl(y, e2)
Expand Down Expand Up @@ -748,11 +748,11 @@ func _cgos_hexfloat_floatscan(f *Struct__IO_FILE, bits int32, emin int32, sign i
return float64(float64(sign) * 0)
}
if e2 > int64(-emin) {
*__errno_location() = int32(34)
*X__errno_location() = int32(34)
return float64(sign) * 1.79769313486231570815e+308 * 1.79769313486231570815e+308
}
if e2 < int64(emin-106) {
*__errno_location() = int32(34)
*X__errno_location() = int32(34)
return float64(sign) * 2.22507385850720138309e-308 * 2.22507385850720138309e-308
}
for x < uint32(2147483648) {
Expand Down Expand Up @@ -787,7 +787,7 @@ func _cgos_hexfloat_floatscan(f *Struct__IO_FILE, bits int32, emin int32, sign i
y = bias + float64(sign)*float64(x) + float64(sign)*y
y -= bias
if !(y != 0) {
*__errno_location() = int32(34)
*X__errno_location() = int32(34)
}
return Scalbnl(y, int32(e2))
}
Expand Down Expand Up @@ -993,7 +993,7 @@ func __floatscan(f *Struct__IO_FILE, prec int32, pok int32) float64 {
}()
}
if !(pok != 0) {
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
__shlim(f, int64(0))
return float64(int32(0))
}
Expand Down Expand Up @@ -1041,7 +1041,7 @@ func __floatscan(f *Struct__IO_FILE, prec int32, pok int32) float64 {
return 0
}()
}
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
__shlim(f, int64(0))
return float64(int32(0))
}
Expand Down
6 changes: 3 additions & 3 deletions fmemopen.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func _cgos_mseek_fmemopen(f *Struct__IO_FILE, off int64, whence int32) int64 {
goto _cgol_1
}
fail:
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
return int64(-1)
_cgol_1:
base = int64(*(*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer((*uint64)(unsafe.Pointer(&[3]uint64{uint64(0), c.pos, c.len})))) + uintptr(whence)*8)))
Expand Down Expand Up @@ -103,11 +103,11 @@ func Fmemopen(buf unsafe.Pointer, size uint64, mode *int8) *Struct__IO_FILE {
}
}()
if !(Strchr((*int8)(unsafe.Pointer(&[4]int8{'r', 'w', 'a', '\x00'})), int32(*mode)) != nil) {
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
return (*Struct__IO_FILE)(nil)
}
if !(buf != nil) && size > uint64(2147483647) {
*__errno_location() = int32(12)
*X__errno_location() = int32(12)
return (*Struct__IO_FILE)(nil)
}
f = (*_cgos_mem_FILE_fmemopen)(Malloc(1300 + func() uint64 {
Expand Down
2 changes: 1 addition & 1 deletion fopen.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ func Fopen(filename *int8, mode *int8) *Struct__IO_FILE {
var fd int32
var flags int32
if !(Strchr((*int8)(unsafe.Pointer(&[4]int8{'r', 'w', 'a', '\x00'})), int32(*mode)) != nil) {
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
return (*Struct__IO_FILE)(nil)
}
flags = __fmodeflags(mode)
Expand Down
6 changes: 3 additions & 3 deletions fopencookie.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ func _cgos_cookieseek_fopencookie(f *Struct__IO_FILE, off int64, whence int32) i
var fc *_cgos_fcookie_fopencookie = (*_cgos_fcookie_fopencookie)(f.Cookie)
var res int32
if uint32(whence) > uint32(2) {
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
return int64(-1)
}
if !(fc.iofuncs.Seek != nil) {
*__errno_location() = int32(95)
*X__errno_location() = int32(95)
return int64(-1)
}
res = fc.iofuncs.Seek(fc.cookie, &off, whence)
Expand All @@ -133,7 +133,7 @@ func _cgos_cookieclose_fopencookie(f *Struct__IO_FILE) int32 {
func Fopencookie(cookie unsafe.Pointer, mode *int8, iofuncs Struct__IO_cookie_io_functions_t) *Struct__IO_FILE {
var f *_cgos_cookie_FILE_fopencookie
if !(Strchr((*int8)(unsafe.Pointer(&[4]int8{'r', 'w', 'a', '\x00'})), int32(*mode)) != nil) {
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
return (*Struct__IO_FILE)(nil)
}
if !(func() (_cgo_ret *_cgos_cookie_FILE_fopencookie) {
Expand Down
4 changes: 2 additions & 2 deletions forkpty.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func forkpty(pm *int32, name *int8, tio *struct_termios, ws *Struct_winsize) int
Close(m)
Close(*(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&p)))) + uintptr(int32(0))*4)))
if login_tty(s) != 0 {
Write(*(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&p)))) + uintptr(int32(1))*4)), unsafe.Pointer(&*__errno_location()), 4)
Write(*(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&p)))) + uintptr(int32(1))*4)), unsafe.Pointer(&*X__errno_location()), 4)
X_exit(int32(127))
}
Close(*(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&p)))) + uintptr(int32(1))*4)))
Expand All @@ -40,7 +40,7 @@ func forkpty(pm *int32, name *int8, tio *struct_termios, ws *Struct_winsize) int
var status int32
waitpid(pid, &status, int32(0))
pid = -1
*__errno_location() = ec
*X__errno_location() = ec
}
Close(*(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&p)))) + uintptr(int32(0))*4)))
out:
Expand Down
2 changes: 1 addition & 1 deletion ftell.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func __ftello(f *Struct__IO_FILE) int64 {
func Ftell(f *Struct__IO_FILE) int64 {
var pos int64 = __ftello(f)
if pos > int64(2147483647) {
*__errno_location() = int32(75)
*X__errno_location() = int32(75)
return int64(-1)
}
return int64(pos)
Expand Down
2 changes: 1 addition & 1 deletion getauxval.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ func __getauxval(item uint64) uint64 {
return *(*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(auxv)) + uintptr(int32(1))*8))
}
}
*__errno_location() = int32(2)
*X__errno_location() = int32(2)
return uint64(0)
}
4 changes: 2 additions & 2 deletions getdelim.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Getdelim(s **int8, n *uint64, delim int32, f *Struct__IO_FILE) int64 {
break
}
}
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
return int64(-1)
}
if !(*s != nil) {
Expand Down Expand Up @@ -69,7 +69,7 @@ func Getdelim(s **int8, n *uint64, delim int32, f *Struct__IO_FILE) int64 {
break
}
}
*__errno_location() = int32(12)
*X__errno_location() = int32(12)
return int64(-1)
}
}
Expand Down
4 changes: 2 additions & 2 deletions getentropy.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ func getentropy(buffer unsafe.Pointer, len uint64) int32 {
var ret int32 = int32(0)
var pos *int8 = (*int8)(buffer)
if len > uint64(256) {
*__errno_location() = int32(5)
*X__errno_location() = int32(5)
return -1
}
pthread_setcancelstate(int32(1), &cs)
for len != 0 {
ret = int32(getrandom(unsafe.Pointer(pos), len, uint32(0)))
if ret < int32(0) {
if *__errno_location() == int32(4) {
if *X__errno_location() == int32(4) {
continue
} else {
break
Expand Down
4 changes: 2 additions & 2 deletions isatty.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ func isatty(fd int32) int32 {
if r == uint64(0) {
return int32(1)
}
if *__errno_location() != int32(9) {
*__errno_location() = int32(25)
if *X__errno_location() != int32(9) {
*X__errno_location() = int32(25)
}
return int32(0)
}
4 changes: 2 additions & 2 deletions lockf.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func lockf(fd int32, op int32, size int64) int32 {
if int32(l.l_type) == int32(2) || l.l_pid == Getpid() {
return int32(0)
}
*__errno_location() = int32(13)
*X__errno_location() = int32(13)
return -1
case int32(0):
l.l_type = int16(2)
Expand All @@ -20,6 +20,6 @@ func lockf(fd int32, op int32, size int64) int32 {
case int32(1):
return fcntl(fd, int32(14), &l)
}
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
return -1
}
4 changes: 2 additions & 2 deletions mmap.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ func _cgos_dummy_mmap() {
func __mmap(start unsafe.Pointer, len uint64, prot int32, flags int32, fd int32, off int64) unsafe.Pointer {
var ret int64
if uint64(off)&4095 != 0 {
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
return unsafe.Pointer(uintptr(18446744073709551615))
}
if len >= uint64(2147483647) {
*__errno_location() = int32(12)
*X__errno_location() = int32(12)
return unsafe.Pointer(uintptr(18446744073709551615))
}
if flags&int32(16) != 0 {
Expand Down
2 changes: 1 addition & 1 deletion mntent.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func getmntent_r(f *Struct__IO_FILE, mnt *struct_mntent, linebuf *int8, buflen i
}
if !(Strchr(linebuf, '\n') != nil) {
Fscanf(f, (*int8)(unsafe.Pointer(&[12]int8{'%', '*', '[', '^', '\n', ']', '%', '*', '[', '\n', ']', '\x00'})))
*__errno_location() = int32(34)
*X__errno_location() = int32(34)
return (*struct_mntent)(nil)
}
cnt = Sscanf(linebuf, (*int8)(unsafe.Pointer(&[39]int8{' ', '%', 'n', '%', '*', 's', '%', 'n', ' ', '%', 'n', '%', '*', 's', '%', 'n', ' ', '%', 'n', '%', '*', 's', '%', 'n', ' ', '%', 'n', '%', '*', 's', '%', 'n', ' ', '%', 'd', ' ', '%', 'd', '\x00'})), (*int32)(unsafe.Pointer(&n)), (*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&n))))+uintptr(int32(1))*4)), (*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&n))))+uintptr(int32(2))*4)), (*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&n))))+uintptr(int32(3))*4)), (*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&n))))+uintptr(int32(4))*4)), (*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&n))))+uintptr(int32(5))*4)), (*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&n))))+uintptr(int32(6))*4)), (*int32)(unsafe.Pointer(uintptr(unsafe.Pointer((*int32)(unsafe.Pointer(&n))))+uintptr(int32(7))*4)), &mnt.mnt_freq, &mnt.mnt_passno)
Expand Down
12 changes: 6 additions & 6 deletions nftw.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func _cgos_do_nftw_nftw(path *int8, fn func(*int8, *struct_stat, int32, *struct_
}()
}
}() != 0 {
if !(flags&int32(1) != 0) && *__errno_location() == int32(2) && !(lstat(path, &st) != 0) {
if !(flags&int32(1) != 0) && *X__errno_location() == int32(2) && !(lstat(path, &st) != 0) {
type_ = int32(7)
} else if *__errno_location() != int32(13) {
} else if *X__errno_location() != int32(13) {
return -1
} else {
type_ = int32(4)
Expand Down Expand Up @@ -88,7 +88,7 @@ func _cgos_do_nftw_nftw(path *int8, fn func(*int8, *struct_stat, int32, *struct_
}
if type_ == int32(2) || type_ == int32(6) {
dfd = open(path, int32(0))
err = *__errno_location()
err = *X__errno_location()
if dfd < int32(0) && err == int32(13) {
type_ = int32(3)
}
Expand All @@ -110,7 +110,7 @@ func _cgos_do_nftw_nftw(path *int8, fn func(*int8, *struct_stat, int32, *struct_
}
if (type_ == int32(2) || type_ == int32(6)) && fd_limit != 0 {
if dfd < int32(0) {
*__errno_location() = err
*X__errno_location() = err
return -1
}
var d *struct___dirstream = fdopendir(dfd)
Expand All @@ -125,7 +125,7 @@ func _cgos_do_nftw_nftw(path *int8, fn func(*int8, *struct_stat, int32, *struct_
continue
}
if Strlen((*int8)(unsafe.Pointer(&de.d_name))) >= uint64(4096)-l {
*__errno_location() = int32(36)
*X__errno_location() = int32(36)
closedir(d)
return -1
}
Expand Down Expand Up @@ -166,7 +166,7 @@ func nftw(path *int8, fn func(*int8, *struct_stat, int32, *struct_FTW) int32, fd
}
l = Strlen(path)
if l > uint64(4096) {
*__errno_location() = int32(36)
*X__errno_location() = int32(36)
return -1
}
Memcpy(unsafe.Pointer((*int8)(unsafe.Pointer(&pathbuf))), unsafe.Pointer(path), l+uint64(1))
Expand Down
2 changes: 1 addition & 1 deletion perror.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import unsafe "unsafe"

func Perror(msg *int8) {
var f *Struct__IO_FILE = &__stderr_FILE
var errstr *int8 = Strerror(*__errno_location())
var errstr *int8 = Strerror(*X__errno_location())
var __need_unlock int32 = func() int32 {
if f.Lock >= int32(0) {
return __lockfile(f)
Expand Down
2 changes: 1 addition & 1 deletion ptsname.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import unsafe "unsafe"
func Ptsname(fd int32) *int8 {
var err int32 = __ptsname_r(fd, (*int8)(unsafe.Pointer(&_cgos_buf_ptsname)), 22)
if err != 0 {
*__errno_location() = err
*X__errno_location() = err
return (*int8)(nil)
}
return (*int8)(unsafe.Pointer(&_cgos_buf_ptsname))
Expand Down
4 changes: 2 additions & 2 deletions pty.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import unsafe "unsafe"

func Posix_openpt(flags int32) int32 {
var r int32 = open((*int8)(unsafe.Pointer(&[10]int8{'/', 'd', 'e', 'v', '/', 'p', 't', 'm', 'x', '\x00'})), flags)
if r < int32(0) && *__errno_location() == int32(28) {
*__errno_location() = int32(11)
if r < int32(0) && *X__errno_location() == int32(28) {
*X__errno_location() = int32(11)
}
return r
}
Expand Down
2 changes: 1 addition & 1 deletion setenv.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func Setenv(var_ *int8, value *int8, overwrite int32) int32 {
*_cgo_addr = uint64(uintptr(unsafe.Pointer(__strchrnul(var_, '='))) - uintptr(unsafe.Pointer(var_)))
return *_cgo_addr
}() != 0) || int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(var_)) + uintptr(l1)))) != 0 {
*__errno_location() = int32(22)
*X__errno_location() = int32(22)
return -1
}
if !(overwrite != 0) && Getenv(var_) != nil {
Expand Down
2 changes: 1 addition & 1 deletion tempnam.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Tempnam(dir *int8, pfx *int8) *int8 {
pl = Strlen(pfx)
l = dl + uint64(1) + pl + uint64(1) + uint64(6)
if l >= uint64(4096) {
*__errno_location() = int32(36)
*X__errno_location() = int32(36)
return (*int8)(nil)
}
Memcpy(unsafe.Pointer((*int8)(unsafe.Pointer(&s))), unsafe.Pointer(dir), dl)
Expand Down
Loading

0 comments on commit 5737a91

Please sign in to comment.