mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 06:53:40 +00:00
cgo: support errno value as second return parameter
Making this work on all targets was interesting but there's now a test in place to make sure this works on all targets that have the CGo test enabled (which is almost all targets).
This commit is contained in:
@@ -151,7 +151,7 @@ func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
|
||||
r1 = uintptr(result)
|
||||
if result == -1 {
|
||||
// Syscall returns -1 on failure.
|
||||
err = uintptr(*libc___error())
|
||||
err = uintptr(*libc_errno_location())
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -161,7 +161,7 @@ func syscall_syscallX(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
|
||||
r1 = call_syscallX(fn, a1, a2, a3)
|
||||
if int64(r1) == -1 {
|
||||
// Syscall returns -1 on failure.
|
||||
err = uintptr(*libc___error())
|
||||
err = uintptr(*libc_errno_location())
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -171,7 +171,7 @@ func syscall_syscallPtr(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
|
||||
r1 = call_syscallX(fn, a1, a2, a3)
|
||||
if r1 == 0 {
|
||||
// Syscall returns a pointer on success, or NULL on failure.
|
||||
err = uintptr(*libc___error())
|
||||
err = uintptr(*libc_errno_location())
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
|
||||
r1 = uintptr(result)
|
||||
if result == -1 {
|
||||
// Syscall returns -1 on failure.
|
||||
err = uintptr(*libc___error())
|
||||
err = uintptr(*libc_errno_location())
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -192,7 +192,7 @@ func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
|
||||
r1 = call_syscall6X(fn, a1, a2, a3, a4, a5, a6)
|
||||
if int64(r1) == -1 {
|
||||
// Syscall returns -1 on failure.
|
||||
err = uintptr(*libc___error())
|
||||
err = uintptr(*libc_errno_location())
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -216,7 +216,7 @@ func libc_getpagesize() int32
|
||||
// }
|
||||
//
|
||||
//export __error
|
||||
func libc___error() *int32
|
||||
func libc_errno_location() *int32
|
||||
|
||||
//export tinygo_syscall
|
||||
func call_syscall(fn, a1, a2, a3 uintptr) int32
|
||||
|
||||
Reference in New Issue
Block a user