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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [20050826-1.c] - Blame information for rev 853

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

Line No. Rev Author Line
1 149 jeremybenn
/* Test whether strncmp has not been "optimized" into memcmp
2
   nor any code with memcmp semantics.  */
3
/* { dg-do run { target i?86-*-linux* x86_64-*-linux* ia64-*-linux* alpha*-*-linux* powerpc*-*-linux* s390*-*-linux* sparc*-*-linux* i?86-*-darwin* powerpc-*-darwin*} } */
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
#include <stdlib.h>
13
 
14
    struct Flags {
15
 int filler[18];
16
 unsigned int a:14;
17
 unsigned int b:14;
18
 unsigned int c:1;
19
 unsigned int d:1;
20
 unsigned int e:1;
21
 unsigned int f:1;
22
    };
23
static void __attribute__((noinline)) set (struct Flags *);
24
static void set (struct Flags *fp)
25
{
26
  fp->b = 5;
27
  fp->d = 1;
28
}
29
 
30
static int __attribute__((noinline)) bar (int);
31
static int bar(int x) { return !(x==1); }
32
int main (void)
33
{
34
  char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE,
35
                  MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
36
  struct Flags *fp;
37
  if (p == MAP_FAILED)
38
    return 0;
39
  if (munmap (p + 65536, 65536) < 0)
40
    return 0;
41
  fp = (struct Flags*)(p + 65536 - sizeof(struct Flags));
42
  set(fp);
43
  if (fp->b > 0)
44
    return (bar(fp->d));
45
  return 1;
46
}

powered by: WebSVN 2.1.0

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