2 strcpy-1.c from the execute part of the gcc torture tests.
7 /* Copyright (C) 2002 Free Software Foundation.
9 Test strcpy with various combinations of pointer alignments and lengths to
10 make sure any optimizations in the library are correct. */
15 #define MAX_OFFSET (sizeof (long long))
19 #define MAX_COPY (3 * sizeof (long long)) /* Was (10 * sizeof (long long)) in GCC, reduced to speed up regression testing */
23 #define MAX_EXTRA (sizeof (long long))
26 #define MAX_LENGTH (MAX_OFFSET + MAX_COPY + 1 + MAX_EXTRA)
28 /* Use a sequence length that is not divisible by two, to make it more
29 likely to detect when words are mixed up. */
30 #define SEQUENCE_LENGTH 31
32 #if !(defined(__SDCC_mcs51) && defined(__SDCC_MODEL_SMALL)) && !defined(__SDCC_pdk14) // Lack of memory
36 #if 0 // TODO: Emable when SDCC suports long double!
43 testTortureExecute (void)
45 #if !(defined(__SDCC_mcs51) && defined(__SDCC_MODEL_SMALL)) && !defined(__SDCC_pdk14) // Lack of memory
46 int off1
, off2
, len
, i
;
49 for (off1
= 0; off1
< MAX_OFFSET
; off1
++)
50 for (off2
= 0; off2
< MAX_OFFSET
; off2
++)
51 for (len
= 1; len
< MAX_COPY
; len
++)
53 for (i
= 0, c
= 'A'; i
< MAX_LENGTH
; i
++, c
++)
56 if (c
>= 'A' + SEQUENCE_LENGTH
)
60 u2
.buf
[off2
+ len
] = '\0';
62 p
= strcpy (u1
.buf
+ off1
, u2
.buf
+ off2
);
63 if (p
!= u1
.buf
+ off1
)
67 for (i
= 0; i
< off1
; i
++, q
++)
71 for (i
= 0, c
= 'A' + off2
; i
< len
; i
++, q
++, c
++)
73 if (c
>= 'A' + SEQUENCE_LENGTH
)
81 for (i
= 0; i
< MAX_EXTRA
; i
++, q
++)