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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [strcpy-1.c] - Blame information for rev 826

Details | Compare with Previous | View Log

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