clock_id int32
tp unsafe.Pointer
}{_CLOCK_MONOTONIC, unsafe.Pointer(&ts)}
- libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args))
+ if errno := libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args)); errno < 0 {
+ // Avoid growing the nosplit stack.
+ systemstack(func() {
+ println("runtime: errno", -errno)
+ throw("clock_gettime failed")
+ })
+ }
return ts.tv_sec*1e9 + int64(ts.tv_nsec)
}
func clock_gettime_trampoline()
clock_id int32
tp unsafe.Pointer
}{_CLOCK_REALTIME, unsafe.Pointer(&ts)}
- libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args))
+ if errno := libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args)); errno < 0 {
+ // Avoid growing the nosplit stack.
+ systemstack(func() {
+ println("runtime: errno", -errno)
+ throw("clock_gettime failed")
+ })
+ }
return ts.tv_sec, int32(ts.tv_nsec)
}
MOVL BX, 4(SP) // arg 2 - clock_id
CALL libc_clock_gettime(SB)
CMPL AX, $-1
- JNE 2(PC)
- MOVL $0xf1, 0xf1 // crash on failure
+ JNE noerr
+ CALL libc_errno(SB)
+ MOVL (AX), AX
+ NEGL AX // caller expects negative errno
+noerr:
MOVL BP, SP
POPL BP
RET
MOVL 0(DI), DI // arg 1 clock_id
CALL libc_clock_gettime(SB)
TESTL AX, AX
- JEQ 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ JEQ noerr
+ CALL libc_errno(SB)
+ MOVL (AX), AX // errno
+ NEGL AX // caller expects negative errno value
+noerr:
POPQ BP
RET
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)
+ BNE noerr
+ BL libc_errno(SB)
+ MOVW (R0), R0 // errno
+ RSB.CS $0, R0 // caller expects negative errno
+noerr:
MOVW R9, R13
RET
MOVD 0(R0), R0 // arg 1 - clock_id
CALL libc_clock_gettime(SB)
CMP $-1, R0
- BNE 3(PC)
- MOVD $0, R0 // crash on failure
- MOVD R0, (R0)
+ BNE noerr
+ CALL libc_errno(SB)
+ MOVW (R0), R0 // errno
+ NEG R0, R0 // caller expects negative errno value
+noerr:
RET
TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0