syscall.Getpagesize(): add test, implement for Linux and Windows

This commit is contained in:
Dan Kegel
2022-06-10 17:20:54 -07:00
committed by Ayke
parent caf405b01d
commit 8754f64f3b
10 changed files with 77 additions and 8 deletions
+8
View File
@@ -40,3 +40,11 @@ func markGlobals() {
start = (start + unsafe.Alignof(uintptr(0)) - 1) &^ (unsafe.Alignof(uintptr(0)) - 1) // align on word boundary
markRoots(start, end)
}
//export getpagesize
func libc_getpagesize() int
//go:linkname syscall_Getpagesize syscall.Getpagesize
func syscall_Getpagesize() int {
return libc_getpagesize()
}
+23
View File
@@ -90,3 +90,26 @@ func markGlobals() {
section = (*peSection)(unsafe.Pointer(uintptr(unsafe.Pointer(section)) + unsafe.Sizeof(peSection{})))
}
}
type systeminfo struct {
anon0 [4]byte
dwpagesize uint32
lpminimumapplicationaddress *byte
lpmaximumapplicationaddress *byte
dwactiveprocessormask uintptr
dwnumberofprocessors uint32
dwprocessortype uint32
dwallocationgranularity uint32
wprocessorlevel uint16
wprocessorrevision uint16
}
//export GetSystemInfo
func _GetSystemInfo(lpSystemInfo unsafe.Pointer)
//go:linkname syscall_Getpagesize syscall.Getpagesize
func syscall_Getpagesize() int {
var info systeminfo
_GetSystemInfo(unsafe.Pointer(&info))
return int(info.dwpagesize)
}