1 /* Copyright (C) 2002 Free Software Foundation.
3 Test strcpy with various combinations of pointer alignments and lengths to
4 make sure any optimizations in the library are correct. */
9 #define MAX_OFFSET (sizeof (long long))
13 #define MAX_COPY (10 * sizeof (long long))
17 #define MAX_EXTRA (sizeof (long long))
20 #define MAX_LENGTH (MAX_OFFSET + MAX_COPY + 1 + MAX_EXTRA)
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
34 int off1, off2, len, i;
37 for (off1 = 0; off1 < MAX_OFFSET; off1++)
38 for (off2 = 0; off2 < MAX_OFFSET; off2++)
39 for (len = 1; len < MAX_COPY; len++)
41 for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)
44 if (c >= 'A' + SEQUENCE_LENGTH)
48 u2.buf[off2 + len] = '\0';
50 p = strcpy (u1.buf + off1, u2.buf + off2);
51 if (p != u1.buf + off1)
55 for (i = 0; i < off1; i++, q++)
59 for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)
61 if (c >= 'A' + SEQUENCE_LENGTH)
69 for (i = 0; i < MAX_EXTRA; i++, q++)