Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sys_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ TEXT syscallX(SB), NOSPLIT, $STACK_SIZE
#ifdef GOOS_darwin
CALL purego_error(SB)
MOVQ PTR_ADDRESS(SP), DI // reload (DI clobbered by call)
MOVQ (AX), AX
MOVLQSX (AX), AX
MOVQ AX, syscallArgs_a3(DI) // save errno
#else
MOVQ $0, syscallArgs_a3(DI) // no errno here: clear the input argument
Expand Down
2 changes: 1 addition & 1 deletion sys_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ TEXT syscallX(SB), NOSPLIT, $0
#ifdef GOOS_darwin
BL purego_error(SB)
MOVD PTR_ADDRESS(RSP), R2 // reload (R2 clobbered by call)
MOVD (R0), R0
MOVW (R0), R0
MOVD R0, syscallArgs_a3(R2) // save errno
#else
MOVD $0, syscallArgs_a3(R2) // no errno here: clear the input argument
Expand Down
4 changes: 4 additions & 0 deletions syscall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"runtime"
"syscall"
"testing"

"github.com/ebitengine/purego"
Expand Down Expand Up @@ -66,6 +67,9 @@ func TestErrno(t *testing.T) {
if int32(r1) != -1 {
t.Errorf("setErrno returned %d, wanted -1", r1)
}
if syscall.Errno(errno) != syscall.ENOENT {
t.Errorf("SyscallN returned errno %#x, wanted %#x", errno, uintptr(syscall.ENOENT))
}

libcName, err := getSystemLibrary()
if err != nil {
Expand Down
Loading