Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / mpx / memmove-2.c
blobe1d78fa47c6e698eb7af1dbf00843af434449dd1
1 /* { dg-do run } */
2 /* { dg-options "-fcheck-pointer-bounds -mmpx" } */
5 #include <stdint.h>
6 #include <string.h>
7 #include "mpx-check.h"
9 #ifdef __i386__
10 /* i386 directory size is 4MB. */
11 #define MPX_NUM_L2_BITS 10
12 #define MPX_NUM_IGN_BITS 2
13 #else /* __i386__ */
14 /* x86_64 directory size is 2GB. */
15 #define MPX_NUM_L2_BITS 17
16 #define MPX_NUM_IGN_BITS 3
17 #endif /* !__i386__ */
20 /* bt_num_of_elems is the number of elements in bounds table. */
21 unsigned long bt_num_of_elems = (1UL << MPX_NUM_L2_BITS);
23 /* Function to test MPX wrapper of memmove function.
24 Check case with no BT allocated for data. */
26 int
27 mpx_test (int argc, const char **argv)
29 void **arr = 0;
30 posix_memalign ((void **) (&arr),
31 1UL << (MPX_NUM_L2_BITS + MPX_NUM_IGN_BITS),
32 2 * bt_num_of_elems * sizeof (void *));
33 void **src = arr, **dst = arr, **ptr = arr;
34 src += 10;
35 dst += 1;
36 ptr += bt_num_of_elems + 100;
37 ptr[0] = __bnd_set_ptr_bounds (arr + 1, sizeof (void *) + 1);
38 memmove (dst, src, 5 * sizeof (void *));
39 return 0;