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. */
12 #define MAX_OFFSET (sizeof (long long))
16 #define MAX_COPY (10 * sizeof (long long))
20 #define MAX_EXTRA (sizeof (long long))
23 #define MAX_LENGTH (MAX_OFFSET + MAX_COPY + 1 + MAX_EXTRA)
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
38 int off1
, off2
, len
, i
;
41 for (off1
= 0; off1
< MAX_OFFSET
; off1
++)
42 for (off2
= 0; off2
< MAX_OFFSET
; off2
++)
43 for (len
= 1; len
< MAX_COPY
; len
++)
45 for (i
= 0, c
= 'A'; i
< MAX_LENGTH
; i
++, c
++)
48 if (c
>= 'A' + SEQUENCE_LENGTH
)
52 u2
.buf
[off2
+ len
] = '\0';
54 p
= strcpy (u1
.buf
+ off1
, u2
.buf
+ off2
);
55 if (p
!= u1
.buf
+ off1
)
59 for (i
= 0; i
< off1
; i
++, q
++)
63 for (i
= 0, c
= 'A' + off2
; i
< len
; i
++, q
++, c
++)
65 if (c
>= 'A' + SEQUENCE_LENGTH
)
73 for (i
= 0; i
< MAX_EXTRA
; i
++, q
++)