summaryrefslogtreecommitdiffhomepage
path: root/pkg/abi
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-01-16 00:45:15 +0000
committergVisor bot <gvisor-bot@google.com>2020-01-16 00:45:15 +0000
commit6a9b381a93e88b8ecc681cc0f92a810dbcc58e7d (patch)
tree97431025d4b459155817dd1e72a6b7c3e23112d6 /pkg/abi
parent4480f1078ef3edef267a88acab4113c21f33edaa (diff)
parentd6fb1ec6c7c76040dd20e915b32f9ed795ae7077 (diff)
Merge release-20200115.0-2-gd6fb1ec (automated)
Diffstat (limited to 'pkg/abi')
-rw-r--r--pkg/abi/linux/time.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/abi/linux/time.go b/pkg/abi/linux/time.go
index 546668bca..5c5a58cd4 100644
--- a/pkg/abi/linux/time.go
+++ b/pkg/abi/linux/time.go
@@ -234,6 +234,19 @@ type StatxTimestamp struct {
_ int32
}
+// ToNsec returns the nanosecond representation.
+func (sxts StatxTimestamp) ToNsec() int64 {
+ return int64(sxts.Sec)*1e9 + int64(sxts.Nsec)
+}
+
+// ToNsecCapped returns the safe nanosecond representation.
+func (sxts StatxTimestamp) ToNsecCapped() int64 {
+ if sxts.Sec > maxSecInDuration {
+ return math.MaxInt64
+ }
+ return sxts.ToNsec()
+}
+
// NsecToStatxTimestamp translates nanoseconds to StatxTimestamp.
func NsecToStatxTimestamp(nsec int64) (ts StatxTimestamp) {
return StatxTimestamp{