Skip to content

Commit 2da5633

Browse files
committed
runtime: fix nanotime for macOS Sierra, again.
macOS Sierra beta4 changed the kernel interface for getting time. DX now optionally points to an address for additional info. Set it to zero to avoid corrupting memory. Fixes #16570 Change-Id: I9f537e552682045325cdbb68b7d0b4ddafade14a Reviewed-on: https://go-review.googlesource.com/25400 Reviewed-by: David Crawshaw <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Quentin Smith <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> Reviewed-by: Austin Clements <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 6317c21 commit 2da5633

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/runtime/sys_darwin_386.s

+4-3
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,16 @@ timeloop:
196196

197197
systime:
198198
// Fall back to system call (usually first call in this thread)
199-
LEAL 12(SP), AX // must be non-nil, unused
199+
LEAL 16(SP), AX // must be non-nil, unused
200200
MOVL AX, 4(SP)
201201
MOVL $0, 8(SP) // time zone pointer
202+
MOVL $0, 12(SP) // required as of Sierra; Issue 16570
202203
MOVL $116, AX
203204
INT $0x80
204205
CMPL AX, $0
205206
JNE inreg
206-
MOVL 12(SP), AX
207-
MOVL 16(SP), DX
207+
MOVL 16(SP), AX
208+
MOVL 20(SP), DX
208209
inreg:
209210
// sec is in AX, usec in DX
210211
// convert to DX:AX nsec

src/runtime/sys_darwin_amd64.s

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ systime:
157157
// Fall back to system call (usually first call in this thread).
158158
MOVQ SP, DI
159159
MOVQ $0, SI
160+
MOVQ $0, DX // required as of Sierra; Issue 16570
160161
MOVL $(0x2000000+116), AX
161162
SYSCALL
162163
CMPQ AX, $0

0 commit comments

Comments
 (0)