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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [duff-1.c] - Blame information for rev 313

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

Line No. Rev Author Line
1 298 jeremybenn
/* Duff's device is legal C; test to make sure the compiler
2
   doesn't complain about it.
3
 
4
   Jason Thorpe <thorpej@wasabisystems.com>
5
   Derived from PR 3846.  */
6
 
7
/* { dg-do run } */
8
/* { dg-options "-O2" } */
9
 
10
extern void abort (void);
11
extern void exit (int);
12
 
13
typedef __SIZE_TYPE__ size_t;
14
extern int memcmp (const void *, const void *, size_t);
15
 
16
void
17
duffcpy (char *dst, const char *src, unsigned long size)
18
{
19
  switch (size & 3)
20
    {
21
    for (;;)
22
      {
23
        *dst++ = *src++;
24
    case 3:
25
        *dst++ = *src++;
26
    case 2:
27
        *dst++ = *src++;
28
    case 1:
29
        *dst++ = *src++;
30
    case 0:
31
        if (size <= 3)
32
          break;
33
        size -= 4;
34
      }
35
    }
36
}
37
 
38
const char testpat[] = "The quick brown fox jumped over the lazy dog.";
39
 
40
int
41
main()
42
{
43
  char buf[64];
44
 
45
  duffcpy (buf, testpat, sizeof (testpat));
46
  if (memcmp (buf, testpat, sizeof (testpat)) != 0)
47
    abort ();
48
 
49
  exit (0);
50
}

powered by: WebSVN 2.1.0

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