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-4.c] - Blame information for rev 298

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
   Roger Sayle <roger@eyesopen.com>
5
   Derived from duff-2.c.  */
6
 
7
/* { dg-do run } */
8
/* { dg-options "-O2" } */
9
 
10
extern void abort (void);
11
extern void exit (int);
12
 
13
#if __INT_MAX__ >= 2147483647
14
/* At least 32-bit integers. */
15
typedef int type32;
16
#else
17
typedef long type32;
18
#endif
19
 
20
type32
21
cksum (const unsigned char *src, unsigned long size)
22
{
23
  type32 ck = 0;
24
 
25
  switch (size & 3)
26
    {
27
    do
28
      {
29
    case 0:
30
        ck ^= (type32)*src++ << 24;
31
        --size;
32
    case 3:
33
        ck ^= (type32)*src++ << 16;
34
        --size;
35
    case 2:
36
        ck ^= (type32)*src++ << 8;
37
        --size;
38
    case 1:
39
        ck ^= (type32)*src++;
40
        --size;
41
      }
42
    while (size > 0);
43
    }
44
 
45
  return ck;
46
}
47
 
48
const char testpat[] = "The quick brown fox jumped over the lazy dog.";
49
 
50
int
51
main()
52
{
53
  type32 ck;
54
 
55
  ck = cksum ((const unsigned char *) testpat, sizeof (testpat));
56
  if (ck != 925902908)
57
    abort ();
58
 
59
  exit (0);
60
}

powered by: WebSVN 2.1.0

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