mirror of
https://github.com/containers/podman.git
synced 2025-12-01 10:38:05 +08:00
Pull in updates made to the filters code for images. Filters now perform an AND operation except for th reference filter which does an OR operation for positive case but an AND operation for negative cases. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
29 lines
696 B
Go
29 lines
696 B
Go
//go:build windows
|
|
|
|
package sysinfo
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
var (
|
|
kernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
|
getCurrentProcess = kernel32.NewProc("GetCurrentProcess")
|
|
getProcessAffinityMask = kernel32.NewProc("GetProcessAffinityMask")
|
|
)
|
|
|
|
func numCPU() int {
|
|
// Gets the affinity mask for a process
|
|
var mask, sysmask uintptr
|
|
currentProcess, _, _ := getCurrentProcess.Call()
|
|
ret, _, _ := getProcessAffinityMask.Call(currentProcess, uintptr(unsafe.Pointer(&mask)), uintptr(unsafe.Pointer(&sysmask)))
|
|
if ret == 0 {
|
|
return 0
|
|
}
|
|
// For every available thread a bit is set in the mask.
|
|
ncpu := int(popcnt(uint64(mask)))
|
|
return ncpu
|
|
}
|