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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [duff-2.c] - Blame information for rev 826

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 the BSD Telnet Kerberos 4 checksum routine.
6
   See also PR 5230.  */
7
 
8
/* { dg-do run } */
9
/* { dg-options "-O2" } */
10
 
11
extern void abort (void);
12
extern void exit (int);
13
 
14
#if __INT_MAX__ >= 2147483647
15
/* At least 32-bit integers. */
16
typedef int type32;
17
#else
18
typedef long type32;
19
#endif
20
 
21
type32
22
cksum (const unsigned char *src, unsigned long size)
23
{
24
  type32 ck = 0;
25
 
26
  switch (size & 3)
27
    {
28
    while (size > 0)
29
      {
30
    case 0:
31
        ck ^= (type32)*src++ << 24;
32
        --size;
33
    case 3:
34
        ck ^= (type32)*src++ << 16;
35
        --size;
36
    case 2:
37
        ck ^= (type32)*src++ << 8;
38
        --size;
39
    case 1:
40
        ck ^= (type32)*src++;
41
        --size;
42
      }
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.