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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [memcpy-2.c] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
/* Copyright (C) 2002  Free Software Foundation.
2
 
3
   Test memcpy with various combinations of pointer alignments and lengths to
4
   make sure any optimizations in the library are correct.
5
 
6
   Written by Michael Meissner, March 9, 2002.  */
7
 
8
#include <string.h>
9
 
10
#ifndef MAX_OFFSET
11
#define MAX_OFFSET (sizeof (long long))
12
#endif
13
 
14
#ifndef MAX_COPY
15
#define MAX_COPY (10 * sizeof (long long))
16
#endif
17
 
18
#ifndef MAX_EXTRA
19
#define MAX_EXTRA (sizeof (long long))
20
#endif
21
 
22
#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)
23
 
24
 
25
/* Use a sequence length that is not divisible by two, to make it more
26
   likely to detect when words are mixed up.  */
27
#define SEQUENCE_LENGTH 31
28
 
29
static union {
30
  char buf[MAX_LENGTH];
31
  long long align_int;
32
  long double align_fp;
33
} u1, u2;
34
 
35
main ()
36
{
37
  int off1, off2, len, i;
38
  char *p, *q, c;
39
 
40
  for (off1 = 0; off1 < MAX_OFFSET; off1++)
41
    for (off2 = 0; off2 < MAX_OFFSET; off2++)
42
      for (len = 1; len < MAX_COPY; len++)
43
        {
44
          for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)
45
            {
46
              u1.buf[i] = 'a';
47
              if (c >= 'A' + SEQUENCE_LENGTH)
48
                c = 'A';
49
              u2.buf[i] = c;
50
            }
51
 
52
          p = memcpy (u1.buf + off1, u2.buf + off2, len);
53
          if (p != u1.buf + off1)
54
            abort ();
55
 
56
          q = u1.buf;
57
          for (i = 0; i < off1; i++, q++)
58
            if (*q != 'a')
59
              abort ();
60
 
61
          for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)
62
            {
63
              if (c >= 'A' + SEQUENCE_LENGTH)
64
                c = 'A';
65
              if (*q != c)
66
                abort ();
67
            }
68
 
69
          for (i = 0; i < MAX_EXTRA; i++, q++)
70
            if (*q != 'a')
71
              abort ();
72
        }
73
 
74
  exit (0);
75
}

powered by: WebSVN 2.1.0

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