Skip to content

Commit

Permalink
runtime: fix nanotime for macOS Sierra, again.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
josharian authored and wheatman committed Jul 9, 2018
1 parent 3de5128 commit 3fb5919
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/runtime/sys_darwin_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,16 @@ timeloop:

systime:
// Fall back to system call (usually first call in this thread)
LEAL 12(SP), AX // must be non-nil, unused
LEAL 16(SP), AX // must be non-nil, unused
MOVL AX, 4(SP)
MOVL $0, 8(SP) // time zone pointer
MOVL $0, 12(SP) // required as of Sierra; Issue 16570
MOVL $116, AX
INT $0x80
CMPL AX, $0
JNE inreg
MOVL 12(SP), AX
MOVL 16(SP), DX
MOVL 16(SP), AX
MOVL 20(SP), DX
inreg:
// sec is in AX, usec in DX
// convert to DX:AX nsec
Expand Down
1 change: 1 addition & 0 deletions src/runtime/sys_darwin_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ systime:
// Fall back to system call (usually first call in this thread).
MOVQ SP, DI
MOVQ $0, SI
MOVQ $0, DX // required as of Sierra; Issue 16570
MOVL $(0x2000000+116), AX
SYSCALL
CMPQ AX, $0
Expand Down

0 comments on commit 3fb5919

Please sign in to comment.