[NDS32] Add intrinsic functions for TLB operation and data prefech.
[official-gcc.git] / gcc / testsuite / gcc.dg / pr65408.c
blob8eec1d2dc369879ddc38aff8653a940858613e3a
1 /* PR middle-end/36043 target/58744 target/65408 */
2 /* { dg-do run { target mmap } } */
3 /* { dg-options "-O2" } */
5 #include <sys/mman.h>
6 #ifndef MAP_ANONYMOUS
7 #define MAP_ANONYMOUS MAP_ANON
8 #endif
9 #ifndef MAP_ANON
10 #define MAP_ANON 0
11 #endif
12 #ifndef MAP_FAILED
13 #define MAP_FAILED ((void *)-1)
14 #endif
16 typedef struct
18 unsigned char r;
19 unsigned char g;
20 unsigned char b;
21 } __attribute__((packed)) pr58744;
23 typedef struct
25 unsigned short r;
26 unsigned short g;
27 unsigned short b;
28 } pr36043;
30 typedef struct
32 int r;
33 int g;
34 int b;
35 } pr65408;
37 __attribute__ ((noinline, noclone))
38 void
39 f1a (pr58744 x)
41 if (x.r != 1 || x.g != 2 || x.b != 3)
42 __builtin_abort();
45 __attribute__ ((noinline, noclone))
46 void
47 f1 (pr58744 *x)
49 f1a (*x);
52 __attribute__ ((noinline, noclone))
53 void
54 f2a (pr36043 x)
56 if (x.r != 1 || x.g != 2 || x.b != 3)
57 __builtin_abort();
60 __attribute__ ((noinline, noclone))
61 void
62 f2 (pr36043 *x)
64 f2a (*x);
67 __attribute__ ((noinline, noclone))
68 void
69 f3a (pr65408 x)
71 if (x.r != 1 || x.g != 2 || x.b != 3)
72 __builtin_abort();
75 __attribute__ ((noinline, noclone))
76 void
77 f3 (pr65408 *x)
79 f3a (*x);
82 int
83 main ()
85 char *p = mmap ((void *) 0, 131072, PROT_READ | PROT_WRITE,
86 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
87 if (p == MAP_FAILED)
88 return 0;
89 char *endp = p + 65536;
90 if (munmap (endp, 65536) < 0)
91 return 0;
93 pr58744 *s1 = (pr58744 *) endp - 1;
94 s1->r = 1;
95 s1->g = 2;
96 s1->b = 3;
97 f1 (s1);
99 pr36043 *s2 = (pr36043 *) endp - 1;
100 s2->r = 1;
101 s2->g = 2;
102 s2->b = 3;
103 f2 (s2);
105 pr65408 *s3 = (pr65408 *) endp - 1;
106 s3->r = 1;
107 s3->g = 2;
108 s3->b = 3;
109 f3 (s3);
111 return 0;