summaryrefslogtreecommitdiff
path: root/src/lib/syscall/time_amd64_linux.go
blob: 67fc51231b03e0711bcaf8375bc41769f8cbf232 (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
25
// 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";
	"unsafe";
)

func Gettimeofday() (sec, nsec, errno int64) {
	var tv Timeval;
	r1, r2, e := Syscall(SYS_GETTIMEOFDAY, int64(uintptr(unsafe.Pointer(&tv))), 0, 0);
	if e != 0 {
		return 0, 0, e
	}
	return int64(tv.Sec), int64(tv.Usec*1000), 0
}

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