What is the equivalent of dwAllocationGranularity
in Linux? In Windows, it's defined as:
The granularity for the starting address at which virtual memory can be allocated.
Note that this is not the same thing as PAGE_SIZE
, which is the granularity of a physical page.
(On Windows, the virtual address granularity is 64 KiB on x86, whereas the page size is of course 4 KiB.)
The nearest equivalent of VirtualAlloc on Linux is mmap which, like VirtualAlloc, allows you to specify a desired allocation target address of the allocated memory. On Windows, this address must be aligned on the allocation granularity. On Linux, I quote from the mmap man page:
If addr is not NULL, then the kernel takes it as a hint about where to place the mapping; on Linux, the mapping will be created at a nearby page boundary.
As far as I know, there is no situation where the allocation granularity is higher than the page size of the system, so you should be able to safely use PAGE_SIZE as a substitute.