2008-11-15 Richard Guenther <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / builtins / memops-asm-lib.c
blobeeffe5c08e49e0c35b61d9d8a8c4d9a4c358b3cd
1 extern void abort (void);
2 extern int inside_main;
3 typedef __SIZE_TYPE__ size_t;
5 #define TEST_ABORT if (inside_main) abort()
7 void *
8 my_memcpy (void *d, const void *s, size_t n)
10 char *dst = (char *) d;
11 const char *src = (const char *) s;
12 while (n--)
13 *dst++ = *src++;
14 return (char *) d;
17 void
18 my_bcopy (const void *s, void *d, size_t n)
20 char *dst = (char *) d;
21 const char *src = (const char *) s;
22 if (src >= dst)
23 while (n--)
24 *dst++ = *src++;
25 else
27 dst += n;
28 src += n;
29 while (n--)
30 *--dst = *--src;
34 void *
35 my_memset (void *d, int c, size_t n)
37 char *dst = (char *) d;
38 while (n--)
39 *dst++ = c;
40 return (char *) d;
43 void
44 my_bzero (void *d, size_t n)
46 char *dst = (char *) d;
47 while (n--)
48 *dst++ = '\0';
51 void *
52 memcpy (void *d, const void *s, size_t n)
54 void *result = my_memcpy (d, s, n);
55 TEST_ABORT;
56 return result;
59 void
60 bcopy (const void *s, void *d, size_t n)
62 my_bcopy (s, d, n);
63 TEST_ABORT;
66 void *
67 memset (void *d, int c, size_t n)
69 void *result = my_memset (d, c, n);
70 TEST_ABORT;
71 return result;
74 void
75 bzero (void *d, size_t n)
77 my_bzero (d, n);
78 TEST_ABORT;
81 #ifdef __vxworks
82 /* The RTP C library uses bfill, which is defined in the same file as
83 bzero and bcopy. */
84 #include "lib/bfill.c"
85 #endif