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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [loop-2f.c] - Blame information for rev 801

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

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

powered by: WebSVN 2.1.0

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