Skip to content

Commit e4a3b8b

Browse files
josharianwheatman
authored andcommitted
runtime: fix nanotime for macOS Sierra, again.
This is a cherry-pick of https://go-review.googlesource.com/25400 to the release-branch-go1.4 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 golang#16570 Change-Id: I714325a7749a145d23cf03251db38196ac9c481a Reviewed-on: https://go-review.googlesource.com/31750 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
1 parent 12aed41 commit e4a3b8b

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
@@ -182,15 +182,16 @@ timeloop:
182182

183183
systime:
184184
// Fall back to system call (usually first call in this thread)
185-
LEAL 12(SP), AX // must be non-nil, unused
185+
LEAL 16(SP), AX // must be non-nil, unused
186186
MOVL AX, 4(SP)
187187
MOVL $0, 8(SP) // time zone pointer
188+
MOVL $0, 12(SP) // required as of Sierra; Issue 16570
188189
MOVL $116, AX
189190
INT $0x80
190191
CMPL AX, $0
191192
JNE inreg
192-
MOVL 12(SP), AX
193-
MOVL 16(SP), DX
193+
MOVL 16(SP), AX
194+
MOVL 20(SP), DX
194195
inreg:
195196
// sec is in AX, usec in DX
196197
// convert to DX:AX nsec

src/runtime/sys_darwin_amd64.s

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ systime:
143143
// Fall back to system call (usually first call in this thread).
144144
MOVQ SP, DI
145145
MOVQ $0, SI
146+
MOVQ $0, DX // required as of Sierra; Issue 16570
146147
MOVL $(0x2000000+116), AX
147148
SYSCALL
148149
CMPQ AX, $0

0 commit comments

Comments
 (0)