diff options
author | Ian Lance Taylor <iant@golang.org> | 2016-10-11 21:04:16 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2016-10-12 13:10:54 +0000 |
commit | 6c517df4daa0acaa25a16baeef5ea037c9a0194c (patch) | |
tree | ebd06f90eae1ac20c76d4a6e29b543d89a0d279c /src/syscall/syscall_openbsd_386.go | |
parent | 6ca48f710f6ae163aa87e883a0a4cf8a91dad0a4 (diff) | |
download | go-git-6c517df4daa0acaa25a16baeef5ea037c9a0194c.tar.gz |
syscall: unify NsecToTime{spec,val}, fix for times < 1970
All the implementations of NsecToTimespec and NsecToTimeval were the
same other than types. Write a single version that uses
GOARCH/GOOS-specific setTimespec and setTimeval functions to handle the
types.
The logic in NsecToTimespec and NsecToTimeval caused times before 1970
to have a negative usec/nsec. The Linux kernel requires that usec
contain a positive number; for consistency, we do this for both
NsecToTimespec and NsecToTimeval.
Change-Id: I525eaba2e7cdb00cb57fa00182dabf19fec298ae
Reviewed-on: https://go-review.googlesource.com/30826
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/syscall/syscall_openbsd_386.go')
-rw-r--r-- | src/syscall/syscall_openbsd_386.go | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/syscall/syscall_openbsd_386.go b/src/syscall/syscall_openbsd_386.go index 185f4b5ce6..ca07ae0500 100644 --- a/src/syscall/syscall_openbsd_386.go +++ b/src/syscall/syscall_openbsd_386.go @@ -4,17 +4,12 @@ package syscall -func NsecToTimespec(nsec int64) (ts Timespec) { - ts.Sec = int64(nsec / 1e9) - ts.Nsec = int32(nsec % 1e9) - return +func setTimespec(sec, nsec int64) Timespec { + return Timespec{Sec: sec, Nsec: int32(nsec)} } -func NsecToTimeval(nsec int64) (tv Timeval) { - nsec += 999 // round up to microsecond - tv.Usec = int32(nsec % 1e9 / 1e3) - tv.Sec = int64(nsec / 1e9) - return +func setTimeval(sec, usec int64) Timeval { + return Timeval{Sec: sec, Usec: int32(usec)} } func SetKevent(k *Kevent_t, fd, mode, flags int) { |