1 /* Copyright (C) 2002 Free Software Foundation.
3 Test memcpy with various combinations of pointer alignments and lengths to
4 make sure any optimizations in the library are correct.
6 Written by Michael Meissner, March 9, 2002. */
11 #define MAX_OFFSET (sizeof (long long))
15 #define MAX_COPY (10 * sizeof (long long))
19 #define MAX_EXTRA (sizeof (long long))
22 #define MAX_LENGTH (MAX_OFFSET + MAX_COPY + 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
37 int off1
, off2
, len
, i
;
40 for (off1
= 0; off1
< MAX_OFFSET
; off1
++)
41 for (off2
= 0; off2
< MAX_OFFSET
; off2
++)
42 for (len
= 1; len
< MAX_COPY
; len
++)
44 for (i
= 0, c
= 'A'; i
< MAX_LENGTH
; i
++, c
++)
47 if (c
>= 'A' + SEQUENCE_LENGTH
)
52 p
= memcpy (u1
.buf
+ off1
, u2
.buf
+ off2
, len
);
53 if (p
!= u1
.buf
+ off1
)
57 for (i
= 0; i
< off1
; i
++, q
++)
61 for (i
= 0, c
= 'A' + off2
; i
< len
; i
++, q
++, c
++)
63 if (c
>= 'A' + SEQUENCE_LENGTH
)
69 for (i
= 0; i
< MAX_EXTRA
; i
++, q
++)