OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package syscall | 5 package syscall |
6 | 6 |
7 func Getpagesize() int» { return 4096 } | 7 func Getpagesize() int { return 4096 } |
8 | 8 |
9 func TimespecToNsec(ts Timespec) int64» { return int64(ts.Sec)*1e9 + int64(ts.Ns
ec) } | 9 func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nse
c) } |
10 | 10 |
11 func NsecToTimespec(nsec int64) (ts Timespec) { | 11 func NsecToTimespec(nsec int64) (ts Timespec) { |
12 » ts.Sec = int32(nsec / 1e9); | 12 » ts.Sec = int32(nsec / 1e9) |
13 » ts.Nsec = int32(nsec % 1e9); | 13 » ts.Nsec = int32(nsec % 1e9) |
14 » return; | 14 » return |
15 } | 15 } |
16 | 16 |
17 func TimevalToNsec(tv Timeval) int64» { return int64(tv.Sec)*1e9 + int64(tv.Us
ec)*1e3 } | 17 func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)
*1e3 } |
18 | 18 |
19 func NsecToTimeval(nsec int64) (tv Timeval) { | 19 func NsecToTimeval(nsec int64) (tv Timeval) { |
20 » nsec += 999;» // round up to microsecond | 20 » nsec += 999 // round up to microsecond |
21 » tv.Usec = int32(nsec % 1e9 / 1e3); | 21 » tv.Usec = int32(nsec % 1e9 / 1e3) |
22 » tv.Sec = int32(nsec / 1e9); | 22 » tv.Sec = int32(nsec / 1e9) |
23 » return; | 23 » return |
24 } | 24 } |
25 | 25 |
26 //sys gettimeofday(tp *Timeval) (sec int32, usec int32, errno int) | 26 //sys gettimeofday(tp *Timeval) (sec int32, usec int32, errno int) |
27 func Gettimeofday(tv *Timeval) (errno int) { | 27 func Gettimeofday(tv *Timeval) (errno int) { |
28 // The tv passed to gettimeofday must be non-nil | 28 // The tv passed to gettimeofday must be non-nil |
29 // but is otherwise unused. The answers come back | 29 // but is otherwise unused. The answers come back |
30 // in the two registers. | 30 // in the two registers. |
31 » sec, usec, err := gettimeofday(tv); | 31 » sec, usec, err := gettimeofday(tv) |
32 » tv.Sec = int32(sec); | 32 » tv.Sec = int32(sec) |
33 » tv.Usec = int32(usec); | 33 » tv.Usec = int32(usec) |
34 » return err; | 34 » return err |
35 } | 35 } |
36 | 36 |
37 func SetKevent(k *Kevent_t, fd, mode, flags int) { | 37 func SetKevent(k *Kevent_t, fd, mode, flags int) { |
38 » k.Ident = uint32(fd); | 38 » k.Ident = uint32(fd) |
39 » k.Filter = int16(mode); | 39 » k.Filter = int16(mode) |
40 » k.Flags = uint16(flags); | 40 » k.Flags = uint16(flags) |
41 } | 41 } |
OLD | NEW |