OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libmudflap/] [testsuite/] [libmudflap.c/] [fail40-frag.c] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 275 jeremybenn
/* 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
17
#ifndef MAP_FAILED
18
#define MAP_FAILED ((void *)-1)
19
#endif
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.  */
29
  p = mmap (NULL, num, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
30
  if (p == MAP_FAILED)
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 *-*-* } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.