PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / memcpy-1.c
blob558c9370abb9aae09773381b3d6bafe7661f2daf
1 /* { dg-add-options stack_size } */
3 #include <string.h>
5 #if defined (STACK_SIZE)
6 #define MEMCPY_SIZE (STACK_SIZE / 3)
7 #else
8 #define MEMCPY_SIZE (1 << 17)
9 #endif
12 void *copy (void *o, const void *i, unsigned l)
14 return memcpy (o, i, l);
17 main ()
19 unsigned i;
20 unsigned char src[MEMCPY_SIZE];
21 unsigned char dst[MEMCPY_SIZE];
23 for (i = 0; i < MEMCPY_SIZE; i++)
24 src[i] = (unsigned char) i, dst[i] = 0;
26 (void) memcpy (dst, src, MEMCPY_SIZE / 128);
28 for (i = 0; i < MEMCPY_SIZE / 128; i++)
29 if (dst[i] != (unsigned char) i)
30 abort ();
32 (void) memset (dst, 1, MEMCPY_SIZE / 128);
34 for (i = 0; i < MEMCPY_SIZE / 128; i++)
35 if (dst[i] != 1)
36 abort ();
38 (void) memcpy (dst, src, MEMCPY_SIZE);
40 for (i = 0; i < MEMCPY_SIZE; i++)
41 if (dst[i] != (unsigned char) i)
42 abort ();
44 (void) memset (dst, 0, MEMCPY_SIZE);
46 for (i = 0; i < MEMCPY_SIZE; i++)
47 if (dst[i] != 0)
48 abort ();
50 (void) copy (dst, src, MEMCPY_SIZE / 128);
52 for (i = 0; i < MEMCPY_SIZE / 128; i++)
53 if (dst[i] != (unsigned char) i)
54 abort ();
56 (void) memset (dst, 0, MEMCPY_SIZE);
58 (void) copy (dst, src, MEMCPY_SIZE);
60 for (i = 0; i < MEMCPY_SIZE; i++)
61 if (dst[i] != (unsigned char) i)
62 abort ();
64 exit (0);