2011-12-12 16:10:11 -07:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
//
|
|
|
|
// System calls and other sys.stuff for AMD64, NetBSD
|
|
|
|
// /usr/src/sys/kern/syscalls.master for syscall numbers.
|
|
|
|
//
|
|
|
|
|
2011-12-19 13:51:13 -07:00
|
|
|
#include "zasm_GOOS_GOARCH.h"
|
2013-08-07 13:20:05 -06:00
|
|
|
#include "../../cmd/ld/textflag.h"
|
2011-12-12 16:10:11 -07:00
|
|
|
|
2012-05-29 10:52:50 -06:00
|
|
|
// int32 lwp_create(void *context, uintptr flags, void *lwpid)
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·lwp_create(SB),NOSPLIT,$0
|
2012-05-23 19:33:11 -06:00
|
|
|
MOVQ context+0(FP), DI
|
|
|
|
MOVQ flags+8(FP), SI
|
|
|
|
MOVQ lwpid+16(FP), DX
|
|
|
|
MOVL $309, AX // sys__lwp_create
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
2012-05-23 19:33:11 -06:00
|
|
|
JCC 2(PC)
|
2013-03-14 21:42:11 -06:00
|
|
|
NEGQ AX
|
2011-12-12 16:10:11 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·lwp_tramp(SB),NOSPLIT,$0
|
2012-05-23 19:33:11 -06:00
|
|
|
|
2011-12-12 16:10:11 -07:00
|
|
|
// Set FS to point at m->tls.
|
|
|
|
LEAQ m_tls(R8), DI
|
|
|
|
CALL runtime·settls(SB)
|
|
|
|
|
2012-05-23 19:33:11 -06:00
|
|
|
// Set up new stack.
|
2011-12-12 16:10:11 -07:00
|
|
|
get_tls(CX)
|
|
|
|
MOVQ R8, m(CX)
|
|
|
|
MOVQ R9, g(CX)
|
|
|
|
CALL runtime·stackcheck(SB)
|
|
|
|
|
|
|
|
// Call fn
|
|
|
|
CALL R12
|
|
|
|
|
2012-05-23 19:33:11 -06:00
|
|
|
// It shouldn't return. If it does, exit.
|
|
|
|
MOVL $310, AX // sys__lwp_exit
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
JMP -3(PC) // keep exiting
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·osyield(SB),NOSPLIT,$0
|
2012-05-15 11:33:37 -06:00
|
|
|
MOVL $350, AX // sys_sched_yield
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·lwp_park(SB),NOSPLIT,$0
|
2012-05-23 19:33:11 -06:00
|
|
|
MOVQ 8(SP), DI // arg 1 - abstime
|
|
|
|
MOVL 16(SP), SI // arg 2 - unpark
|
|
|
|
MOVQ 24(SP), DX // arg 3 - hint
|
|
|
|
MOVQ 32(SP), R10 // arg 4 - unparkhint
|
|
|
|
MOVL $434, AX // sys__lwp_park
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·lwp_unpark(SB),NOSPLIT,$0
|
2012-05-23 19:33:11 -06:00
|
|
|
MOVQ 8(SP), DI // arg 1 - lwp
|
|
|
|
MOVL 16(SP), SI // arg 2 - hint
|
|
|
|
MOVL $321, AX // sys__lwp_unpark
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·lwp_self(SB),NOSPLIT,$0
|
2012-05-30 11:27:04 -06:00
|
|
|
MOVL $311, AX // sys__lwp_self
|
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2011-12-12 16:10:11 -07:00
|
|
|
// Exit the entire program (like C exit)
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·exit(SB),NOSPLIT,$-8
|
2011-12-12 16:10:11 -07:00
|
|
|
MOVL 8(SP), DI // arg 1 - exit status
|
|
|
|
MOVL $1, AX // sys_exit
|
|
|
|
SYSCALL
|
2012-05-14 19:26:05 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-12-12 16:10:11 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·exit1(SB),NOSPLIT,$-8
|
2012-05-15 11:33:37 -06:00
|
|
|
MOVL $310, AX // sys__lwp_exit
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
2012-05-14 19:26:05 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-12-12 16:10:11 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·open(SB),NOSPLIT,$-8
|
2013-03-12 11:47:44 -06:00
|
|
|
MOVQ 8(SP), DI // arg 1 pathname
|
|
|
|
MOVL 16(SP), SI // arg 2 flags
|
|
|
|
MOVL 20(SP), DX // arg 3 mode
|
|
|
|
MOVL $5, AX
|
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·close(SB),NOSPLIT,$-8
|
2013-03-12 11:47:44 -06:00
|
|
|
MOVL 8(SP), DI // arg 1 fd
|
|
|
|
MOVL $6, AX
|
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·read(SB),NOSPLIT,$-8
|
2013-03-12 11:47:44 -06:00
|
|
|
MOVL 8(SP), DI // arg 1 fd
|
|
|
|
MOVQ 16(SP), SI // arg 2 buf
|
|
|
|
MOVL 24(SP), DX // arg 3 count
|
|
|
|
MOVL $3, AX
|
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·write(SB),NOSPLIT,$-8
|
2011-12-12 16:10:11 -07:00
|
|
|
MOVL 8(SP), DI // arg 1 - fd
|
|
|
|
MOVQ 16(SP), SI // arg 2 - buf
|
|
|
|
MOVL 24(SP), DX // arg 3 - nbyte
|
|
|
|
MOVL $4, AX // sys_write
|
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·usleep(SB),NOSPLIT,$16
|
2011-12-12 16:10:11 -07:00
|
|
|
MOVL $0, DX
|
|
|
|
MOVL usec+0(FP), AX
|
|
|
|
MOVL $1000000, CX
|
|
|
|
DIVL CX
|
|
|
|
MOVQ AX, 0(SP) // tv_sec
|
|
|
|
MOVL $1000, AX
|
|
|
|
MULL DX
|
|
|
|
MOVQ AX, 8(SP) // tv_nsec
|
|
|
|
|
|
|
|
MOVQ SP, DI // arg 1 - rqtp
|
|
|
|
MOVQ $0, SI // arg 2 - rmtp
|
2012-05-15 11:33:37 -06:00
|
|
|
MOVL $430, AX // sys_nanosleep
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·raise(SB),NOSPLIT,$16
|
2012-05-15 11:33:37 -06:00
|
|
|
MOVL $311, AX // sys__lwp_self
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
2012-05-15 11:33:37 -06:00
|
|
|
MOVQ AX, DI // arg 1 - target
|
2013-03-14 23:11:03 -06:00
|
|
|
MOVL sig+0(FP), SI // arg 2 - signo
|
2012-05-15 11:33:37 -06:00
|
|
|
MOVL $318, AX // sys__lwp_kill
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·setitimer(SB),NOSPLIT,$-8
|
2011-12-12 16:10:11 -07:00
|
|
|
MOVL 8(SP), DI // arg 1 - which
|
|
|
|
MOVQ 16(SP), SI // arg 2 - itv
|
|
|
|
MOVQ 24(SP), DX // arg 3 - oitv
|
2012-05-15 11:33:37 -06:00
|
|
|
MOVL $425, AX // sys_setitimer
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
RET
|
|
|
|
|
|
|
|
// func now() (sec int64, nsec int32)
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT time·now(SB), NOSPLIT, $32
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
MOVQ $0, DI // arg 1 - clock_id
|
|
|
|
LEAQ 8(SP), SI // arg 2 - tp
|
|
|
|
MOVL $427, AX // sys_clock_gettime
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
MOVQ 8(SP), AX // sec
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
MOVL 16(SP), DX // nsec
|
2011-12-12 16:10:11 -07:00
|
|
|
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
// sec is in AX, nsec in DX
|
2011-12-12 16:10:11 -07:00
|
|
|
MOVQ AX, sec+0(FP)
|
|
|
|
MOVL DX, nsec+8(FP)
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·nanotime(SB),NOSPLIT,$32
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
MOVQ $0, DI // arg 1 - clock_id
|
|
|
|
LEAQ 8(SP), SI // arg 2 - tp
|
|
|
|
MOVL $427, AX // sys_clock_gettime
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
MOVQ 8(SP), AX // sec
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
MOVL 16(SP), DX // nsec
|
2011-12-12 16:10:11 -07:00
|
|
|
|
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.
Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark old ns/op new ns/op delta
BenchmarkNow 110 118 +7.27%
Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark old ns/op new ns/op delta
BenchmarkNow 625 542 -13.28%
Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark old ns/op new ns/op delta
BenchmarkNow 992 909 -8.37%
FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 699 695 -0.57%
FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1553 1658 +6.76%
OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 1262 1236 -2.06%
OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 5089 5043 -0.90%
NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark old ns/op new ns/op delta
BenchmarkNow 277 278 +0.36%
NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark old ns/op new ns/op delta
BenchmarkNow 103 105 +1.94%
Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.
R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 07:57:25 -07:00
|
|
|
// sec is in AX, nsec in DX
|
2011-12-12 16:10:11 -07:00
|
|
|
// return nsec in AX
|
|
|
|
IMULQ $1000000000, AX
|
|
|
|
ADDQ DX, AX
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·getcontext(SB),NOSPLIT,$-8
|
2012-05-15 12:32:49 -06:00
|
|
|
MOVQ 8(SP), DI // arg 1 - context
|
|
|
|
MOVL $307, AX // sys_getcontext
|
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
|
|
|
MOVL $0xf1, 0xf1 // crash
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigprocmask(SB),NOSPLIT,$0
|
2012-05-15 12:32:49 -06:00
|
|
|
MOVL 8(SP), DI // arg 1 - how
|
|
|
|
MOVQ 16(SP), SI // arg 2 - set
|
|
|
|
MOVQ 24(SP), DX // arg 3 - oset
|
|
|
|
MOVL $293, AX // sys_sigprocmask
|
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
|
|
|
MOVL $0xf1, 0xf1 // crash
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigreturn_tramp(SB),NOSPLIT,$-8
|
2012-05-10 11:48:43 -06:00
|
|
|
MOVQ R15, DI // Load address of ucontext
|
|
|
|
MOVQ $308, AX // sys_setcontext
|
|
|
|
SYSCALL
|
|
|
|
MOVQ $-1, DI // Something failed...
|
|
|
|
MOVL $1, AX // sys_exit
|
|
|
|
SYSCALL
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigaction(SB),NOSPLIT,$-8
|
2011-12-12 16:10:11 -07:00
|
|
|
MOVL 8(SP), DI // arg 1 - signum
|
|
|
|
MOVQ 16(SP), SI // arg 2 - nsa
|
|
|
|
MOVQ 24(SP), DX // arg 3 - osa
|
2012-05-10 11:48:43 -06:00
|
|
|
// arg 4 - tramp
|
|
|
|
LEAQ runtime·sigreturn_tramp(SB), R10
|
2012-08-26 04:57:47 -06:00
|
|
|
MOVQ $2, R8 // arg 5 - vers
|
2012-05-10 11:48:43 -06:00
|
|
|
MOVL $340, AX // sys___sigaction_sigtramp
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
2012-05-14 19:26:05 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-12-12 16:10:11 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigtramp(SB),NOSPLIT,$64
|
2011-12-12 16:10:11 -07:00
|
|
|
get_tls(BX)
|
2012-05-15 12:32:49 -06:00
|
|
|
|
2012-03-12 13:55:18 -06:00
|
|
|
// check that m exists
|
|
|
|
MOVQ m(BX), BP
|
|
|
|
CMPQ BP, $0
|
2013-07-11 14:39:39 -06:00
|
|
|
JNE 5(PC)
|
2012-09-04 12:40:49 -06:00
|
|
|
MOVQ DI, 0(SP)
|
2013-07-11 14:39:39 -06:00
|
|
|
MOVQ $runtime·badsignal(SB), AX
|
|
|
|
CALL AX
|
2012-09-04 12:40:49 -06:00
|
|
|
RET
|
2012-03-12 13:55:18 -06:00
|
|
|
|
2011-12-12 16:10:11 -07:00
|
|
|
// save g
|
|
|
|
MOVQ g(BX), R10
|
|
|
|
MOVQ R10, 40(SP)
|
2012-05-15 12:32:49 -06:00
|
|
|
|
2011-12-12 16:10:11 -07:00
|
|
|
// g = m->signal
|
|
|
|
MOVQ m_gsignal(BP), BP
|
|
|
|
MOVQ BP, g(BX)
|
2012-05-15 12:32:49 -06:00
|
|
|
|
2011-12-12 16:10:11 -07:00
|
|
|
MOVQ DI, 0(SP)
|
|
|
|
MOVQ SI, 8(SP)
|
|
|
|
MOVQ DX, 16(SP)
|
|
|
|
MOVQ R10, 24(SP)
|
2012-05-15 12:32:49 -06:00
|
|
|
|
2011-12-12 16:10:11 -07:00
|
|
|
CALL runtime·sighandler(SB)
|
|
|
|
|
|
|
|
// restore g
|
|
|
|
get_tls(BX)
|
|
|
|
MOVQ 40(SP), R10
|
|
|
|
MOVQ R10, g(BX)
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·mmap(SB),NOSPLIT,$0
|
2011-12-12 16:10:11 -07:00
|
|
|
MOVQ 8(SP), DI // arg 1 - addr
|
|
|
|
MOVQ 16(SP), SI // arg 2 - len
|
|
|
|
MOVL 24(SP), DX // arg 3 - prot
|
|
|
|
MOVL 28(SP), R10 // arg 4 - flags
|
|
|
|
MOVL 32(SP), R8 // arg 5 - fd
|
|
|
|
MOVQ 36(SP), R9
|
|
|
|
SUBQ $16, SP
|
|
|
|
MOVQ R9, 8(SP) // arg 7 - offset (passed on stack)
|
|
|
|
MOVQ $0, R9 // arg 6 - pad
|
2012-05-15 11:33:37 -06:00
|
|
|
MOVL $197, AX // sys_mmap
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
ADDQ $16, SP
|
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·munmap(SB),NOSPLIT,$0
|
2011-12-12 16:10:11 -07:00
|
|
|
MOVQ 8(SP), DI // arg 1 - addr
|
|
|
|
MOVQ 16(SP), SI // arg 2 - len
|
|
|
|
MOVL $73, AX // sys_munmap
|
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
2012-05-14 19:26:05 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-12-12 16:10:11 -07:00
|
|
|
RET
|
|
|
|
|
2012-11-26 04:34:01 -07:00
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·madvise(SB),NOSPLIT,$0
|
2012-11-26 04:34:01 -07:00
|
|
|
MOVQ addr+0(FP), DI // arg 1 - addr
|
|
|
|
MOVQ len+8(FP), SI // arg 2 - len
|
|
|
|
MOVQ behav+16(FP), DX // arg 3 - behav
|
|
|
|
MOVQ $75, AX // sys_madvise
|
|
|
|
SYSCALL
|
2012-12-22 13:06:28 -07:00
|
|
|
// ignore failure - maybe pages are locked
|
2012-11-26 04:34:01 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
|
2011-12-12 16:10:11 -07:00
|
|
|
MOVQ new+8(SP), DI // arg 1 - nss
|
|
|
|
MOVQ old+16(SP), SI // arg 2 - oss
|
2012-05-10 11:48:43 -06:00
|
|
|
MOVQ $281, AX // sys___sigaltstack14
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
2012-05-14 19:26:05 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-12-12 16:10:11 -07:00
|
|
|
RET
|
|
|
|
|
|
|
|
// set tls base to DI
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·settls(SB),NOSPLIT,$8
|
2011-12-12 16:10:11 -07:00
|
|
|
// adjust for ELF: wants to use -16(FS) and -8(FS) for g and m
|
2012-05-14 19:26:05 -06:00
|
|
|
ADDQ $16, DI // arg 1 - ptr
|
|
|
|
MOVQ $317, AX // sys__lwp_setprivate
|
2011-12-12 16:10:11 -07:00
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
2012-05-14 19:26:05 -06:00
|
|
|
MOVL $0xf1, 0xf1 // crash
|
2011-12-12 16:10:11 -07:00
|
|
|
RET
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT runtime·sysctl(SB),NOSPLIT,$0
|
2011-12-12 16:10:11 -07:00
|
|
|
MOVQ 8(SP), DI // arg 1 - name
|
|
|
|
MOVL 16(SP), SI // arg 2 - namelen
|
|
|
|
MOVQ 24(SP), DX // arg 3 - oldp
|
|
|
|
MOVQ 32(SP), R10 // arg 4 - oldlenp
|
|
|
|
MOVQ 40(SP), R8 // arg 5 - newp
|
|
|
|
MOVQ 48(SP), R9 // arg 6 - newlen
|
|
|
|
MOVQ $202, AX // sys___sysctl
|
|
|
|
SYSCALL
|
|
|
|
JCC 3(PC)
|
2013-03-14 21:42:11 -06:00
|
|
|
NEGQ AX
|
2011-12-12 16:10:11 -07:00
|
|
|
RET
|
|
|
|
MOVL $0, AX
|
|
|
|
RET
|
|
|
|
|
2013-08-16 21:11:29 -06:00
|
|
|
// int32 runtime·kqueue(void)
|
|
|
|
TEXT runtime·kqueue(SB),NOSPLIT,$0
|
|
|
|
MOVQ $0, DI
|
|
|
|
MOVL $344, AX
|
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
|
|
|
NEGQ AX
|
|
|
|
RET
|
|
|
|
|
|
|
|
// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout)
|
|
|
|
TEXT runtime·kevent(SB),NOSPLIT,$0
|
|
|
|
MOVL 8(SP), DI
|
|
|
|
MOVQ 16(SP), SI
|
|
|
|
MOVL 24(SP), DX
|
|
|
|
MOVQ 32(SP), R10
|
|
|
|
MOVL 40(SP), R8
|
|
|
|
MOVQ 48(SP), R9
|
|
|
|
MOVL $435, AX
|
|
|
|
SYSCALL
|
|
|
|
JCC 2(PC)
|
|
|
|
NEGQ AX
|
|
|
|
RET
|
|
|
|
|
|
|
|
// void runtime·closeonexec(int32 fd)
|
|
|
|
TEXT runtime·closeonexec(SB),NOSPLIT,$0
|
|
|
|
MOVL 8(SP), DI // fd
|
|
|
|
MOVQ $2, SI // F_SETFD
|
|
|
|
MOVQ $1, DX // FD_CLOEXEC
|
|
|
|
MOVL $92, AX // fcntl
|
|
|
|
SYSCALL
|
|
|
|
RET
|