mirror of
https://github.com/golang/go
synced 2024-11-17 13:44:43 -07:00
runtime: switch runtime to libc for openbsd/arm
Use libc rather than performing direct system calls for the runtime on openbsd/arm. Updates #36435 Change-Id: If64a96a61c80b9748792f8a85a8f16ed6ebca91f Reviewed-on: https://go-review.googlesource.com/c/go/+/315792 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
83df4a590b
commit
603f43cbae
@ -32,6 +32,11 @@ const (
|
||||
|
||||
_PTHREAD_CREATE_DETACHED = 0x1
|
||||
|
||||
_F_SETFD = 0x2
|
||||
_F_GETFL = 0x3
|
||||
_F_SETFL = 0x4
|
||||
_FD_CLOEXEC = 0x1
|
||||
|
||||
_SIGHUP = 0x1
|
||||
_SIGINT = 0x2
|
||||
_SIGQUIT = 0x3
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build openbsd && !386 && !amd64 && !arm64
|
||||
// +build openbsd,!386,!amd64,!arm64
|
||||
//go:build openbsd && !386 && !amd64 && !arm && !arm64
|
||||
// +build openbsd,!386,!amd64,!arm,!arm64
|
||||
|
||||
package runtime
|
||||
|
||||
|
@ -1303,7 +1303,7 @@ func usesLibcall() bool {
|
||||
case "aix", "darwin", "illumos", "ios", "solaris", "windows":
|
||||
return true
|
||||
case "openbsd":
|
||||
return GOARCH == "386" || GOARCH == "amd64" || GOARCH == "arm64"
|
||||
return GOARCH == "386" || GOARCH == "amd64" || GOARCH == "arm" || GOARCH == "arm64"
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build (openbsd && 386) || (openbsd && amd64) || (openbsd && arm64)
|
||||
// +build openbsd,386 openbsd,amd64 openbsd,arm64
|
||||
//go:build (openbsd && 386) || (openbsd && amd64) || (openbsd && arm) || (openbsd && arm64)
|
||||
// +build openbsd,386 openbsd,amd64 openbsd,arm openbsd,arm64
|
||||
|
||||
package runtime
|
||||
|
||||
|
@ -146,6 +146,16 @@ TEXT runtime·pthread_create_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·thrkill_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 - signal
|
||||
MOVW $0, R2 // arg 3 - tcb
|
||||
MOVW 0(R0), R0 // arg 1 - tid
|
||||
CALL libc_thrkill(SB)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·thrsleep_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
SUB $16, R13
|
||||
@ -169,307 +179,289 @@ TEXT runtime·thrwakeup_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·sched_yield_trampoline(SB),NOSPLIT,$0
|
||||
TEXT runtime·exit_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
CALL libc_sched_yield(SB)
|
||||
MOVW 0(R0), R0 // arg 1 exit status
|
||||
BL libc_exit(SB)
|
||||
MOVW $0, R8 // crash on failure
|
||||
MOVW R8, (R8)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
// Exit the entire program (like C exit)
|
||||
TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0
|
||||
MOVW code+0(FP), R0 // arg 1 - status
|
||||
MOVW $1, R12 // sys_exit
|
||||
INVOKE_SYSCALL
|
||||
MOVW.CS $0, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
TEXT runtime·getthrid_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
MOVW R0, R8
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
BL libc_getthrid(SB)
|
||||
MOVW R0, 0(R8)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
// func exitThread(wait *uint32)
|
||||
TEXT runtime·exitThread(SB),NOSPLIT,$0-4
|
||||
MOVW wait+0(FP), R0 // arg 1 - notdead
|
||||
MOVW $302, R12 // sys___threxit
|
||||
INVOKE_SYSCALL
|
||||
MOVW.CS $1, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
JMP 0(PC)
|
||||
|
||||
TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0
|
||||
MOVW name+0(FP), R0 // arg 1 - path
|
||||
MOVW mode+4(FP), R1 // arg 2 - mode
|
||||
MOVW perm+8(FP), R2 // arg 3 - perm
|
||||
MOVW $5, R12 // sys_open
|
||||
INVOKE_SYSCALL
|
||||
MOVW.CS $-1, R0
|
||||
MOVW R0, ret+12(FP)
|
||||
TEXT runtime·raiseproc_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW R0, R4
|
||||
BL libc_getpid(SB) // arg 1 pid
|
||||
MOVW R4, R1 // arg 2 signal
|
||||
BL libc_kill(SB)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0
|
||||
MOVW fd+0(FP), R0 // arg 1 - fd
|
||||
MOVW $6, R12 // sys_close
|
||||
INVOKE_SYSCALL
|
||||
MOVW.CS $-1, R0
|
||||
MOVW R0, ret+4(FP)
|
||||
TEXT runtime·sched_yield_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
BL libc_sched_yield(SB)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0
|
||||
MOVW fd+0(FP), R0 // arg 1 - fd
|
||||
MOVW p+4(FP), R1 // arg 2 - buf
|
||||
MOVW n+8(FP), R2 // arg 3 - nbyte
|
||||
MOVW $3, R12 // sys_read
|
||||
INVOKE_SYSCALL
|
||||
RSB.CS $0, R0 // caller expects negative errno
|
||||
MOVW R0, ret+12(FP)
|
||||
RET
|
||||
|
||||
// func pipe() (r, w int32, errno int32)
|
||||
TEXT runtime·pipe(SB),NOSPLIT,$0-12
|
||||
MOVW $r+0(FP), R0
|
||||
MOVW $263, R12
|
||||
INVOKE_SYSCALL
|
||||
MOVW R0, errno+8(FP)
|
||||
RET
|
||||
|
||||
// func pipe2(flags int32) (r, w int32, errno int32)
|
||||
TEXT runtime·pipe2(SB),NOSPLIT,$0-16
|
||||
MOVW $r+4(FP), R0
|
||||
MOVW flags+0(FP), R1
|
||||
MOVW $101, R12
|
||||
INVOKE_SYSCALL
|
||||
MOVW R0, errno+12(FP)
|
||||
RET
|
||||
|
||||
TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0
|
||||
MOVW fd+0(FP), R0 // arg 1 - fd
|
||||
MOVW p+4(FP), R1 // arg 2 - buf
|
||||
MOVW n+8(FP), R2 // arg 3 - nbyte
|
||||
MOVW $4, R12 // sys_write
|
||||
INVOKE_SYSCALL
|
||||
RSB.CS $0, R0 // caller expects negative errno
|
||||
MOVW R0, ret+12(FP)
|
||||
RET
|
||||
|
||||
TEXT runtime·usleep(SB),NOSPLIT,$16
|
||||
MOVW usec+0(FP), R0
|
||||
CALL runtime·usplitR0(SB)
|
||||
MOVW R0, 4(R13) // tv_sec - l32
|
||||
MOVW $0, R0
|
||||
MOVW R0, 8(R13) // tv_sec - h32
|
||||
MOVW $1000, R2
|
||||
MUL R1, R2
|
||||
MOVW R2, 12(R13) // tv_nsec
|
||||
|
||||
MOVW $4(R13), R0 // arg 1 - rqtp
|
||||
MOVW $0, R1 // arg 2 - rmtp
|
||||
MOVW $91, R12 // sys_nanosleep
|
||||
INVOKE_SYSCALL
|
||||
RET
|
||||
|
||||
TEXT runtime·getthrid(SB),NOSPLIT,$0-4
|
||||
MOVW $299, R12 // sys_getthrid
|
||||
INVOKE_SYSCALL
|
||||
MOVW R0, ret+0(FP)
|
||||
RET
|
||||
|
||||
TEXT runtime·thrkill(SB),NOSPLIT,$0-8
|
||||
MOVW tid+0(FP), R0 // arg 1 - tid
|
||||
MOVW sig+4(FP), R1 // arg 2 - signum
|
||||
MOVW $0, R2 // arg 3 - tcb
|
||||
MOVW $119, R12 // sys_thrkill
|
||||
INVOKE_SYSCALL
|
||||
RET
|
||||
|
||||
TEXT runtime·raiseproc(SB),NOSPLIT,$12
|
||||
MOVW $20, R12 // sys_getpid
|
||||
INVOKE_SYSCALL
|
||||
// arg 1 - pid, already in R0
|
||||
MOVW sig+0(FP), R1 // arg 2 - signum
|
||||
MOVW $122, R12 // sys_kill
|
||||
INVOKE_SYSCALL
|
||||
RET
|
||||
|
||||
TEXT runtime·mmap(SB),NOSPLIT,$16
|
||||
MOVW addr+0(FP), R0 // arg 1 - addr
|
||||
MOVW n+4(FP), R1 // arg 2 - len
|
||||
MOVW prot+8(FP), R2 // arg 3 - prot
|
||||
MOVW flags+12(FP), R3 // arg 4 - flags
|
||||
MOVW fd+16(FP), R4 // arg 5 - fd (on stack)
|
||||
MOVW R4, 4(R13)
|
||||
MOVW $0, R5 // arg 6 - pad (on stack)
|
||||
MOVW R5, 8(R13)
|
||||
MOVW off+20(FP), R6 // arg 7 - offset (on stack)
|
||||
MOVW R6, 12(R13) // lower 32 bits (from Go runtime)
|
||||
MOVW $0, R7
|
||||
MOVW R7, 16(R13) // high 32 bits
|
||||
ADD $4, R13
|
||||
MOVW $197, R12 // sys_mmap
|
||||
INVOKE_SYSCALL
|
||||
SUB $4, R13
|
||||
TEXT runtime·mmap_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
SUB $16, R13
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW R0, R8
|
||||
MOVW 4(R0), R1 // arg 2 len
|
||||
MOVW 8(R0), R2 // arg 3 prot
|
||||
MOVW 12(R0), R3 // arg 4 flags
|
||||
MOVW 16(R0), R4 // arg 5 fid (on stack)
|
||||
MOVW R4, 0(R13)
|
||||
MOVW $0, R5 // pad (on stack)
|
||||
MOVW R5, 4(R13)
|
||||
MOVW 20(R0), R6 // arg 6 offset (on stack)
|
||||
MOVW R6, 8(R13) // low 32 bits
|
||||
MOVW $0, R7
|
||||
MOVW R7, 12(R13) // high 32 bits
|
||||
MOVW 0(R0), R0 // arg 1 addr
|
||||
BL libc_mmap(SB)
|
||||
MOVW $0, R1
|
||||
MOVW.CS R0, R1 // if error, move to R1
|
||||
MOVW.CS $0, R0
|
||||
MOVW R0, p+24(FP)
|
||||
MOVW R1, err+28(FP)
|
||||
CMP $-1, R0
|
||||
BNE ok
|
||||
BL libc_errno(SB)
|
||||
MOVW (R0), R1 // errno
|
||||
MOVW $0, R0
|
||||
ok:
|
||||
MOVW R0, 24(R8)
|
||||
MOVW R1, 28(R8)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·munmap(SB),NOSPLIT,$0
|
||||
MOVW addr+0(FP), R0 // arg 1 - addr
|
||||
MOVW n+4(FP), R1 // arg 2 - len
|
||||
MOVW $73, R12 // sys_munmap
|
||||
INVOKE_SYSCALL
|
||||
MOVW.CS $0, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
TEXT runtime·munmap_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 len
|
||||
MOVW 0(R0), R0 // arg 1 addr
|
||||
BL libc_munmap(SB)
|
||||
CMP $-1, R0
|
||||
BNE 3(PC)
|
||||
MOVW $0, R8 // crash on failure
|
||||
MOVW R8, (R8)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·madvise(SB),NOSPLIT,$0
|
||||
MOVW addr+0(FP), R0 // arg 1 - addr
|
||||
MOVW n+4(FP), R1 // arg 2 - len
|
||||
MOVW flags+8(FP), R2 // arg 2 - flags
|
||||
MOVW $75, R12 // sys_madvise
|
||||
INVOKE_SYSCALL
|
||||
MOVW.CS $-1, R0
|
||||
MOVW R0, ret+12(FP)
|
||||
TEXT runtime·madvise_trampoline(SB), NOSPLIT, $0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 len
|
||||
MOVW 8(R0), R2 // arg 3 advice
|
||||
MOVW 0(R0), R0 // arg 1 addr
|
||||
BL libc_madvise(SB)
|
||||
// ignore failure - maybe pages are locked
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·setitimer(SB),NOSPLIT,$0
|
||||
MOVW mode+0(FP), R0 // arg 1 - mode
|
||||
MOVW new+4(FP), R1 // arg 2 - new value
|
||||
MOVW old+8(FP), R2 // arg 3 - old value
|
||||
MOVW $69, R12 // sys_setitimer
|
||||
INVOKE_SYSCALL
|
||||
TEXT runtime·open_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
SUB $8, R13
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 - flags
|
||||
MOVW 8(R0), R2 // arg 3 - mode (vararg, on stack)
|
||||
MOVW R2, 0(R13)
|
||||
MOVW 0(R0), R0 // arg 1 - path
|
||||
MOVW R13, R4
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
BL libc_open(SB)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
// func walltime() (sec int64, nsec int32)
|
||||
TEXT runtime·walltime(SB), NOSPLIT, $32
|
||||
MOVW CLOCK_REALTIME, R0 // arg 1 - clock_id
|
||||
MOVW $8(R13), R1 // arg 2 - tp
|
||||
MOVW $87, R12 // sys_clock_gettime
|
||||
INVOKE_SYSCALL
|
||||
|
||||
MOVW 8(R13), R0 // sec - l32
|
||||
MOVW 12(R13), R1 // sec - h32
|
||||
MOVW 16(R13), R2 // nsec
|
||||
|
||||
MOVW R0, sec_lo+0(FP)
|
||||
MOVW R1, sec_hi+4(FP)
|
||||
MOVW R2, nsec+8(FP)
|
||||
|
||||
TEXT runtime·close_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 0(R0), R0 // arg 1 - fd
|
||||
BL libc_close(SB)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
// int64 nanotime1(void) so really
|
||||
// void nanotime1(int64 *nsec)
|
||||
TEXT runtime·nanotime1(SB),NOSPLIT,$32
|
||||
MOVW CLOCK_MONOTONIC, R0 // arg 1 - clock_id
|
||||
MOVW $8(R13), R1 // arg 2 - tp
|
||||
MOVW $87, R12 // sys_clock_gettime
|
||||
INVOKE_SYSCALL
|
||||
|
||||
MOVW 8(R13), R0 // sec - l32
|
||||
MOVW 12(R13), R4 // sec - h32
|
||||
MOVW 16(R13), R2 // nsec
|
||||
|
||||
MOVW $1000000000, R3
|
||||
MULLU R0, R3, (R1, R0)
|
||||
MUL R3, R4
|
||||
ADD.S R2, R0
|
||||
ADC R4, R1
|
||||
|
||||
MOVW R0, ret_lo+0(FP)
|
||||
MOVW R1, ret_hi+4(FP)
|
||||
TEXT runtime·read_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 - buf
|
||||
MOVW 8(R0), R2 // arg 3 - count
|
||||
MOVW 0(R0), R0 // arg 1 - fd
|
||||
BL libc_read(SB)
|
||||
CMP $-1, R0
|
||||
BNE noerr
|
||||
BL libc_errno(SB)
|
||||
MOVW (R0), R0 // errno
|
||||
RSB.CS $0, R0 // caller expects negative errno
|
||||
noerr:
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·sigaction(SB),NOSPLIT,$0
|
||||
MOVW sig+0(FP), R0 // arg 1 - signum
|
||||
MOVW new+4(FP), R1 // arg 2 - new sigaction
|
||||
MOVW old+8(FP), R2 // arg 3 - old sigaction
|
||||
MOVW $46, R12 // sys_sigaction
|
||||
INVOKE_SYSCALL
|
||||
MOVW.CS $3, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
TEXT runtime·write_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 buf
|
||||
MOVW 8(R0), R2 // arg 3 count
|
||||
MOVW 0(R0), R0 // arg 1 fd
|
||||
BL libc_write(SB)
|
||||
CMP $-1, R0
|
||||
BNE noerr
|
||||
BL libc_errno(SB)
|
||||
MOVW (R0), R0 // errno
|
||||
RSB.CS $0, R0 // caller expects negative errno
|
||||
noerr:
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·obsdsigprocmask(SB),NOSPLIT,$0
|
||||
MOVW how+0(FP), R0 // arg 1 - mode
|
||||
MOVW new+4(FP), R1 // arg 2 - new
|
||||
MOVW $48, R12 // sys_sigprocmask
|
||||
INVOKE_SYSCALL
|
||||
MOVW.CS $3, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
MOVW R0, ret+8(FP)
|
||||
TEXT runtime·pipe2_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 flags
|
||||
MOVW 0(R0), R0 // arg 1 filedes
|
||||
BL libc_pipe2(SB)
|
||||
CMP $-1, R0
|
||||
BNE 3(PC)
|
||||
BL libc_errno(SB)
|
||||
MOVW (R0), R0 // errno
|
||||
RSB.CS $0, R0 // caller expects negative errno
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·sigaltstack(SB),NOSPLIT,$0
|
||||
MOVW new+0(FP), R0 // arg 1 - new sigaltstack
|
||||
MOVW old+4(FP), R1 // arg 2 - old sigaltstack
|
||||
MOVW $288, R12 // sys_sigaltstack
|
||||
INVOKE_SYSCALL
|
||||
MOVW.CS $0, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
TEXT runtime·setitimer_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 new
|
||||
MOVW 8(R0), R2 // arg 3 old
|
||||
MOVW 0(R0), R0 // arg 1 which
|
||||
BL libc_setitimer(SB)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·sysctl(SB),NOSPLIT,$8
|
||||
MOVW mib+0(FP), R0 // arg 1 - mib
|
||||
MOVW miblen+4(FP), R1 // arg 2 - miblen
|
||||
MOVW out+8(FP), R2 // arg 3 - out
|
||||
MOVW size+12(FP), R3 // arg 4 - size
|
||||
MOVW dst+16(FP), R4 // arg 5 - dest (on stack)
|
||||
MOVW R4, 4(R13)
|
||||
MOVW ndst+20(FP), R5 // arg 6 - newlen (on stack)
|
||||
MOVW R5, 8(R13)
|
||||
ADD $4, R13
|
||||
MOVW $202, R12 // sys___sysctl
|
||||
INVOKE_SYSCALL
|
||||
SUB $4, R13
|
||||
MOVW.CC $0, R0
|
||||
RSB.CS $0, R0
|
||||
MOVW R0, ret+24(FP)
|
||||
TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 0(R0), R0 // arg 1 usec
|
||||
BL libc_usleep(SB)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
// int32 runtime·kqueue(void);
|
||||
TEXT runtime·kqueue(SB),NOSPLIT,$0
|
||||
MOVW $269, R12 // sys_kqueue
|
||||
INVOKE_SYSCALL
|
||||
RSB.CS $0, R0
|
||||
MOVW R0, ret+0(FP)
|
||||
TEXT runtime·sysctl_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
SUB $8, R13
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 miblen
|
||||
MOVW 8(R0), R2 // arg 3 out
|
||||
MOVW 12(R0), R3 // arg 4 size
|
||||
MOVW 16(R0), R4 // arg 5 dst (on stack)
|
||||
MOVW R4, 0(R13)
|
||||
MOVW 20(R0), R5 // arg 6 ndst (on stack)
|
||||
MOVW R5, 4(R13)
|
||||
MOVW 0(R0), R0 // arg 1 mib
|
||||
BL libc_sysctl(SB)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout);
|
||||
TEXT runtime·kevent(SB),NOSPLIT,$8
|
||||
MOVW kq+0(FP), R0 // arg 1 - kq
|
||||
MOVW ch+4(FP), R1 // arg 2 - changelist
|
||||
MOVW nch+8(FP), R2 // arg 3 - nchanges
|
||||
MOVW ev+12(FP), R3 // arg 4 - eventlist
|
||||
MOVW nev+16(FP), R4 // arg 5 - nevents (on stack)
|
||||
MOVW R4, 4(R13)
|
||||
MOVW ts+20(FP), R5 // arg 6 - timeout (on stack)
|
||||
MOVW R5, 8(R13)
|
||||
ADD $4, R13
|
||||
MOVW $72, R12 // sys_kevent
|
||||
INVOKE_SYSCALL
|
||||
RSB.CS $0, R0
|
||||
SUB $4, R13
|
||||
MOVW R0, ret+24(FP)
|
||||
TEXT runtime·kqueue_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
BL libc_kqueue(SB)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
// func closeonexec(fd int32)
|
||||
TEXT runtime·closeonexec(SB),NOSPLIT,$0
|
||||
MOVW fd+0(FP), R0 // arg 1 - fd
|
||||
MOVW $2, R1 // arg 2 - cmd (F_SETFD)
|
||||
MOVW $1, R2 // arg 3 - arg (FD_CLOEXEC)
|
||||
MOVW $92, R12 // sys_fcntl
|
||||
INVOKE_SYSCALL
|
||||
TEXT runtime·kevent_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
SUB $8, R13
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 keventt
|
||||
MOVW 8(R0), R2 // arg 3 nch
|
||||
MOVW 12(R0), R3 // arg 4 ev
|
||||
MOVW 16(R0), R4 // arg 5 nev (on stack)
|
||||
MOVW R4, 0(R13)
|
||||
MOVW 20(R0), R5 // arg 6 ts (on stack)
|
||||
MOVW R5, 4(R13)
|
||||
MOVW 0(R0), R0 // arg 1 kq
|
||||
BL libc_kevent(SB)
|
||||
CMP $-1, R0
|
||||
BNE ok
|
||||
BL libc_errno(SB)
|
||||
MOVW (R0), R0 // errno
|
||||
RSB.CS $0, R0 // caller expects negative errno
|
||||
ok:
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
// func runtime·setNonblock(fd int32)
|
||||
TEXT runtime·setNonblock(SB),NOSPLIT,$0-4
|
||||
MOVW fd+0(FP), R0 // fd
|
||||
MOVW $3, R1 // F_GETFL
|
||||
MOVW $0, R2
|
||||
MOVW $92, R12
|
||||
INVOKE_SYSCALL
|
||||
ORR $0x4, R0, R2 // O_NONBLOCK
|
||||
MOVW fd+0(FP), R0 // fd
|
||||
MOVW $4, R1 // F_SETFL
|
||||
MOVW $92, R12
|
||||
INVOKE_SYSCALL
|
||||
TEXT runtime·clock_gettime_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 tp
|
||||
MOVW 0(R0), R0 // arg 1 clock_id
|
||||
BL libc_clock_gettime(SB)
|
||||
CMP $-1, R0
|
||||
BNE 3(PC)
|
||||
MOVW $0, R8 // crash on failure
|
||||
MOVW R8, (R8)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
SUB $8, R13
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 cmd
|
||||
MOVW 8(R0), R2 // arg 3 arg (vararg, on stack)
|
||||
MOVW R2, 0(R13)
|
||||
MOVW 0(R0), R0 // arg 1 fd
|
||||
BL libc_fcntl(SB)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·sigaction_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 new
|
||||
MOVW 8(R0), R2 // arg 3 old
|
||||
MOVW 0(R0), R0 // arg 1 sig
|
||||
BL libc_sigaction(SB)
|
||||
CMP $-1, R0
|
||||
BNE 3(PC)
|
||||
MOVW $0, R8 // crash on failure
|
||||
MOVW R8, (R8)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·sigprocmask_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 new
|
||||
MOVW 8(R0), R2 // arg 3 old
|
||||
MOVW 0(R0), R0 // arg 1 how
|
||||
BL libc_pthread_sigmask(SB)
|
||||
CMP $-1, R0
|
||||
BNE 3(PC)
|
||||
MOVW $0, R8 // crash on failure
|
||||
MOVW R8, (R8)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
||||
TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT,$0
|
||||
MOVW R13, R9
|
||||
BIC $0x7, R13 // align for ELF ABI
|
||||
MOVW 4(R0), R1 // arg 2 old
|
||||
MOVW 0(R0), R0 // arg 1 new
|
||||
BL libc_sigaltstack(SB)
|
||||
CMP $-1, R0
|
||||
BNE 3(PC)
|
||||
MOVW $0, R8 // crash on failure
|
||||
MOVW R8, (R8)
|
||||
MOVW R9, R13
|
||||
RET
|
||||
|
Loading…
Reference in New Issue
Block a user