Commit c824f540 authored by Elias Naur's avatar Elias Naur Committed by Keith Randall

runtime: move iOS kevent calls to libc

Change-Id: Ie97c9c9163f5af7b4768c34faac726e21627aa79
Reviewed-on: https://go-review.googlesource.com/118660
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 72c29fc8
...@@ -125,6 +125,9 @@ const ( ...@@ -125,6 +125,9 @@ const (
_EVFILT_WRITE = -0x2 _EVFILT_WRITE = -0x2
_PTHREAD_CREATE_DETACHED = 0x2 _PTHREAD_CREATE_DETACHED = 0x2
_F_SETFD = 0x2
_FD_CLOEXEC = 0x1
) )
type machbody struct { type machbody struct {
......
...@@ -123,6 +123,9 @@ const ( ...@@ -123,6 +123,9 @@ const (
_EVFILT_WRITE = -0x2 _EVFILT_WRITE = -0x2
_PTHREAD_CREATE_DETACHED = 0x2 _PTHREAD_CREATE_DETACHED = 0x2
_F_SETFD = 0x2
_FD_CLOEXEC = 0x1
) )
type machbody struct { type machbody struct {
......
...@@ -10,19 +10,6 @@ ...@@ -10,19 +10,6 @@
#include "go_tls.h" #include "go_tls.h"
#include "textflag.h" #include "textflag.h"
// Copied from /usr/include/sys/syscall.h
#define SYS_gettimeofday 116
#define SYS_kill 37
#define SYS_getpid 20
#define SYS_pthread_sigmask 329
#define SYS_setitimer 83
#define SYS___sysctl 202
#define SYS_sigaction 46
#define SYS_sigreturn 184
#define SYS_kqueue 362
#define SYS_kevent 363
#define SYS_fcntl 92
TEXT notok<>(SB),NOSPLIT,$0 TEXT notok<>(SB),NOSPLIT,$0
MOVW $0, R8 MOVW $0, R8
MOVW R8, (R8) MOVW R8, (R8)
...@@ -114,12 +101,11 @@ TEXT runtime·madvise_trampoline(SB),NOSPLIT,$0 ...@@ -114,12 +101,11 @@ TEXT runtime·madvise_trampoline(SB),NOSPLIT,$0
BL.EQ notok<>(SB) BL.EQ notok<>(SB)
RET RET
TEXT runtime·setitimer(SB),NOSPLIT,$0 TEXT runtime·setitimer_trampoline(SB),NOSPLIT,$0
MOVW mode+0(FP), R0 MOVW 4(R0), R1 // arg 2 new
MOVW new+4(FP), R1 MOVW 8(R0), R2 // arg 3 old
MOVW old+8(FP), R2 MOVW 0(R0), R0 // arg 1 which
MOVW $SYS_setitimer, R12 BL libc_setitimer(SB)
SWI $0x80
RET RET
TEXT runtime·walltime_trampoline(SB),NOSPLIT,$0 TEXT runtime·walltime_trampoline(SB),NOSPLIT,$0
...@@ -265,22 +251,18 @@ TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 ...@@ -265,22 +251,18 @@ TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0
TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-0 TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-0
B runtime·armPublicationBarrier(SB) B runtime·armPublicationBarrier(SB)
TEXT runtime·sysctl(SB),NOSPLIT,$0 TEXT runtime·sysctl_trampoline(SB),NOSPLIT,$0
MOVW mib+0(FP), R0 MOVW 4(R0), R1 // arg 2 miblen
MOVW miblen+4(FP), R1 MOVW 8(R0), R2 // arg 3 out
MOVW out+8(FP), R2 MOVW 12(R0), R3 // arg 4 size
MOVW size+12(FP), R3 MOVW 16(R0), R4 // arg 5 dst
MOVW dst+16(FP), R4 MOVW 20(R0), R5 // arg 6 ndst
MOVW ndst+20(FP), R5 MOVW 0(R0), R0 // arg 1 mib
MOVW $SYS___sysctl, R12 // syscall entry // Only R0-R3 are used for arguments, the rest
SWI $0x80 // go on the stack.
BCC sysctl_ret MOVM.DB.W [R4-R5], (R13)
RSB $0, R0, R0 BL libc_sysctl(SB)
MOVW R0, ret+24(FP) ADD $(2*4), R13
RET
sysctl_ret:
MOVW $0, R0
MOVW R0, ret+24(FP)
RET RET
// uint32 mach_msg_trap(void*, uint32, uint32, uint32, uint32, uint32, uint32) // uint32 mach_msg_trap(void*, uint32, uint32, uint32, uint32, uint32, uint32)
...@@ -352,35 +334,37 @@ TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0 ...@@ -352,35 +334,37 @@ TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0
MOVW R0, ret+4(FP) MOVW R0, ret+4(FP)
RET RET
// int32 runtime·kqueue(void) TEXT runtime·kqueue_trampoline(SB),NOSPLIT,$0
TEXT runtime·kqueue(SB),NOSPLIT,$0 BL libc_kqueue(SB)
MOVW $SYS_kqueue, R12
SWI $0x80
RSB.CS $0, R0, R0
MOVW R0, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int events, Timespec *timeout) // int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int events, Timespec *timeout)
TEXT runtime·kevent(SB),NOSPLIT,$0 TEXT runtime·kevent_trampoline(SB),NOSPLIT,$0
MOVW $SYS_kevent, R12 MOVW 4(R0), R1 // arg 2 keventss
MOVW kq+0(FP), R0 MOVW 8(R0), R2 // arg 3 nch
MOVW ch+4(FP), R1 MOVW 12(R0), R3 // arg 4 ev
MOVW nch+8(FP), R2 MOVW 16(R0), R4 // arg 5 nev
MOVW ev+12(FP), R3 MOVW 20(R0), R5 // arg 6 ts
MOVW nev+16(FP), R4 MOVW 0(R0), R0 // arg 1 kq
MOVW ts+20(FP), R5 // Only R0-R3 are used for arguments, the rest
SWI $0x80 // go on the stack.
RSB.CS $0, R0, R0 MOVM.DB.W [R4-R5], (R13)
MOVW R0, ret+24(FP) BL libc_kevent(SB)
ADD $(2*4), R13
MOVW $-1, R2
CMP R0, R2
BNE ok
BL libc_error(SB)
MOVW (R0), R0 // errno
RSB $0, R0, R0 // caller wants it as a negative error code
ok:
RET RET
// int32 runtime·closeonexec(int32 fd) TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0
TEXT runtime·closeonexec(SB),NOSPLIT,$0 MOVW 4(R0), R1 // arg 2 cmd
MOVW $SYS_fcntl, R12 MOVW 8(R0), R2 // arg 3 arg
MOVW fd+0(FP), R0 MOVW 0(R0), R0 // arg 1 fd
MOVW $2, R1 // F_SETFD BL libc_fcntl(SB)
MOVW $1, R2 // FD_CLOEXEC
SWI $0x80
RET RET
// sigaltstack is not supported on iOS, so our sigtramp has // sigaltstack is not supported on iOS, so our sigtramp has
......
...@@ -10,19 +10,6 @@ ...@@ -10,19 +10,6 @@
#include "go_tls.h" #include "go_tls.h"
#include "textflag.h" #include "textflag.h"
// Copied from /usr/include/sys/syscall.h
#define SYS_gettimeofday 116
#define SYS_kill 37
#define SYS_getpid 20
#define SYS_pthread_sigmask 329
#define SYS_setitimer 83
#define SYS___sysctl 202
#define SYS_sigaction 46
#define SYS_sigreturn 184
#define SYS_kqueue 362
#define SYS_kevent 363
#define SYS_fcntl 92
TEXT notok<>(SB),NOSPLIT,$0 TEXT notok<>(SB),NOSPLIT,$0
MOVD $0, R8 MOVD $0, R8
MOVD R8, (R8) MOVD R8, (R8)
...@@ -106,12 +93,11 @@ TEXT runtime·madvise_trampoline(SB),NOSPLIT,$0 ...@@ -106,12 +93,11 @@ TEXT runtime·madvise_trampoline(SB),NOSPLIT,$0
BL libc_madvise(SB) BL libc_madvise(SB)
RET RET
TEXT runtime·setitimer(SB),NOSPLIT,$0 TEXT runtime·setitimer_trampoline(SB),NOSPLIT,$0
MOVW mode+0(FP), R0 MOVD 8(R0), R1 // arg 2 new
MOVD new+8(FP), R1 MOVD 16(R0), R2 // arg 3 old
MOVD old+16(FP), R2 MOVW 0(R0), R0 // arg 1 which
MOVW $SYS_setitimer, R16 BL libc_setitimer(SB)
SVC $0x80
RET RET
TEXT runtime·walltime_trampoline(SB),NOSPLIT,$0 TEXT runtime·walltime_trampoline(SB),NOSPLIT,$0
...@@ -262,22 +248,14 @@ TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 ...@@ -262,22 +248,14 @@ TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0
BL libc_usleep(SB) BL libc_usleep(SB)
RET RET
TEXT runtime·sysctl(SB),NOSPLIT,$0 TEXT runtime·sysctl_trampoline(SB),NOSPLIT,$0
MOVD mib+0(FP), R0 MOVW 8(R0), R1 // arg 2 miblen
MOVW miblen+8(FP), R1 MOVD 16(R0), R2 // arg 3 out
MOVD out+16(FP), R2 MOVD 24(R0), R3 // arg 4 size
MOVD size+24(FP), R3 MOVD 32(R0), R4 // arg 5 dst
MOVD dst+32(FP), R4 MOVD 40(R0), R5 // arg 6 ndst
MOVD ndst+40(FP), R5 MOVD 0(R0), R0 // arg 1 mib
MOVW $SYS___sysctl, R16 BL libc_sysctl(SB)
SVC $0x80
BCC ok
NEG R0, R0
MOVW R0, ret+48(FP)
RET
ok:
MOVW $0, R0
MOVW R0, ret+48(FP)
RET RET
// uint32 mach_msg_trap(void*, uint32, uint32, uint32, uint32, uint32, uint32) // uint32 mach_msg_trap(void*, uint32, uint32, uint32, uint32, uint32, uint32)
...@@ -349,37 +327,32 @@ TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0 ...@@ -349,37 +327,32 @@ TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0
MOVW R0, ret+8(FP) MOVW R0, ret+8(FP)
RET RET
// int32 runtime·kqueue(void) TEXT runtime·kqueue_trampoline(SB),NOSPLIT,$0
TEXT runtime·kqueue(SB),NOSPLIT,$0 BL libc_kqueue(SB)
MOVW $SYS_kqueue, R16
SVC $0x80
BCC 2(PC)
NEG R0, R0
MOVW R0, ret+0(FP)
RET RET
// int32 runtime·kevent(int kq, Kevent *ch, int nch, Kevent *ev, int nev, Timespec *ts) TEXT runtime·kevent_trampoline(SB),NOSPLIT,$0
TEXT runtime·kevent(SB),NOSPLIT,$0 MOVD 8(R0), R1 // arg 2 keventt
MOVW kq+0(FP), R0 MOVW 16(R0), R2 // arg 3 nch
MOVD ch+8(FP), R1 MOVD 24(R0), R3 // arg 4 ev
MOVW nch+16(FP), R2 MOVW 32(R0), R4 // arg 5 nev
MOVD ev+24(FP), R3 MOVD 40(R0), R5 // arg 6 ts
MOVW nev+32(FP), R4 MOVW 0(R0), R0 // arg 1 kq
MOVD ts+40(FP), R5 BL libc_kevent(SB)
MOVW $SYS_kevent, R16 MOVD $-1, R2
SVC $0x80 CMP R0, R2
BCC 2(PC) BNE ok
NEG R0, R0 BL libc_error(SB)
MOVW R0, ret+48(FP) MOVD (R0), R0 // errno
NEG R0, R0 // caller wants it as a negative error code
ok:
RET RET
// int32 runtime·closeonexec(int32 fd) TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0
TEXT runtime·closeonexec(SB),NOSPLIT,$0 MOVW 4(R0), R1 // arg 2 cmd
MOVW fd+0(FP), R0 MOVW 8(R0), R2 // arg 3 arg
MOVW $2, R1 // F_SETFD MOVW 0(R0), R0 // arg 1 fd
MOVW $1, R2 // FD_CLOEXEC BL libc_fcntl(SB)
MOVW $SYS_fcntl, R16
SVC $0x80
RET RET
// sigaltstack on iOS is not supported and will always // sigaltstack on iOS is not supported and will always
......
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