提交 9f2c985a 编写于 作者: W WAKAYAMA Shirou

fix windows build.

上级 a1c1d7b2
......@@ -8,11 +8,11 @@ import (
)
var (
modkernel32 = syscall.NewLazyDLL("kernel32.dll")
modNt = syscall.NewLazyDLL("ntdll.dll")
Modkernel32 = syscall.NewLazyDLL("kernel32.dll")
ModNt = syscall.NewLazyDLL("ntdll.dll")
procGetSystemTimes = modkernel32.NewProc("GetSystemTimes")
procNtQuerySystemInformation = modNt.NewProc("NtQuerySystemInformation")
ProcGetSystemTimes = Modkernel32.NewProc("GetSystemTimes")
ProcNtQuerySystemInformation = ModNt.NewProc("NtQuerySystemInformation")
)
type FILETIME struct {
......
......@@ -5,16 +5,18 @@ package gopsutil
import (
"syscall"
"unsafe"
common "github.com/shirou/gopsutil/common"
)
// TODO: Get percpu
func CPUTimes(percpu bool) ([]CPUTimesStat, error) {
var ret []CPUTimesStat
var lpIdleTime FILETIME
var lpKernelTime FILETIME
var lpUserTime FILETIME
r, _, _ := procGetSystemTimes.Call(
var lpIdleTime common.FILETIME
var lpKernelTime common.FILETIME
var lpUserTime common.FILETIME
r, _, _ := common.ProcGetSystemTimes.Call(
uintptr(unsafe.Pointer(&lpIdleTime)),
uintptr(unsafe.Pointer(&lpKernelTime)),
uintptr(unsafe.Pointer(&lpUserTime)))
......
......@@ -11,10 +11,10 @@ import (
)
var (
procGetDiskFreeSpaceExW = modkernel32.NewProc("GetDiskFreeSpaceExW")
procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
procGetDriveType = modkernel32.NewProc("GetDriveTypeW")
provGetVolumeInformation = modkernel32.NewProc("GetVolumeInformationW")
procGetDiskFreeSpaceExW = common.Modkernel32.NewProc("GetDiskFreeSpaceExW")
procGetLogicalDriveStringsW = common.Modkernel32.NewProc("GetLogicalDriveStringsW")
procGetDriveType = common.Modkernel32.NewProc("GetDriveTypeW")
provGetVolumeInformation = common.Modkernel32.NewProc("GetVolumeInformationW")
)
var (
......
......@@ -6,11 +6,14 @@ import (
"os"
"syscall"
"unsafe"
common "github.com/shirou/gopsutil/common"
process "github.com/shirou/gopsutil/process"
)
var (
procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
procGetTickCount = modkernel32.NewProc("GetTickCount")
procGetSystemTimeAsFileTime = common.Modkernel32.NewProc("GetSystemTimeAsFileTime")
procGetTickCount = common.Modkernel32.NewProc("GetTickCount")
)
func HostInfo() (*HostInfoStat, error) {
......@@ -28,7 +31,7 @@ func HostInfo() (*HostInfoStat, error) {
ret.Uptime = uint64(uptimemsec) / 1000
procs, err := Pids()
procs, err := process.Pids()
if err != nil {
return ret, err
}
......@@ -39,7 +42,7 @@ func HostInfo() (*HostInfoStat, error) {
}
func BootTime() (uint64, error) {
var lpSystemTimeAsFileTime FILETIME
var lpSystemTimeAsFileTime common.FILETIME
r, _, _ := procGetSystemTimeAsFileTime.Call(uintptr(unsafe.Pointer(&lpSystemTimeAsFileTime)))
if r == 0 {
......
......@@ -5,10 +5,12 @@ package gopsutil
import (
"syscall"
"unsafe"
common "github.com/shirou/gopsutil/common"
)
var (
procGlobalMemoryStatusEx = modkernel32.NewProc("GlobalMemoryStatusEx")
procGlobalMemoryStatusEx = common.Modkernel32.NewProc("GlobalMemoryStatusEx")
)
type MEMORYSTATUSEX struct {
......
......@@ -44,7 +44,7 @@ func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) {
for _, ifi := range ifs {
name := ifi.Name
for ; ai != nil; ai = ai.Next {
name = bytePtrToString(&ai.Description[0])
name = common.BytePtrToString(&ai.Description[0])
c := NetIOCountersStat{
Name: name,
}
......
......@@ -10,6 +10,8 @@ import (
"github.com/shirou/w32"
common "github.com/shirou/gopsutil/common"
cpu "github.com/shirou/gopsutil/cpu"
net "github.com/shirou/gopsutil/net"
)
const (
......@@ -130,7 +132,7 @@ func (p *Process) Threads() (map[string]string, error) {
ret := make(map[string]string, 0)
return ret, common.NotImplementedError
}
func (p *Process) CPUTimes() (*CPUTimesStat, error) {
func (p *Process) CPUTimes() (*cpu.CPUTimesStat, error) {
return nil, common.NotImplementedError
}
func (p *Process) CPUPercent() (int32, error) {
......@@ -157,7 +159,7 @@ func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
return nil, common.NotImplementedError
}
func (p *Process) Connections() ([]NetConnectionStat, error) {
func (p *Process) Connections() ([]net.NetConnectionStat, error) {
return nil, common.NotImplementedError
}
......@@ -249,7 +251,7 @@ func getProcInfo(pid int32) (*SystemProcessInformation, error) {
buffer := make([]byte, bufferSize)
var sysProcInfo SystemProcessInformation
ret, _, _ := procNtQuerySystemInformation.Call(
ret, _, _ := common.ProcNtQuerySystemInformation.Call(
uintptr(unsafe.Pointer(&sysProcInfo)),
uintptr(unsafe.Pointer(&buffer[0])),
uintptr(unsafe.Pointer(&bufferSize)),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册