1 /* This is a replacement of needed parts from <stdlib.h> and <string.h>
2 for -foptimize-strlen testing, to ensure we are testing the builtins
3 rather than whatever the OS has in its headers. */
5 #define NULL ((void *) 0)
6 typedef __SIZE_TYPE__
size_t;
7 extern void abort (void);
8 void *calloc (size_t, size_t);
11 char *strdup (const char *);
12 size_t strlen (const char *);
13 size_t strnlen (const char *, size_t);
14 void *memcpy (void *__restrict
, const void *__restrict
, size_t);
15 void *memmove (void *, const void *, size_t);
16 char *strcpy (char *__restrict
, const char *__restrict
);
17 char *strcat (char *__restrict
, const char *__restrict
);
18 char *strchr (const char *, int);
19 int strcmp (const char *, const char *);
20 int strncmp (const char *, const char *, size_t);
21 void *memset (void *, int, size_t);
22 int memcmp (const void *, const void *, size_t);
23 int strcmp (const char *, const char *);
25 void *mempcpy (void *__restrict
, const void *__restrict
, size_t);
26 char *stpcpy (char *__restrict
, const char *__restrict
);
29 int sprintf (char * __restrict
, const char *__restrict
, ...);
30 int snprintf (char * __restrict
, size_t, const char *__restrict
, ...);
32 #if defined(FORTIFY_SOURCE) && FORTIFY_SOURCE > 0 && __OPTIMIZE__
33 # define bos(ptr) __builtin_object_size (ptr, FORTIFY_SOURCE > 0)
34 # define bos0(ptr) __builtin_object_size (ptr, 0)
36 extern inline __attribute__((gnu_inline
, always_inline
, artificial
)) void *
37 memcpy (void *__restrict dest
, const void *__restrict src
, size_t len
)
39 return __builtin___memcpy_chk (dest
, src
, len
, bos0 (dest
));
42 extern inline __attribute__((gnu_inline
, always_inline
, artificial
)) void *
43 memmove (void *dest
, const void *src
, size_t len
)
45 return __builtin___memmove_chk (dest
, src
, len
, bos0 (dest
));
48 extern inline __attribute__((gnu_inline
, always_inline
, artificial
)) char *
49 strcpy (char *__restrict dest
, const char *__restrict src
)
51 return __builtin___strcpy_chk (dest
, src
, bos (dest
));
54 extern inline __attribute__((gnu_inline
, always_inline
, artificial
)) char *
55 strcat (char *__restrict dest
, const char *__restrict src
)
57 return __builtin___strcat_chk (dest
, src
, bos (dest
));
61 extern inline __attribute__((gnu_inline
, always_inline
, artificial
)) void *
62 mempcpy (void *__restrict dest
, const void *__restrict src
, size_t len
)
64 return __builtin___mempcpy_chk (dest
, src
, len
, bos0 (dest
));
67 extern inline __attribute__((gnu_inline
, always_inline
, artificial
)) char *
68 stpcpy (char *__restrict dest
, const char *__restrict src
)
70 return __builtin___stpcpy_chk (dest
, src
, bos (dest
));