summaryrefslogtreecommitdiff
path: root/src/lib/syscall/time_amd64_darwin.go
blob: 8253171cac66153c20d6025e2b6e1ddd5c3b8195 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2009 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.

package syscall

import syscall "syscall"

func Gettimeofday() (sec, nsec, errno int64) {
	// The "1" in the call is the timeval pointer, which must be
	// non-zero but is otherwise unused.  The results
	// are returned in r1, r2.
	r1, r2, err := Syscall(SYS_GETTIMEOFDAY, 1, 0, 0);
	if err != 0 {
		return 0, 0, err
	}
	return r1, r2*1000, 0
}

func Nstotimeval(ns int64, tv *Timeval) {
	ns += 999;	// round up
	tv.Sec = int64(ns/1000000000);
	tv.Usec = uint32(ns%1000000000 / 1000);
}