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