1#ifndef _STRING_H
2
3#ifndef _ISOMAC
4/* Some of these are defined as macros in the real string.h, so we must
5 prototype them before including it. */
6#include <sys/types.h>
7
8extern void *__memccpy (void *__dest, const void *__src,
9 int __c, size_t __n);
10
11extern size_t __strnlen (const char *__string, size_t __maxlen)
12 __attribute_pure__;
13
14extern char *__strsep (char **__stringp, const char *__delim);
15
16extern int __strverscmp (const char *__s1, const char *__s2)
17 __attribute_pure__;
18
19extern int __strncasecmp (const char *__s1, const char *__s2,
20 size_t __n)
21 __attribute_pure__;
22
23extern int __strcasecmp (const char *__s1, const char *__s2)
24 __attribute_pure__;
25
26extern char *__strcasestr (const char *__haystack, const char *__needle)
27 __attribute_pure__;
28
29extern char *__strdup (const char *__string)
30 __attribute_malloc__;
31extern char *__strndup (const char *__string, size_t __n)
32 __attribute_malloc__;
33
34extern void *__rawmemchr (const void *__s, int __c)
35 __attribute_pure__;
36
37extern char *__strchrnul (const char *__s, int __c)
38 __attribute_pure__;
39
40extern void *__memrchr (const void *__s, int __c, size_t __n)
41 __attribute_pure__;
42
43extern void *__memchr (const void *__s, int __c, size_t __n)
44 __attribute_pure__;
45
46extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
47
48extern int __ffs (int __i) __attribute__ ((const));
49
50extern char *__strerror_r (int __errnum, char *__buf, size_t __buflen);
51
52/* Get _STRING_ARCH_unaligned. */
53#include <string_private.h>
54#endif
55
56#include <string/string.h>
57
58#ifndef _ISOMAC
59extern __typeof (strcoll_l) __strcoll_l;
60extern __typeof (strxfrm_l) __strxfrm_l;
61extern __typeof (strcasecmp_l) __strcasecmp_l;
62extern __typeof (strncasecmp_l) __strncasecmp_l;
63
64/* Alternative version which doesn't pollute glibc's namespace. */
65#if IS_IN (libc)
66# undef strndupa
67# define strndupa(s, n) \
68 (__extension__ \
69 ({ \
70 const char *__old = (s); \
71 size_t __len = __strnlen (__old, (n)); \
72 char *__new = (char *) __builtin_alloca (__len + 1); \
73 __new[__len] = '\0'; \
74 (char *) memcpy (__new, __old, __len); \
75 }))
76#endif
77
78libc_hidden_proto (__mempcpy)
79#ifndef __NO_STRING_INLINES
80# define __mempcpy(dest, src, n) __builtin_mempcpy (dest, src, n)
81#endif
82libc_hidden_proto (__stpcpy)
83#ifndef __NO_STRING_INLINES
84# define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
85#endif
86libc_hidden_proto (__stpncpy)
87libc_hidden_proto (__rawmemchr)
88libc_hidden_proto (__strcasecmp)
89libc_hidden_proto (__strcasecmp_l)
90libc_hidden_proto (__strncasecmp_l)
91extern __typeof (strncat) __strncat;
92libc_hidden_proto (__strncat)
93libc_hidden_proto (__strdup)
94libc_hidden_proto (__strndup)
95libc_hidden_proto (__strerror_r)
96libc_hidden_proto (__strverscmp)
97libc_hidden_proto (basename)
98extern char *__basename (const char *__filename) __THROW __nonnull ((1));
99libc_hidden_proto (__basename)
100libc_hidden_proto (strcoll)
101libc_hidden_proto (__strcoll_l)
102libc_hidden_proto (__strxfrm_l)
103libc_hidden_proto (__strtok_r)
104extern char *__strsep_g (char **__stringp, const char *__delim);
105libc_hidden_proto (__strsep_g)
106libc_hidden_proto (strnlen)
107libc_hidden_proto (__strnlen)
108libc_hidden_proto (memmem)
109extern __typeof (memmem) __memmem;
110libc_hidden_proto (__memmem)
111libc_hidden_proto (__ffs)
112
113#if IS_IN (libc)
114/* Avoid hidden reference to IFUNC symbol __explicit_bzero_chk. */
115void __explicit_bzero_chk_internal (void *, size_t, size_t)
116 __THROW __nonnull ((1)) attribute_hidden;
117# define explicit_bzero(buf, len) \
118 __explicit_bzero_chk_internal (buf, len, __bos0 (buf))
119#elif !IS_IN (nonlib)
120void __explicit_bzero_chk (void *, size_t, size_t) __THROW __nonnull ((1));
121# define explicit_bzero(buf, len) __explicit_bzero_chk (buf, len, __bos0 (buf))
122#endif
123
124libc_hidden_builtin_proto (memchr)
125libc_hidden_builtin_proto (memcpy)
126libc_hidden_builtin_proto (mempcpy)
127libc_hidden_builtin_proto (memcmp)
128libc_hidden_builtin_proto (memmove)
129libc_hidden_builtin_proto (memset)
130libc_hidden_builtin_proto (strcat)
131libc_hidden_builtin_proto (strchr)
132libc_hidden_builtin_proto (strcmp)
133libc_hidden_builtin_proto (strcpy)
134libc_hidden_builtin_proto (strcspn)
135libc_hidden_builtin_proto (strlen)
136libc_hidden_builtin_proto (strncmp)
137libc_hidden_builtin_proto (strncpy)
138libc_hidden_builtin_proto (strpbrk)
139libc_hidden_builtin_proto (stpcpy)
140libc_hidden_builtin_proto (strrchr)
141libc_hidden_builtin_proto (strspn)
142libc_hidden_builtin_proto (strstr)
143libc_hidden_builtin_proto (ffs)
144
145#if IS_IN (rtld)
146extern __typeof (__stpcpy) __stpcpy attribute_hidden;
147extern __typeof (__strdup) __strdup attribute_hidden;
148extern __typeof (__strerror_r) __strerror_r attribute_hidden;
149extern __typeof (__strsep_g) __strsep_g attribute_hidden;
150
151extern __typeof (memchr) memchr attribute_hidden;
152extern __typeof (memcmp) memcmp attribute_hidden;
153extern __typeof (memcpy) memcpy attribute_hidden;
154extern __typeof (memmove) memmove attribute_hidden;
155extern __typeof (memset) memset attribute_hidden;
156extern __typeof (rawmemchr) rawmemchr attribute_hidden;
157extern __typeof (stpcpy) stpcpy attribute_hidden;
158extern __typeof (strchr) strchr attribute_hidden;
159extern __typeof (strcmp) strcmp attribute_hidden;
160extern __typeof (strlen) strlen attribute_hidden;
161extern __typeof (strnlen) strnlen attribute_hidden;
162extern __typeof (strsep) strsep attribute_hidden;
163#endif
164
165#if (!IS_IN (libc) || !defined SHARED) \
166 && !defined NO_MEMPCPY_STPCPY_REDIRECT
167/* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call
168 __mempcpy and __stpcpy if not inlined. */
169extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy");
170extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy");
171#endif
172
173extern void *__memcpy_chk (void *__restrict __dest,
174 const void *__restrict __src, size_t __len,
175 size_t __destlen) __THROW;
176extern void *__memmove_chk (void *__dest, const void *__src, size_t __len,
177 size_t __destlen) __THROW;
178extern void *__mempcpy_chk (void *__restrict __dest,
179 const void *__restrict __src, size_t __len,
180 size_t __destlen) __THROW;
181extern void *__memset_chk (void *__dest, int __ch, size_t __len,
182 size_t __destlen) __THROW;
183extern char *__strcpy_chk (char *__restrict __dest,
184 const char *__restrict __src,
185 size_t __destlen) __THROW;
186extern char *__stpcpy_chk (char *__restrict __dest,
187 const char *__restrict __src,
188 size_t __destlen) __THROW;
189extern char *__strncpy_chk (char *__restrict __dest,
190 const char *__restrict __src,
191 size_t __len, size_t __destlen) __THROW;
192extern char *__strcat_chk (char *__restrict __dest,
193 const char *__restrict __src,
194 size_t __destlen) __THROW;
195extern char *__strncat_chk (char *__restrict __dest,
196 const char *__restrict __src,
197 size_t __len, size_t __destlen) __THROW;
198#endif
199
200#endif
201