mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 18:47:47 +00:00
syscall.Getpagesize(): add test, implement for Linux and Windows
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user