8 #define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
11 /* max mmap size, *start is the largest power-of-2 size considered */
12 static size_t mmax(int fd
, size_t *start
)
17 for (i
=n
=*start
; i
>=PAGE_SIZE
; i
/=2) {
18 if ((p
=mmap(0, n
, PROT_NONE
, MAP_PRIVATE
, fd
, 0)) == MAP_FAILED
) {
27 return n
& -PAGE_SIZE
;
31 fills the virtual memory with anonymous PROT_NONE mmaps,
32 returns the mappings in *p and *n in decreasing size order,
33 the return value is the number of mappings or -1 on failure.
35 int t_vmfill(void **p
, size_t *n
, int len
)
37 int fd
= open("/dev/zero", O_RDWR
);
38 size_t start
= SIZE_MAX
/2 + 1;
47 q
= mmap(0, m
, PROT_NONE
, MAP_PRIVATE
, fd
, 0);