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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libmudflap/] [testsuite/] [libmudflap.c/] [pass51-frag.c] - Blame information for rev 738

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 738 jeremybenn
/* Test object-spanning accesses.  This is most conveniently done with
2
   mmap, thus the config.h specificity here.  */
3
#include "../config.h"
4
 
5
#include <unistd.h>
6
#include <string.h>
7
#ifdef HAVE_SYS_MMAN_H
8
#include <sys/mman.h>
9
#endif
10
 
11
int main ()
12
{
13
#ifndef MAP_ANONYMOUS
14
#define MAP_ANONYMOUS MAP_ANON
15
#endif
16
#ifndef MAP_FAILED
17
#define MAP_FAILED ((void *)-1)
18
#endif
19
#ifdef HAVE_MMAP
20
  void *p;
21
  unsigned pg = getpagesize ();
22
  int rc;
23
 
24
  p = mmap (NULL, 4 * pg, PROT_READ|PROT_WRITE,
25
            MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
26
  if (p == MAP_FAILED)
27
    return 1;
28
 
29
  memset (p, 0, 4*pg);
30
  rc = munmap (p, pg);
31
  if (rc < 0) return 1;
32
  memset (p+pg, 0, 3*pg);
33
  rc = munmap (p+pg, pg);
34
  if (rc < 0) return 1;
35
  memset (p+2*pg, 0, 2*pg);
36
  rc = munmap (p+2*pg, pg);
37
  if (rc < 0) return 1;
38
  memset (p+3*pg, 0, pg);
39
  rc = munmap (p+3*pg, pg);
40
  if (rc < 0) return 1;
41
#endif
42
 
43
  return 0;
44
}

powered by: WebSVN 2.1.0

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