Ticket #14911: mmap.c
File mmap.c, 310 bytes (added by , 6 years ago) |
---|
Line | |
---|---|
1 | #include <sys/mman.h> |
2 | #include <errno.h> |
3 | #include <OS.h> |
4 | |
5 | int 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 | } |