1#include <unistd.h>
2#include "tests/sys_mman.h"
3#include <stdio.h>
4#include <stdlib.h>
5
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). */
9
10int main()
11{
12    void* m;
13
14    m = mmap(NULL, 100, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
15
16    if (m == (void*)-1) {
17       fprintf(stderr, "error mmapping\n");
18       exit(1);
19    }
20
21    munmap(m, 100);
22
23    return 0;
24}
25