2002-05-10 David S. Miller <davem@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / memcpy-1.c
blob684854b66dc01a06a2a8c62b87d4d01311187464
1 #include <string.h>
3 #if defined (STACK_SIZE)
4 #define MEMCPY_SIZE (STACK_SIZE / 3)
5 #else
6 #define MEMCPY_SIZE (1 << 17)
7 #endif
10 void *copy (void *o, const void *i, unsigned l)
12 return memcpy (o, i, l);
15 main ()
17 unsigned i;
18 unsigned char src[MEMCPY_SIZE];
19 unsigned char dst[MEMCPY_SIZE];
21 for (i = 0; i < MEMCPY_SIZE; i++)
22 src[i] = (unsigned char) i, dst[i] = 0;
24 (void) memcpy (dst, src, MEMCPY_SIZE / 128);
26 for (i = 0; i < MEMCPY_SIZE / 128; i++)
27 if (dst[i] != (unsigned char) i)
28 abort ();
30 (void) memset (dst, 1, MEMCPY_SIZE / 128);
32 for (i = 0; i < MEMCPY_SIZE / 128; i++)
33 if (dst[i] != 1)
34 abort ();
36 (void) memcpy (dst, src, MEMCPY_SIZE);
38 for (i = 0; i < MEMCPY_SIZE; i++)
39 if (dst[i] != (unsigned char) i)
40 abort ();
42 (void) memset (dst, 0, MEMCPY_SIZE);
44 for (i = 0; i < MEMCPY_SIZE; i++)
45 if (dst[i] != 0)
46 abort ();
48 (void) copy (dst, src, MEMCPY_SIZE / 128);
50 for (i = 0; i < MEMCPY_SIZE / 128; i++)
51 if (dst[i] != (unsigned char) i)
52 abort ();
54 (void) memset (dst, 0, MEMCPY_SIZE);
56 (void) copy (dst, src, MEMCPY_SIZE);
58 for (i = 0; i < MEMCPY_SIZE; i++)
59 if (dst[i] != (unsigned char) i)
60 abort ();
62 exit (0);