mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
all: initial stubs for Windows support; see https://github.com/VictoriaMetrics/VictoriaMetrics/issues/70
This commit is contained in:
parent
b75630fcf4
commit
e88a03323a
2 changed files with 49 additions and 0 deletions
9
lib/filestream/filestream_windows.go
Normal file
9
lib/filestream/filestream_windows.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package filestream
|
||||
|
||||
func (st *streamTracker) adviseDontNeed(n int, fdatasync bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st *streamTracker) close() error {
|
||||
return nil
|
||||
}
|
40
lib/memory/memory_windows.go
Normal file
40
lib/memory/memory_windows.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package memory
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||
)
|
||||
|
||||
// This has been adapted from https://github.com/pbnjay/memory.
|
||||
|
||||
type memStatusEx struct {
|
||||
dwLength uint32
|
||||
dwMemoryLoad uint32
|
||||
ullTotalPhys uint64
|
||||
unused [6]uint64
|
||||
}
|
||||
|
||||
func sysTotalMemory() int {
|
||||
kernel32, err := syscall.LoadDLL("kernel32.dll")
|
||||
if err != nil {
|
||||
logger.Panicf("FATAL: cannot load kernel32.dll: %s", err)
|
||||
}
|
||||
globalMemoryStatusEx, err := kernel32.FindProc("GlobalMemoryStatusEx")
|
||||
if err != nil {
|
||||
logger.Panicf("FATAL: cannot find GlobalMemoryStatusEx: %s", err)
|
||||
}
|
||||
msx := &memStatusEx{
|
||||
dwLength: uint32(unsafe.Sizeof(memStatusEx{})),
|
||||
}
|
||||
r, _, err := globalMemoryStatusEx.Call(uintptr(unsafe.Pointer(msx)))
|
||||
if r == 0 {
|
||||
logger.Panicf("FATAL: error in GlobalMemoryStatusEx: %s", err)
|
||||
}
|
||||
n := int(msx.ullTotalPhys)
|
||||
if uint64(n) != msx.ullTotalPhys {
|
||||
logger.Panicf("FATAL: int overflow for msx.ullTotalPhys=%d", msx.ullTotalPhys)
|
||||
}
|
||||
return n
|
||||
}
|
Loading…
Reference in a new issue