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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libmudflap/] [testsuite/] [libmudflap.c/] [fail40-frag.c] - Blame information for rev 38

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

Line No. Rev Author Line
1 38 julius
/* 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
#ifdef HAVE_MMAP
18
  volatile unsigned char *p;
19
  unsigned num = getpagesize ();
20
  unsigned i;
21
  int rc;
22
 
23
  /* Get a bit of usable address space.  We really want an 2**N+1-sized object,
24
     so the low/high addresses wrap when hashed into the lookup cache.  So we
25
     will manually unregister the entire mmap, then re-register a slice.  */
26
  p = mmap (NULL, num, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
27
  if (p == NULL)
28
    return 1;
29
  /* Now unregister it, as if munmap was called.  But don't actually munmap, so
30
     we can write into the memory.  */
31
  __mf_unregister ((void *) p, num, __MF_TYPE_HEAP_I);
32
 
33
  /* Now register it under a slightly inflated, 2**N+1 size.  */
34
  __mf_register ((void *) p, num+1, __MF_TYPE_HEAP_I, "fake mmap registration");
35
 
36
  /* Traverse array to ensure that entire lookup cache is made to point at it.  */
37
  for (i=0; i<num; i++)
38
    p[i] = 0;
39
 
40
  /* Unregister it.  This should clear the entire lookup cache, even though
41
     hash(low) == hash (high)  (and probably == 0) */
42
  __mf_unregister ((void *) p, num+1, __MF_TYPE_HEAP_I);
43
 
44
  /* Now touch the middle portion of the ex-array.  If the lookup cache was
45
     well and truly cleaned, then this access should trap.  */
46
  p[num/2] = 1;
47
 
48
  return 0;
49
#else
50
  return 1;
51
#endif
52
}
53
/* { dg-output "mudflap violation 1.*check/write.*" } */
54
/* { dg-output "Nearby object 1.*" } */
55
/* { dg-output "mudflap dead object.*fake mmap registration.*" } */
56
/* { dg-do run { xfail *-*-* } } */

powered by: WebSVN 2.1.0

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