PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt.h
bloba4044fd28f56017ee02d33705018fa996acbf621
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 *malloc (size_t);
9 void free (void *);
10 char *strdup (const char *);
11 size_t strlen (const char *);
12 size_t strnlen (const char *, size_t);
13 void *memcpy (void *__restrict, const void *__restrict, size_t);
14 void *memmove (void *, const void *, size_t);
15 char *strcpy (char *__restrict, const char *__restrict);
16 char *strcat (char *__restrict, const char *__restrict);
17 char *strchr (const char *, int);
18 void *memset (void *, int, size_t);
19 int memcmp (const void *, const void *, size_t);
20 int strcmp (const char *, const char *);
21 #ifdef USE_GNU
22 void *mempcpy (void *__restrict, const void *__restrict, size_t);
23 char *stpcpy (char *__restrict, const char *__restrict);
24 #endif
26 #if defined(FORTIFY_SOURCE) && FORTIFY_SOURCE > 0 && __OPTIMIZE__
27 # define bos(ptr) __builtin_object_size (ptr, FORTIFY_SOURCE > 0)
28 # define bos0(ptr) __builtin_object_size (ptr, 0)
30 extern inline __attribute__((gnu_inline, always_inline, artificial)) void *
31 memcpy (void *__restrict dest, const void *__restrict src, size_t len)
33 return __builtin___memcpy_chk (dest, src, len, bos0 (dest));
36 extern inline __attribute__((gnu_inline, always_inline, artificial)) void *
37 memmove (void *dest, const void *src, size_t len)
39 return __builtin___memmove_chk (dest, src, len, bos0 (dest));
42 extern inline __attribute__((gnu_inline, always_inline, artificial)) char *
43 strcpy (char *__restrict dest, const char *__restrict src)
45 return __builtin___strcpy_chk (dest, src, bos (dest));
48 extern inline __attribute__((gnu_inline, always_inline, artificial)) char *
49 strcat (char *__restrict dest, const char *__restrict src)
51 return __builtin___strcat_chk (dest, src, bos (dest));
54 # ifdef USE_GNU
55 extern inline __attribute__((gnu_inline, always_inline, artificial)) void *
56 mempcpy (void *__restrict dest, const void *__restrict src, size_t len)
58 return __builtin___mempcpy_chk (dest, src, len, bos0 (dest));
61 extern inline __attribute__((gnu_inline, always_inline, artificial)) char *
62 stpcpy (char *__restrict dest, const char *__restrict src)
64 return __builtin___stpcpy_chk (dest, src, bos (dest));
66 # endif
67 #endif