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

Subversion Repositories openrisc

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

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
#ifndef MAP_ANONYMOUS
9
#define MAP_ANONYMOUS MAP_ANON
10
#endif
11
#ifndef MAP_ANON
12
#define MAP_ANON 0
13
#endif
14
#include <stdlib.h>
15
 
16
void __attribute__((noinline)) test (const char *p)
17
{
18
  if (__builtin_strncmp (p, "abcdefghijklmnopq", 17) == 0)
19
    abort ();
20
}
21
 
22
int main (void)
23
{
24
  char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE,
25
                  MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
26
  if (p == MAP_FAILED)
27
    return 0;
28
  if (munmap (p + 65536, 65536) < 0)
29
    return 0;
30
  __builtin_memcpy (p + 65536 - 5, "abcd", 5);
31
  test (p + 65536 - 5);
32
  return 0;
33
}

powered by: WebSVN 2.1.0

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