Skip to content

Commit

Permalink
Fix for undefined type syscall.Timeval32 Usec and Sec methods on darw…
Browse files Browse the repository at this point in the history
…in/386 (#128)

Fixes darwin/386 where syscall.Timeval32 Usec and Sec methods were undefined.

Fixes #127
  • Loading branch information
thomasmodeneis authored and andrewkroh committed Aug 28, 2019
1 parent cd07243 commit 356ba2b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
12 changes: 0 additions & 12 deletions sigar_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ func (self *LoadAverage) Get() error {
return nil
}

func (self *Uptime) Get() error {
tv := syscall.Timeval32{}

if err := sysctlbyname("kern.boottime", &tv); err != nil {
return err
}

self.Length = time.Since(time.Unix(int64(tv.Sec), int64(tv.Usec)*1000)).Seconds()

return nil
}

func (self *Mem) Get() error {
var vmstat C.vm_statistics_data_t

Expand Down
18 changes: 18 additions & 0 deletions sigar_darwin_386.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package gosigar

import (
"syscall"
"time"
)

func (self *Uptime) Get() error {
tv := syscall.Timeval{}

if err := sysctlbyname("kern.boottime", &tv); err != nil {
return err
}

self.Length = time.Since(time.Unix(int64(tv.Sec), int64(tv.Usec)*1000)).Seconds()

return nil
}
18 changes: 18 additions & 0 deletions sigar_darwin_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package gosigar

import (
"syscall"
"time"
)

func (self *Uptime) Get() error {
tv := syscall.Timeval32{}

if err := sysctlbyname("kern.boottime", &tv); err != nil {
return err
}

self.Length = time.Since(time.Unix(int64(tv.Sec), int64(tv.Usec)*1000)).Seconds()

return nil
}

0 comments on commit 356ba2b

Please sign in to comment.