The Go Darwin syscall
package func Read(fd int, p \[\]byte) (n int, err error)
function is making a read
(SYS_READ
) system call:
read Mac OS X Developer Tools Manual Page
ssize_t read(int fildes, void *buf, size_t nbyte);
Read()
attempts to readnbyte
bytes of data from the object referenced by the descriptorfildes
into the buffer pointed to bybuf
.
The Go Darwin syscall
package Syscall
function is:
// func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64);
// Trap # in AX, args in DI SI DX, return in AX DX
TEXT ·Syscall(SB),7,$0
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
MOVQ $0, R10
MOVQ $0, R8
MOVQ $0, R9
MOVQ 8(SP), AX // syscall entry
ADDQ $0x2000000, AX
SYSCALL
JCC ok
MOVQ $-1, 40(SP) // r1
MOVQ $0, 48(SP) // r2
MOVQ AX, 56(SP) // errno
CALL runtime·exitsyscall(SB)
RET
ok:
MOVQ AX, 40(SP) // r1
MOVQ DX, 48(SP) // r2
MOVQ $0, 56(SP) // errno
CALL runtime·exitsyscall(SB)
RET