View
@@ -439,7 +439,8 @@ func schedinit() {
stackinit()
mallocinit()
mcommoninit(_g_.m)
typelinksinit()
alginit() // maps must not be used before this call
typelinksinit() // uses maps
itabsinit()
msigsave(_g_.m)
View
@@ -12,13 +12,18 @@ TEXT _rt0_amd64_linux(SB),NOSPLIT,$-8
// When building with -buildmode=c-shared, this symbol is called when the shared
// library is loaded.
TEXT _rt0_amd64_linux_lib(SB),NOSPLIT,$0x48
// Note: This function calls external C code, which might required 16-byte stack
// alignment after cmd/internal/obj applies its transformations.
TEXT _rt0_amd64_linux_lib(SB),NOSPLIT,$0x50
MOVQ SP, AX
ANDQ $-16, SP
MOVQ BX, 0x10(SP)
MOVQ BP, 0x18(SP)
MOVQ R12, 0x20(SP)
MOVQ R13, 0x28(SP)
MOVQ R14, 0x30(SP)
MOVQ R15, 0x38(SP)
MOVQ AX, 0x40(SP)
MOVQ DI, _rt0_amd64_linux_lib_argc<>(SB)
MOVQ SI, _rt0_amd64_linux_lib_argv<>(SB)
@@ -50,6 +55,7 @@ restore:
MOVQ 0x28(SP), R13
MOVQ 0x30(SP), R14
MOVQ 0x38(SP), R15
MOVQ 0x40(SP), SP
RET
TEXT _rt0_amd64_linux_lib_go(SB),NOSPLIT,$0
View
@@ -162,11 +162,15 @@ TEXT runtime·mincore(SB),NOSPLIT,$0
TEXT time·now(SB), 7, $32
MOVW $8(R13), R0 // timeval
MOVW $0, R1 // zone
MOVW $0, R2 // see issue 16570
MOVW $SYS_gettimeofday, R12
SWI $0x80 // Note: R0 is tv_sec, R1 is tv_usec
CMP $0, R0
BNE inreg
MOVW 8(R13), R0
MOVW 12(R13), R1
inreg:
MOVW R1, R2 // usec
MOVW R0, sec+0(FP)
MOVW $0, R1
MOVW R1, loc+4(FP)
@@ -178,9 +182,14 @@ TEXT time·now(SB), 7, $32
TEXT runtime·nanotime(SB),NOSPLIT,$32
MOVW $8(R13), R0 // timeval
MOVW $0, R1 // zone
MOVW $0, R2 // see issue 16570
MOVW $SYS_gettimeofday, R12
SWI $0x80 // Note: R0 is tv_sec, R1 is tv_usec
CMP $0, R0
BNE inreg
MOVW 8(R13), R0
MOVW 12(R13), R1
inreg:
MOVW R1, R2
MOVW $1000000000, R3
MULLU R0, R3, (R1, R0)
View
@@ -155,9 +155,14 @@ TEXT time·now(SB),NOSPLIT,$40-12
MOVD RSP, R0 // timeval
MOVD R0, R9 // this is how dyld calls gettimeofday
MOVW $0, R1 // zone
MOVD $0, R2 // see issue 16570
MOVW $SYS_gettimeofday, R16
SVC $0x80 // Note: x0 is tv_sec, w1 is tv_usec
CMP $0, R0
BNE inreg
MOVD 0(RSP), R0
MOVW 8(RSP), R1
inreg:
MOVD R0, sec+0(FP)
MOVW $1000, R3
MUL R3, R1
@@ -168,9 +173,14 @@ TEXT runtime·nanotime(SB),NOSPLIT,$40
MOVD RSP, R0 // timeval
MOVD R0, R9 // this is how dyld calls gettimeofday
MOVW $0, R1 // zone
MOVD $0, R2 // see issue 16570
MOVW $SYS_gettimeofday, R16
SVC $0x80 // Note: x0 is tv_sec, w1 is tv_usec
CMP $0, R0
BNE inreg
MOVD 0(RSP), R0
MOVW 8(RSP), R1
inreg:
MOVW $1000000000, R3
MUL R3, R0
MOVW $1000, R3
View
@@ -26,14 +26,21 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
}
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
func Gettimeofday(tv *Timeval) (err error) {
// The tv passed to gettimeofday must be non-nil
// but is otherwise unused. The answers come back
// in the two registers.
func Gettimeofday(tv *Timeval) error {
// The tv passed to gettimeofday must be non-nil.
// Before macOS Sierra (10.12), tv was otherwise unused and
// the answers came back in the two registers.
// As of Sierra, gettimeofday return zeros and populates
// tv itself.
sec, usec, err := gettimeofday(tv)
tv.Sec = int32(sec)
tv.Usec = int32(usec)
return err
if err != nil {
return err
}
if sec != 0 || usec != 0 {
tv.Sec = int32(sec)
tv.Usec = int32(usec)
}
return nil
}
func SetKevent(k *Kevent_t, fd, mode, flags int) {
View
@@ -26,14 +26,21 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
}
//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
func Gettimeofday(tv *Timeval) (err error) {
// The tv passed to gettimeofday must be non-nil
// but is otherwise unused. The answers come back
// in the two registers.
func Gettimeofday(tv *Timeval) error {
// The tv passed to gettimeofday must be non-nil.
// Before macOS Sierra (10.12), tv was otherwise unused and
// the answers came back in the two registers.
// As of Sierra, gettimeofday return zeros and populates
// tv itself.
sec, usec, err := gettimeofday(tv)
tv.Sec = sec
tv.Usec = usec
return err
if err != nil {
return err
}
if sec != 0 || usec != 0 {
tv.Sec = sec
tv.Usec = usec
}
return nil
}
func SetKevent(k *Kevent_t, fd, mode, flags int) {
View
@@ -26,14 +26,19 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
}
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
func Gettimeofday(tv *Timeval) (err error) {
func Gettimeofday(tv *Timeval) error {
// The tv passed to gettimeofday must be non-nil
// but is otherwise unused. The answers come back
// in the two registers.
sec, usec, err := gettimeofday(tv)
tv.Sec = int32(sec)
tv.Usec = int32(usec)
return err
if err != nil {
return err
}
if sec != 0 || usec != 0 {
tv.Sec = int32(sec)
tv.Usec = int32(usec)
}
return nil
}
func SetKevent(k *Kevent_t, fd, mode, flags int) {
View
@@ -26,14 +26,19 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
}
//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
func Gettimeofday(tv *Timeval) (err error) {
func Gettimeofday(tv *Timeval) error {
// The tv passed to gettimeofday must be non-nil
// but is otherwise unused. The answers come back
// in the two registers.
sec, usec, err := gettimeofday(tv)
tv.Sec = sec
tv.Usec = usec
return err
if err != nil {
return err
}
if sec != 0 || usec != 0 {
tv.Sec = sec
tv.Usec = usec
}
return nil
}
func SetKevent(k *Kevent_t, fd, mode, flags int) {
View
@@ -0,0 +1,23 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin
// +build amd64 386 arm arm64
package syscall_test
import (
"syscall"
"testing"
)
func TestDarwinGettimeofday(t *testing.T) {
tv := &syscall.Timeval{}
if err := syscall.Gettimeofday(tv); err != nil {
t.Fatal(err)
}
if tv.Sec == 0 && tv.Usec == 0 {
t.Fatal("Sec and Usec both zero")
}
}