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