[IR] Allow fast math flags on fptrunc and fpext (#115894)
[llvm-project.git] / lldb / tools / intel-features / intel-mpx / test / main.cpp
blobecc292866ff6d070ee0245d6d34763a3daaede14
1 const int size = 5;
3 #include <cstddef>
4 #include <cstdlib>
5 #include <sys/prctl.h>
7 void func(int *ptr) {
8 int *tmp;
10 #if defined __GNUC__ && !defined __INTEL_COMPILER
11 __builtin___bnd_store_ptr_bounds ((void**)&ptr, ptr);
12 #endif
13 tmp = ptr + size - 1;
14 #if defined __GNUC__ && !defined __INTEL_COMPILER
15 __builtin___bnd_store_ptr_bounds ((void**)&tmp, tmp);
16 #endif
17 tmp = (int*)0x2; // Break 2.
19 return; // Break 3.
22 int
23 main(int argc, char const *argv[])
25 // This call returns 0 only if the CPU and the kernel support
26 // Intel(R) Memory Protection Extensions (Intel(R) MPX).
27 if (prctl(PR_MPX_ENABLE_MANAGEMENT, 0, 0, 0, 0) != 0)
28 return -1;
30 int* a = (int *) calloc(size, sizeof(int));
31 #if defined __GNUC__ && !defined __INTEL_COMPILER
32 __builtin___bnd_store_ptr_bounds ((void**)&a, a);
33 #endif
34 func(a); // Break 1.
36 free(a); // Break 4.
38 return 0;