drd/tests/swapcontext: Improve the portability of this test further
[valgrind.git] / none / tests / munmap_exe.c
blob16152010a6664ced92caa27b4e01baf890ec8c2e
1 #include <unistd.h>
2 #include "tests/sys_mman.h"
3 #include <stdio.h>
4 #include <stdlib.h>
6 /* Point of this is that the fd of an PROT_EXEC segment is -1, so Valgrind
7 shouldn't add it to its list of exe segs, and thus it won't be discarded
8 upon the munmap() (so no "discard" message). */
10 int main()
12 void* m;
14 m = mmap(NULL, 100, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
16 if (m == (void*)-1) {
17 fprintf(stderr, "error mmapping\n");
18 exit(1);
21 munmap(m, 100);
23 return 0;