Skip to content

Commit e012d0d

Browse files
syscall: drop references to Unix epoch in Timeval/Timespec docs
The various conversion functions just change the format of time values. They don't use the Unix epoch. Although in practice the values are often times since the Unix epoch, they aren't always, so referring to the epoch can be confusing. Fixes #43010 Change-Id: I640d665f0d2017f0974db05d70858037c7c91eda Reviewed-on: https://go-review.googlesource.com/c/go/+/277073 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 1fe891a commit e012d0d

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/syscall/syscall.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,22 @@ func BytePtrFromString(s string) (*byte, error) {
7777
// See mksyscall.pl.
7878
var _zero uintptr
7979

80-
// Unix returns ts as the number of seconds and nanoseconds elapsed since the
81-
// Unix epoch.
80+
// Unix returns the time stored in ts as seconds plus nanoseconds.
8281
func (ts *Timespec) Unix() (sec int64, nsec int64) {
8382
return int64(ts.Sec), int64(ts.Nsec)
8483
}
8584

86-
// Unix returns tv as the number of seconds and nanoseconds elapsed since the
87-
// Unix epoch.
85+
// Unix returns the time stored in tv as seconds plus nanoseconds.
8886
func (tv *Timeval) Unix() (sec int64, nsec int64) {
8987
return int64(tv.Sec), int64(tv.Usec) * 1000
9088
}
9189

92-
// Nano returns ts as the number of nanoseconds elapsed since the Unix epoch.
90+
// Nano returns the time stored in ts as nanoseconds.
9391
func (ts *Timespec) Nano() int64 {
9492
return int64(ts.Sec)*1e9 + int64(ts.Nsec)
9593
}
9694

97-
// Nano returns tv as the number of nanoseconds elapsed since the Unix epoch.
95+
// Nano returns the time stored in tv as nanoseconds.
9896
func (tv *Timeval) Nano() int64 {
9997
return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
10098
}

src/syscall/timestruct.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66

77
package syscall
88

9-
// TimespecToNsec converts a Timespec value into a number of
10-
// nanoseconds since the Unix epoch.
9+
// TimespecToNSec returns the time stored in ts as nanoseconds.
1110
func TimespecToNsec(ts Timespec) int64 { return ts.Nano() }
1211

13-
// NsecToTimespec takes a number of nanoseconds since the Unix epoch
14-
// and returns the corresponding Timespec value.
12+
// NsecToTimespec converts a number of nanoseconds into a Timespec.
1513
func NsecToTimespec(nsec int64) Timespec {
1614
sec := nsec / 1e9
1715
nsec = nsec % 1e9
@@ -22,12 +20,10 @@ func NsecToTimespec(nsec int64) Timespec {
2220
return setTimespec(sec, nsec)
2321
}
2422

25-
// TimevalToNsec converts a Timeval value into a number of nanoseconds
26-
// since the Unix epoch.
23+
// TimevalToNsec returns the time stored in tv as nanoseconds.
2724
func TimevalToNsec(tv Timeval) int64 { return tv.Nano() }
2825

29-
// NsecToTimeval takes a number of nanoseconds since the Unix epoch
30-
// and returns the corresponding Timeval value.
26+
// NsecToTimeval converts a number of nanoseconds into a Timeval.
3127
func NsecToTimeval(nsec int64) Timeval {
3228
nsec += 999 // round up to microsecond
3329
usec := nsec % 1e9 / 1e3

0 commit comments

Comments
 (0)