}
 
 //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) {
 
 }
 
 //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) {
 
--- /dev/null
+// 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
+
+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")
+       }
+}