| 1 |
/* { dg-add-options stack_size } */ |
| 2 |
|
| 3 |
#include <string.h> |
| 4 |
|
| 5 |
void abort (void); |
| 6 |
void exit (int); |
| 7 |
|
| 8 |
#if defined (STACK_SIZE) |
| 9 |
#define MEMCPY_SIZE (STACK_SIZE / 3) |
| 10 |
#else |
| 11 |
#define MEMCPY_SIZE (1 << 17) |
| 12 |
#endif |
| 13 |
|
| 14 |
|
| 15 |
void *copy (void *o, const void *i, unsigned l) |
| 16 |
{ |
| 17 |
return memcpy (o, i, l); |
| 18 |
} |
| 19 |
|
| 20 |
int |
| 21 |
main (void) |
| 22 |
{ |
| 23 |
unsigned i; |
| 24 |
unsigned char src[MEMCPY_SIZE]; |
| 25 |
unsigned char dst[MEMCPY_SIZE]; |
| 26 |
|
| 27 |
for (i = 0; i < MEMCPY_SIZE; i++) |
| 28 |
src[i] = (unsigned char) i, dst[i] = 0; |
| 29 |
|
| 30 |
(void) memcpy (dst, src, MEMCPY_SIZE / 128); |
| 31 |
|
| 32 |
for (i = 0; i < MEMCPY_SIZE / 128; i++) |
| 33 |
if (dst[i] != (unsigned char) i) |
| 34 |
abort (); |
| 35 |
|
| 36 |
(void) memset (dst, 1, MEMCPY_SIZE / 128); |
| 37 |
|
| 38 |
for (i = 0; i < MEMCPY_SIZE / 128; i++) |
| 39 |
if (dst[i] != 1) |
| 40 |
abort (); |
| 41 |
|
| 42 |
(void) memcpy (dst, src, MEMCPY_SIZE); |
| 43 |
|
| 44 |
for (i = 0; i < MEMCPY_SIZE; i++) |
| 45 |
if (dst[i] != (unsigned char) i) |
| 46 |
abort (); |
| 47 |
|
| 48 |
(void) memset (dst, 0, MEMCPY_SIZE); |
| 49 |
|
| 50 |
for (i = 0; i < MEMCPY_SIZE; i++) |
| 51 |
if (dst[i] != 0) |
| 52 |
abort (); |
| 53 |
|
| 54 |
(void) copy (dst, src, MEMCPY_SIZE / 128); |
| 55 |
|
| 56 |
for (i = 0; i < MEMCPY_SIZE / 128; i++) |
| 57 |
if (dst[i] != (unsigned char) i) |
| 58 |
abort (); |
| 59 |
|
| 60 |
(void) memset (dst, 0, MEMCPY_SIZE); |
| 61 |
|
| 62 |
(void) copy (dst, src, MEMCPY_SIZE); |
| 63 |
|
| 64 |
for (i = 0; i < MEMCPY_SIZE; i++) |
| 65 |
if (dst[i] != (unsigned char) i) |
| 66 |
abort (); |
| 67 |
|
| 68 |
exit (0); |
| 69 |
} |