| 1 |
// Copyright 2009 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
#include "textflag.h" |
| 6 |
#include "funcdata.h" |
| 7 |
|
| 8 |
// |
| 9 |
// System calls for AMD64, Linux |
| 10 |
// |
| 11 |
|
| 12 |
#define SYS_gettimeofday 96 |
| 13 |
|
| 14 |
// func rawVforkSyscall(trap, a1, a2, a3 uintptr) (r1, err uintptr) |
| 15 |
TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-48 |
| 16 |
MOVQ a1+8(FP), DI |
| 17 |
MOVQ a2+16(FP), SI |
| 18 |
MOVQ a3+24(FP), DX |
| 19 |
MOVQ $0, R10 |
| 20 |
MOVQ $0, R8 |
| 21 |
MOVQ $0, R9 |
| 22 |
MOVQ trap+0(FP), AX // syscall entry |
| 23 |
POPQ R12 // preserve return address |
| 24 |
SYSCALL |
| 25 |
PUSHQ R12 |
| 26 |
CMPQ AX, $0xfffffffffffff001 |
| 27 |
JLS ok2 |
| 28 |
MOVQ $-1, r1+32(FP) |
| 29 |
NEGQ AX |
| 30 |
MOVQ AX, err+40(FP) |
| 31 |
RET |
| 32 |
ok2: |
| 33 |
MOVQ AX, r1+32(FP) |
| 34 |
MOVQ $0, err+40(FP) |
| 35 |
RET |
| 36 |
|
| 37 |
// func rawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) |
| 38 |
TEXT ·rawSyscallNoError(SB),NOSPLIT,$0-48 |
| 39 |
MOVQ a1+8(FP), DI |
| 40 |
MOVQ a2+16(FP), SI |
| 41 |
MOVQ a3+24(FP), DX |
| 42 |
MOVQ trap+0(FP), AX // syscall entry |
| 43 |
SYSCALL |
| 44 |
MOVQ AX, r1+32(FP) |
| 45 |
MOVQ DX, r2+40(FP) |
| 46 |
RET |
| 47 |
|
| 48 |
// func gettimeofday(tv *Timeval) (err uintptr) |
| 49 |
TEXT ·gettimeofday(SB),NOSPLIT,$0-16 |
| 50 |
// Usually, we'd check if we're running |
| 51 |
// secret code here, but because we execute |
| 52 |
// gettimeofday on the G stack, it's fine to leave |
| 53 |
// the registers uncleared |
| 54 |
MOVQ tv+0(FP), DI |
| 55 |
MOVQ $0, SI |
| 56 |
MOVQ runtime·vdsoGettimeofdaySym(SB), AX |
| 57 |
TESTQ AX, AX |
| 58 |
JZ fallback |
| 59 |
CALL AX |
| 60 |
ret: |
| 61 |
CMPQ AX, $0xfffffffffffff001 |
| 62 |
JLS ok7 |
| 63 |
NEGQ AX |
| 64 |
MOVQ AX, err+8(FP) |
| 65 |
RET |
| 66 |
fallback: |
| 67 |
MOVL $SYS_gettimeofday, AX |
| 68 |
SYSCALL |
| 69 |
JMP ret |
| 70 |
ok7: |
| 71 |
MOVQ $0, err+8(FP) |
| 72 |
RET |