Created
June 22, 2021 20:38
-
-
Save dsh0005/3761286ab1b62df56997a308c3dd40f5 to your computer and use it in GitHub Desktop.
Allocate high addresses with mmap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#include <sys/mman.h> | |
int main(void){ | |
void * const hint = (void*)~(uintptr_t)0; | |
const void * const reserved = mmap(hint, 1, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | |
printf("hint:%p\nreserved: %p\n", hint, reserved); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment