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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [20050826-1.c] - Blame information for rev 708

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

Line No. Rev Author Line
1 689 jeremybenn
/* Test whether strncmp has not been "optimized" into memcmp
2
   nor any code with memcmp semantics.  */
3
/* { dg-do run { target mmap } } */
4
/* { dg-options "-O2" } */
5
#include <stddef.h>
6
#include <stdio.h>
7
#include <sys/mman.h>
8
/* Darwin spells this differently */
9
#ifndef MAP_ANONYMOUS
10
#define MAP_ANONYMOUS MAP_ANON
11
#endif
12
#ifndef MAP_ANON
13
#define MAP_ANON 0
14
#endif
15
#include <stdlib.h>
16
 
17
    struct Flags {
18
 int filler[18];
19
 unsigned int a:14;
20
 unsigned int b:14;
21
 unsigned int c:1;
22
 unsigned int d:1;
23
 unsigned int e:1;
24
 unsigned int f:1;
25
    };
26
static void __attribute__((noinline)) set (struct Flags *);
27
static void set (struct Flags *fp)
28
{
29
  fp->b = 5;
30
  fp->d = 1;
31
}
32
 
33
static int __attribute__((noinline)) bar (int);
34
static int bar(int x) { return !(x==1); }
35
int main (void)
36
{
37
  char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE,
38
                  MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
39
  struct Flags *fp;
40
  if (p == MAP_FAILED)
41
    return 0;
42
  if (munmap (p + 65536, 65536) < 0)
43
    return 0;
44
  fp = (struct Flags*)(p + 65536 - sizeof(struct Flags));
45
  set(fp);
46
  if (fp->b > 0)
47
    return (bar(fp->d));
48
  return 1;
49
}

powered by: WebSVN 2.1.0

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