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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [loop-2g.c] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
#include <limits.h>
2
 
3
#ifdef __unix__ /* ??? Is that good enough? */
4
#include <sys/types.h>
5
#include <sys/mman.h>
6
#include <sys/stat.h>
7
#include <fcntl.h>
8
#ifndef MAP_ANON
9
#ifdef MAP_ANONYMOUS
10
#define MAP_ANON MAP_ANONYMOUS
11
#else
12
#define MAP_ANON MAP_FILE
13
#endif
14
#endif
15
#ifndef MAP_FILE
16
#define MAP_FILE 0
17
#endif
18
#ifndef MAP_FIXED
19
#define MAP_FIXED 0
20
#endif
21
#endif
22
 
23
#define MAP_START (void *)0x7fff8000
24
#define MAP_LEN 0x10000
25
 
26
#define OFFSET (MAP_LEN/2 - 2 * sizeof (char));
27
 
28
f (int s, char *p)
29
{
30
  int i;
31
  for (i = s; &p[i] < &p[40] && i >= 0; i++)
32
    {
33
      p[i] = -2;
34
    }
35
}
36
 
37
main ()
38
{
39
#ifdef MAP_ANON
40
  char *p;
41
  int dev_zero;
42
 
43
  dev_zero = open ("/dev/zero", O_RDONLY);
44
  /* -1 is OK when we have MAP_ANON; else mmap will flag an error.  */
45
  if (INT_MAX != 0x7fffffffL || sizeof (char *) != sizeof (int))
46
    exit (0);
47
  p = mmap (MAP_START, MAP_LEN, PROT_READ|PROT_WRITE,
48
            MAP_ANON|MAP_FIXED|MAP_PRIVATE, dev_zero, 0);
49
  if (p != (char *)-1)
50
    {
51
      p += OFFSET;
52
      p[39] = 0;
53
      f (0, p);
54
      if (p[39] != (char)-2)
55
        abort ();
56
      p[39] = 0;
57
      f (-1, p);
58
      if (p[39] != 0)
59
        abort ();
60
    }
61
#endif
62
  exit (0);
63
}

powered by: WebSVN 2.1.0

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