Mercurial > hg > CbC > CbC_gcc
annotate libmudflap/testsuite/libmudflap.c/fail40-frag.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children |
rev | line source |
---|---|
0 | 1 /* Test proper lookup-uncaching of large objects */ |
2 #include "../config.h" | |
3 | |
4 #include <unistd.h> | |
5 #include <string.h> | |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #ifdef HAVE_SYS_MMAN_H | |
9 #include <sys/mman.h> | |
10 #endif | |
11 | |
12 int main () | |
13 { | |
14 #ifndef MAP_ANONYMOUS | |
15 #define MAP_ANONYMOUS MAP_ANON | |
16 #endif | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
17 #ifndef MAP_FAILED |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
18 #define MAP_FAILED ((void *)-1) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
19 #endif |
0 | 20 #ifdef HAVE_MMAP |
21 volatile unsigned char *p; | |
22 unsigned num = getpagesize (); | |
23 unsigned i; | |
24 int rc; | |
25 | |
26 /* Get a bit of usable address space. We really want an 2**N+1-sized object, | |
27 so the low/high addresses wrap when hashed into the lookup cache. So we | |
28 will manually unregister the entire mmap, then re-register a slice. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
29 p = mmap (NULL, num, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
30 if (p == MAP_FAILED) |
0 | 31 return 1; |
32 /* Now unregister it, as if munmap was called. But don't actually munmap, so | |
33 we can write into the memory. */ | |
34 __mf_unregister ((void *) p, num, __MF_TYPE_HEAP_I); | |
35 | |
36 /* Now register it under a slightly inflated, 2**N+1 size. */ | |
37 __mf_register ((void *) p, num+1, __MF_TYPE_HEAP_I, "fake mmap registration"); | |
38 | |
39 /* Traverse array to ensure that entire lookup cache is made to point at it. */ | |
40 for (i=0; i<num; i++) | |
41 p[i] = 0; | |
42 | |
43 /* Unregister it. This should clear the entire lookup cache, even though | |
44 hash(low) == hash (high) (and probably == 0) */ | |
45 __mf_unregister ((void *) p, num+1, __MF_TYPE_HEAP_I); | |
46 | |
47 /* Now touch the middle portion of the ex-array. If the lookup cache was | |
48 well and truly cleaned, then this access should trap. */ | |
49 p[num/2] = 1; | |
50 | |
51 return 0; | |
52 #else | |
53 return 1; | |
54 #endif | |
55 } | |
56 /* { dg-output "mudflap violation 1.*check/write.*" } */ | |
57 /* { dg-output "Nearby object 1.*" } */ | |
58 /* { dg-output "mudflap dead object.*fake mmap registration.*" } */ | |
59 /* { dg-do run { xfail *-*-* } } */ |