]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: add Unix method to TimeSpec, TimeVal
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 19 Jan 2012 03:05:44 +0000 (19:05 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 19 Jan 2012 03:05:44 +0000 (19:05 -0800)
Fixes #2534

R=golang-dev, dave, alex.brainman
CC=golang-dev
https://golang.org/cl/5554057

src/pkg/syscall/syscall.go
src/pkg/syscall/syscall_windows.go

index f82c6c5626379c738c0b1af0b7f020dd2329859a..b10358ab820a5ae8138b421ee669cc1896e9cc98 100644 (file)
@@ -29,3 +29,11 @@ func StringBytePtr(s string) *byte { return &StringByteSlice(s)[0] }
 // Single-word zero for use when we need a valid pointer to 0 bytes.
 // See mksyscall.pl.
 var _zero uintptr
+
+func (ts *Timespec) Unix() (sec int64, nsec int64) {
+       return int64(ts.Sec), int64(ts.Nsec)
+}
+
+func (tv *Timeval) Unix() (sec int64, nsec int64) {
+       return int64(tv.Sec), int64(tv.Usec) * 1000
+}
index b77a0779c511cc3c48a6031181fd226b0a9ce753..45e2994f1589f79806a0ebcde82ffb2e77f86025 100644 (file)
@@ -624,6 +624,13 @@ func (w WaitStatus) Signaled() bool { return false }
 
 func (w WaitStatus) TrapCause() int { return -1 }
 
+// Timespec is an invented structure on Windows, but here for
+// consistency with the syscall package for other operating systems.
+type Timespec struct {
+       Sec  int64
+       Nsec int64
+}
+
 // TODO(brainman): fix all needed for net
 
 func Accept(fd Handle) (nfd Handle, sa Sockaddr, err error) { return 0, nil, EWINDOWS }