OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [duff-1.c] - Rev 378

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

/* Duff's device is legal C; test to make sure the compiler
   doesn't complain about it.
 
   Jason Thorpe <thorpej@wasabisystems.com>
   Derived from PR 3846.  */
 
/* { dg-do run } */
/* { dg-options "-O2" } */
 
extern void abort (void);
extern void exit (int);
 
typedef __SIZE_TYPE__ size_t;
extern int memcmp (const void *, const void *, size_t);
 
void
duffcpy (char *dst, const char *src, unsigned long size)
{
  switch (size & 3)
    {
    for (;;)
      {
	*dst++ = *src++;
    case 3:
	*dst++ = *src++;
    case 2:
	*dst++ = *src++;
    case 1:
	*dst++ = *src++;
    case 0:
	if (size <= 3)
	  break;
	size -= 4;
      }
    }
}
 
const char testpat[] = "The quick brown fox jumped over the lazy dog.";
 
int
main()
{
  char buf[64];
 
  duffcpy (buf, testpat, sizeof (testpat));
  if (memcmp (buf, testpat, sizeof (testpat)) != 0)
    abort ();
 
  exit (0);
}
 

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

powered by: WebSVN 2.1.0

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