aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/syscall_linux_arm64.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2016-10-11 21:04:16 -0700
committerRuss Cox <rsc@golang.org>2016-10-12 13:10:54 +0000
commit6c517df4daa0acaa25a16baeef5ea037c9a0194c (patch)
treeebd06f90eae1ac20c76d4a6e29b543d89a0d279c /src/syscall/syscall_linux_arm64.go
parent6ca48f710f6ae163aa87e883a0a4cf8a91dad0a4 (diff)
downloadgo-6c517df4daa0acaa25a16baeef5ea037c9a0194c.tar.xz
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_linux_arm64.go')
-rw-r--r--src/syscall/syscall_linux_arm64.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/syscall/syscall_linux_arm64.go b/src/syscall/syscall_linux_arm64.go
index 01c72f16b8..0903ba3ece 100644
--- a/src/syscall/syscall_linux_arm64.go
+++ b/src/syscall/syscall_linux_arm64.go
@@ -71,17 +71,12 @@ func Lstat(path string, stat *Stat_t) (err error) {
//sysnb Gettimeofday(tv *Timeval) (err error)
//sysnb Time(t *Time_t) (tt Time_t, err error)
-func NsecToTimespec(nsec int64) (ts Timespec) {
- ts.Sec = nsec / 1e9
- ts.Nsec = nsec % 1e9
- return
+func setTimespec(sec, nsec int64) Timespec {
+ return Timespec{Sec: sec, Nsec: nsec}
}
-func NsecToTimeval(nsec int64) (tv Timeval) {
- nsec += 999 // round up to microsecond
- tv.Sec = nsec / 1e9
- tv.Usec = nsec % 1e9 / 1e3
- return
+func setTimeval(sec, usec int64) Timeval {
+ return Timeval{Sec: sec, Usec: usec}
}
func Pipe(p []int) (err error) {