Nov. 13, 2023
6:28 p.m.
`sysconf(_SC_PHYS_PAGES)` returns an error for i386 Mac binaries on any machine with more than 4 GB of RAM. From [the source code](https://github.com/apple-oss-distributions/Libc/blob/c5a3293354e22262702a3ad...) it's clear why--it calls `sysctlbyname()` to put the `hw.memsize` sysctl into a long, which is only 32-bits on i386. This returns an error on any Mac with more than 4GB: the value is too large for a 32-bit long. The `sysctl` man page documents that an int64 should be used for `hw.memsize`, do that and divide by the page size ourselves. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4384