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