1
0
mirror of https://github.com/golang/go synced 2024-11-13 17:10:21 -07:00

os/syscall: correct netbsd types/names

Fix types/names so that these functions work with the generated
syscall/z* files.

R=golang-dev, m4dh4tt3r
CC=golang-dev
https://golang.org/cl/6201078
This commit is contained in:
Joel Sing 2012-05-15 12:00:13 +10:00
parent b42ebb6fbf
commit b554fb912f
3 changed files with 11 additions and 11 deletions

View File

@ -19,7 +19,7 @@ func fileInfoFromStat(st *syscall.Stat_t, name string) FileInfo {
fs := &fileStat{ fs := &fileStat{
name: basename(name), name: basename(name),
size: int64(st.Size), size: int64(st.Size),
modTime: timespecToTime(st.Mtim), modTime: timespecToTime(st.Mtimespec),
sys: st, sys: st,
} }
fs.mode = FileMode(st.Mode & 0777) fs.mode = FileMode(st.Mode & 0777)
@ -57,5 +57,5 @@ func timespecToTime(ts syscall.Timespec) time.Time {
// For testing. // For testing.
func atime(fi FileInfo) time.Time { func atime(fi FileInfo) time.Time {
return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim) return timespecToTime(fi.Sys().(*syscall.Stat_t).Atimespec)
} }

View File

@ -9,7 +9,7 @@ func Getpagesize() int { return 4096 }
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
func NsecToTimespec(nsec int64) (ts Timespec) { func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int32(nsec / 1e9) ts.Sec = int64(nsec / 1e9)
ts.Nsec = int32(nsec % 1e9) ts.Nsec = int32(nsec % 1e9)
return return
} }
@ -19,14 +19,14 @@ func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)
func NsecToTimeval(nsec int64) (tv Timeval) { func NsecToTimeval(nsec int64) (tv Timeval) {
nsec += 999 // round up to microsecond nsec += 999 // round up to microsecond
tv.Usec = int32(nsec % 1e9 / 1e3) tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int32(nsec / 1e9) tv.Sec = int64(nsec / 1e9)
return return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {
k.Ident = uint32(fd) k.Ident = uint32(fd)
k.Filter = int16(mode) k.Filter = uint32(mode)
k.Flags = uint16(flags) k.Flags = uint32(flags)
} }
func (iov *Iovec) SetLen(length int) { func (iov *Iovec) SetLen(length int) {

View File

@ -9,8 +9,8 @@ func Getpagesize() int { return 4096 }
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
func NsecToTimespec(nsec int64) (ts Timespec) { func NsecToTimespec(nsec int64) (ts Timespec) {
ts.Sec = int32(nsec / 1e9) ts.Sec = int64(nsec / 1e9)
ts.Nsec = nsec % 1e9 ts.Nsec = int64(nsec % 1e9)
return return
} }
@ -18,15 +18,15 @@ func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)
func NsecToTimeval(nsec int64) (tv Timeval) { func NsecToTimeval(nsec int64) (tv Timeval) {
nsec += 999 // round up to microsecond nsec += 999 // round up to microsecond
tv.Usec = nsec % 1e9 / 1e3 tv.Usec = int32(nsec % 1e9 / 1e3)
tv.Sec = int64(nsec / 1e9) tv.Sec = int64(nsec / 1e9)
return return
} }
func SetKevent(k *Kevent_t, fd, mode, flags int) { func SetKevent(k *Kevent_t, fd, mode, flags int) {
k.Ident = uint64(fd) k.Ident = uint64(fd)
k.Filter = int16(mode) k.Filter = uint32(mode)
k.Flags = uint16(flags) k.Flags = uint32(flags)
} }
func (iov *Iovec) SetLen(length int) { func (iov *Iovec) SetLen(length int) {