Ticket #14911: mmap.c

File mmap.c, 310 bytes (added by waddlesplash, 6 years ago)

test program showing 0x0 can be mapped

Line 
1#include <sys/mman.h>
2#include <errno.h>
3#include <OS.h>
4
5int main()
6{
7 void* m = mmap((void*)0, 0x1000, PROT_READ | PROT_WRITE,
8 MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, 0, 0);
9 printf("mapped at: %p\nerrno: %d (%s)\n", m, errno, strerror(errno));
10 strcpy(m, "hello world from 0x0!");
11 puts(m);
12 return 0;
13}