add std/private/win_getsysteminfo; refactor the usage of GetSystemInfo (#19310)

* add std/private/win_getsysteminfo

* import at the top level

* wrappers follow nep1 too

* follow review comment
This commit is contained in:
flywind 2022-01-04 18:49:54 +08:00 • committed by GitHub
commit 1869826668
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 35 deletions

View file

@ -42,25 +42,10 @@ type
when defined(windows):
import winlean
type
SYSTEM_INFO {.final, pure.} = object
u1: uint32
dwPageSize: uint32
lpMinimumApplicationAddress: pointer
lpMaximumApplicationAddress: pointer
dwActiveProcessorMask: ptr uint32
dwNumberOfProcessors: uint32
dwProcessorType: uint32
dwAllocationGranularity: uint32
wProcessorLevel: uint16
wProcessorRevision: uint16
proc getSystemInfo(lpSystemInfo: ptr SYSTEM_INFO) {.stdcall,
dynlib: "kernel32", importc: "GetSystemInfo".}
import std/private/win_getsysteminfo
proc getAllocationGranularity: uint =
var sysInfo: SYSTEM_INFO
var sysInfo: SystemInfo
getSystemInfo(addr sysInfo)
return uint(sysInfo.dwAllocationGranularity)