1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _TESTCASES_MMAP_TEST_H
3 #define _TESTCASES_MMAP_TEST_H
4 #include <sys/mman.h>
5 #include <sys/resource.h>
6 #include <stddef.h>
7 #include <strings.h>
8 #include "../../kselftest_harness.h"
9 
10 #define TOP_DOWN 0
11 #define BOTTOM_UP 1
12 
13 #define PROT (PROT_READ | PROT_WRITE)
14 #define FLAGS (MAP_PRIVATE | MAP_ANONYMOUS)
15 
memory_layout(void)16 static inline int memory_layout(void)
17 {
18 	void *value1 = mmap(NULL, sizeof(int), PROT, FLAGS, 0, 0);
19 	void *value2 = mmap(NULL, sizeof(int), PROT, FLAGS, 0, 0);
20 
21 	return value2 > value1;
22 }
23 #endif /* _TESTCASES_MMAP_TEST_H */
24