aboutsummaryrefslogblamecommitdiffstats
path: root/wireguard-go-bridge/goruntime-boottime-over-monotonic.diff
blob: e449ac4e1126caa4f93eeec9c1f83a36b0c49a1b (plain) (tree)




































                                                                                                    







                                                            




                                                                            







                                                                        




                                                                        







                                                         




                                                                            
 









                                                           
From 74523c5a12d37fa792e77a252bcc569484c3d41a Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Wed, 27 Feb 2019 05:33:01 +0100
Subject: [PATCH] runtime: use libc_mach_continuous_time in nanotime on Darwin

This makes timers account for having expired while a computer was
asleep, which is quite common on mobile devices. Note that
continuous_time absolute_time, except that it takes into account
time spent in suspend.

Fixes #24595
---
 src/runtime/sys_darwin.go      | 2 +-
 src/runtime/sys_darwin_386.s   | 2 +-
 src/runtime/sys_darwin_amd64.s | 2 +-
 src/runtime/sys_darwin_arm.s   | 2 +-
 src/runtime/sys_darwin_arm64.s | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/runtime/sys_darwin.go b/src/runtime/sys_darwin.go
index f34ac88352..416fcb673f 100644
--- a/src/runtime/sys_darwin.go
+++ b/src/runtime/sys_darwin.go
@@ -403,7 +403,7 @@ func closeonexec(fd int32) {
 //go:cgo_import_dynamic libc_usleep usleep "/usr/lib/libSystem.B.dylib"
 
 //go:cgo_import_dynamic libc_mach_timebase_info mach_timebase_info "/usr/lib/libSystem.B.dylib"
-//go:cgo_import_dynamic libc_mach_absolute_time mach_absolute_time "/usr/lib/libSystem.B.dylib"
+//go:cgo_import_dynamic libc_mach_continuous_time mach_continuous_time "/usr/lib/libSystem.B.dylib"
 //go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
 //go:cgo_import_dynamic libc_sigaction sigaction "/usr/lib/libSystem.B.dylib"
 //go:cgo_import_dynamic libc_pthread_sigmask pthread_sigmask "/usr/lib/libSystem.B.dylib"
diff --git a/src/runtime/sys_darwin_386.s b/src/runtime/sys_darwin_386.s
index 1bc1a63c28..34a3561350 100644
--- a/src/runtime/sys_darwin_386.s
+++ b/src/runtime/sys_darwin_386.s
@@ -184,7 +184,7 @@ TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
 	PUSHL	BP
 	MOVL	SP, BP
 	SUBL	$8+(machTimebaseInfo__size+15)/16*16, SP
-	CALL	libc_mach_absolute_time(SB)
+	CALL	libc_mach_continuous_time(SB)
 	MOVL	16+(machTimebaseInfo__size+15)/16*16(SP), CX
 	MOVL	AX, 0(CX)
 	MOVL	DX, 4(CX)
diff --git a/src/runtime/sys_darwin_amd64.s b/src/runtime/sys_darwin_amd64.s
index f99cb00ab8..8b99316983 100644
--- a/src/runtime/sys_darwin_amd64.s
+++ b/src/runtime/sys_darwin_amd64.s
@@ -86,7 +86,7 @@ TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
 	PUSHQ	BP
 	MOVQ	SP, BP
 	MOVQ	DI, BX
-	CALL	libc_mach_absolute_time(SB)
+	CALL	libc_mach_continuous_time(SB)
 	MOVQ	AX, 0(BX)
 	MOVL	timebase<>+machTimebaseInfo_numer(SB), SI
 	MOVL	timebase<>+machTimebaseInfo_denom(SB), DI // atomic read
diff --git a/src/runtime/sys_darwin_arm.s b/src/runtime/sys_darwin_arm.s
index 54c7afbf34..a4f06fdb85 100644
--- a/src/runtime/sys_darwin_arm.s
+++ b/src/runtime/sys_darwin_arm.s
@@ -118,7 +118,7 @@ GLOBL timebase<>(SB),NOPTR,$(machTimebaseInfo__size)
 
 TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
 	MOVW	R0, R8
-	BL	libc_mach_absolute_time(SB)
+	BL	libc_mach_continuous_time(SB)
 	MOVW	R0, 0(R8)
 	MOVW	R1, 4(R8)
 	MOVW	timebase<>+machTimebaseInfo_numer(SB), R6
diff --git a/src/runtime/sys_darwin_arm64.s b/src/runtime/sys_darwin_arm64.s
index 29951d8ad7..cdaf0a630e 100644
--- a/src/runtime/sys_darwin_arm64.s
+++ b/src/runtime/sys_darwin_arm64.s
@@ -113,7 +113,7 @@ GLOBL timebase<>(SB),NOPTR,$(machTimebaseInfo__size)
 
 TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$40
 	MOVD	R0, R19
-	BL	libc_mach_absolute_time(SB)
+	BL	libc_mach_continuous_time(SB)
 	MOVD	R0, 0(R19)
 	MOVW	timebase<>+machTimebaseInfo_numer(SB), R20
 	MOVD	$timebase<>+machTimebaseInfo_denom(SB), R21
-- 
2.20.1