xref: /llvm-project/lldb/test/API/linux/aarch64/mte_memory_region/main.c (revision 6cdc2239dbabeb6fb8a9f933693f744a60d50a8c)
1 #include <asm/hwcap.h>
2 #include <asm/mman.h>
3 #include <sys/auxv.h>
4 #include <sys/mman.h>
5 #include <sys/prctl.h>
6 #include <unistd.h>
7 
main(int argc,char const * argv[])8 int main(int argc, char const *argv[]) {
9   if (!(getauxval(AT_HWCAP2) & HWCAP2_MTE))
10     return 1;
11 
12   int got = prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0);
13   if (got)
14     return 1;
15 
16   void *the_page = mmap(0, sysconf(_SC_PAGESIZE), PROT_MTE,
17                         MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
18   if (the_page == MAP_FAILED)
19     return 1;
20 
21   return 0; // Set break point at this line.
22 }
23