annotate gcc/testsuite/gcc.dg/20050826-1.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test whether strncmp has not been "optimized" into memcmp
kono
parents:
diff changeset
2 nor any code with memcmp semantics. */
kono
parents:
diff changeset
3 /* { dg-do run { target mmap } } */
kono
parents:
diff changeset
4 /* { dg-options "-O2" } */
kono
parents:
diff changeset
5 #include <stddef.h>
kono
parents:
diff changeset
6 #include <stdio.h>
kono
parents:
diff changeset
7 #include <sys/mman.h>
kono
parents:
diff changeset
8 /* Darwin spells this differently */
kono
parents:
diff changeset
9 #ifndef MAP_ANONYMOUS
kono
parents:
diff changeset
10 #define MAP_ANONYMOUS MAP_ANON
kono
parents:
diff changeset
11 #endif
kono
parents:
diff changeset
12 #ifndef MAP_ANON
kono
parents:
diff changeset
13 #define MAP_ANON 0
kono
parents:
diff changeset
14 #endif
kono
parents:
diff changeset
15 #ifndef MAP_FAILED
kono
parents:
diff changeset
16 #define MAP_FAILED ((void *)-1)
kono
parents:
diff changeset
17 #endif
kono
parents:
diff changeset
18 #include <stdlib.h>
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 struct Flags {
kono
parents:
diff changeset
21 int filler[18];
kono
parents:
diff changeset
22 unsigned int a:14;
kono
parents:
diff changeset
23 unsigned int b:14;
kono
parents:
diff changeset
24 unsigned int c:1;
kono
parents:
diff changeset
25 unsigned int d:1;
kono
parents:
diff changeset
26 unsigned int e:1;
kono
parents:
diff changeset
27 unsigned int f:1;
kono
parents:
diff changeset
28 };
kono
parents:
diff changeset
29 static void __attribute__((noinline)) set (struct Flags *);
kono
parents:
diff changeset
30 static void set (struct Flags *fp)
kono
parents:
diff changeset
31 {
kono
parents:
diff changeset
32 fp->b = 5;
kono
parents:
diff changeset
33 fp->d = 1;
kono
parents:
diff changeset
34 }
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 static int __attribute__((noinline)) bar (int);
kono
parents:
diff changeset
37 static int bar(int x) { return !(x==1); }
kono
parents:
diff changeset
38 int main (void)
kono
parents:
diff changeset
39 {
kono
parents:
diff changeset
40 char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE,
kono
parents:
diff changeset
41 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
kono
parents:
diff changeset
42 struct Flags *fp;
kono
parents:
diff changeset
43 if (p == MAP_FAILED)
kono
parents:
diff changeset
44 return 0;
kono
parents:
diff changeset
45 if (munmap (p + 65536, 65536) < 0)
kono
parents:
diff changeset
46 return 0;
kono
parents:
diff changeset
47 fp = (struct Flags*)(p + 65536 - sizeof(struct Flags));
kono
parents:
diff changeset
48 set(fp);
kono
parents:
diff changeset
49 if (fp->b > 0)
kono
parents:
diff changeset
50 return (bar(fp->d));
kono
parents:
diff changeset
51 return 1;
kono
parents:
diff changeset
52 }