Commit 16d1a8e6 authored by Keith Randall's avatar Keith Randall

runtime: move open/close/read/write from syscall to libc on Darwin

Update #17490

Change-Id: Ia0bb0ba10dc0bbb299290a60b8228275d55125d7
Reviewed-on: https://go-review.googlesource.com/110438
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent ce5c3871
......@@ -86,6 +86,11 @@ func pthread_self_trampoline() pthread
//go:cgo_import_dynamic libc_pthread_kill pthread_kill "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic libc_pthread_self pthread_self "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic libc_close close "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic libc_read read "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic libc_write write "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic libc_mmap mmap "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic libc_munmap munmap "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic libc_madvise madvise "/usr/lib/libSystem.B.dylib"
......
......@@ -29,35 +29,67 @@ TEXT runtime·exitThread(SB),NOSPLIT,$0-4
MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·open(SB),NOSPLIT,$0
MOVL $5, AX
INT $0x80
JAE 2(PC)
MOVL $-1, AX
TEXT runtime·open(SB),NOSPLIT,$0-16
MOVL name+0(FP), AX // arg 1 name
MOVL mode+4(FP), CX // arg 2 mode
MOVL perm+8(FP), DX // arg 3 perm
PUSHL BP
MOVL SP, BP
SUBL $12, SP
ANDL $~15, SP
MOVL AX, 0(SP)
MOVL CX, 4(SP)
MOVL DX, 8(SP)
CALL libc_open(SB)
MOVL BP, SP
POPL BP
MOVL AX, ret+12(FP)
RET
TEXT runtime·closefd(SB),NOSPLIT,$0
MOVL $6, AX
INT $0x80
JAE 2(PC)
MOVL $-1, AX
TEXT runtime·closefd(SB),NOSPLIT,$0-8
MOVL fd+0(FP), AX // arg 1 fd
PUSHL BP
MOVL SP, BP
SUBL $4, SP
ANDL $~15, SP
MOVL AX, 0(SP)
CALL libc_close(SB)
MOVL BP, SP
POPL BP
MOVL AX, ret+4(FP)
RET
TEXT runtime·read(SB),NOSPLIT,$0
MOVL $3, AX
INT $0x80
JAE 2(PC)
MOVL $-1, AX
TEXT runtime·read(SB),NOSPLIT,$0-16
MOVL fd+0(FP), AX // arg 1 fd
MOVL p+4(FP), CX // arg 2 buf
MOVL n+8(FP), DX // arg 3 count
PUSHL BP
MOVL SP, BP
SUBL $12, SP
ANDL $~15, SP
MOVL AX, 0(SP)
MOVL CX, 4(SP)
MOVL DX, 8(SP)
CALL libc_read(SB)
MOVL BP, SP
POPL BP
MOVL AX, ret+12(FP)
RET
TEXT runtime·write(SB),NOSPLIT,$0
MOVL $4, AX
INT $0x80
JAE 2(PC)
MOVL $-1, AX
TEXT runtime·write(SB),NOSPLIT,$0-16
MOVL fd+0(FP), AX // arg 1 fd
MOVL p+4(FP), CX // arg 2 buf
MOVL n+8(FP), DX // arg 3 count
PUSHL BP
MOVL SP, BP
SUBL $12, SP
ANDL $~15, SP
MOVL AX, 0(SP)
MOVL CX, 4(SP)
MOVL DX, 8(SP)
CALL libc_write(SB)
MOVL BP, SP
POPL BP
MOVL AX, ret+12(FP)
RET
......
......@@ -32,45 +32,53 @@ TEXT runtime·exitThread(SB),NOSPLIT,$0-8
MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·open(SB),NOSPLIT,$0
TEXT runtime·open(SB),NOSPLIT,$0-20
MOVQ name+0(FP), DI // arg 1 pathname
MOVL mode+8(FP), SI // arg 2 flags
MOVL perm+12(FP), DX // arg 3 mode
MOVL $(0x2000000+5), AX // syscall entry
SYSCALL
JCC 2(PC)
MOVL $-1, AX
PUSHQ BP
MOVQ SP, BP
ANDQ $~15, SP // align stack
CALL libc_open(SB)
MOVQ BP, SP
POPQ BP
MOVL AX, ret+16(FP)
RET
TEXT runtime·closefd(SB),NOSPLIT,$0
TEXT runtime·closefd(SB),NOSPLIT,$0-12
MOVL fd+0(FP), DI // arg 1 fd
MOVL $(0x2000000+6), AX // syscall entry
SYSCALL
JCC 2(PC)
MOVL $-1, AX
PUSHQ BP
MOVQ SP, BP
ANDQ $~15, SP // align stack
CALL libc_close(SB)
MOVQ BP, SP
POPQ BP
MOVL AX, ret+8(FP)
RET
TEXT runtime·read(SB),NOSPLIT,$0
TEXT runtime·read(SB),NOSPLIT,$0-28
MOVL fd+0(FP), DI // arg 1 fd
MOVQ p+8(FP), SI // arg 2 buf
MOVL n+16(FP), DX // arg 3 count
MOVL $(0x2000000+3), AX // syscall entry
SYSCALL
JCC 2(PC)
MOVL $-1, AX
PUSHQ BP
MOVQ SP, BP
ANDQ $~15, SP // align stack
CALL libc_read(SB)
MOVQ BP, SP
POPQ BP
MOVL AX, ret+24(FP)
RET
TEXT runtime·write(SB),NOSPLIT,$0
TEXT runtime·write(SB),NOSPLIT,$0-28
MOVQ fd+0(FP), DI // arg 1 fd
MOVQ p+8(FP), SI // arg 2 buf
MOVL n+16(FP), DX // arg 3 count
MOVL $(0x2000000+4), AX // syscall entry
SYSCALL
JCC 2(PC)
MOVL $-1, AX
PUSHQ BP
MOVQ SP, BP
ANDQ $~15, SP // align stack
CALL libc_write(SB)
MOVQ BP, SP
POPQ BP
MOVL AX, ret+24(FP)
RET
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment