1 | #ifndef _STRING_H |
2 | |
3 | #ifndef _ISOMAC |
4 | #include <sys/types.h> |
5 | |
6 | extern void *__memccpy (void *__dest, const void *__src, |
7 | int __c, size_t __n); |
8 | |
9 | extern size_t __strnlen (const char *__string, size_t __maxlen) |
10 | __attribute_pure__; |
11 | |
12 | extern char *__strsep (char **__stringp, const char *__delim); |
13 | |
14 | extern int __strverscmp (const char *__s1, const char *__s2) |
15 | __attribute_pure__; |
16 | |
17 | extern int __strncasecmp (const char *__s1, const char *__s2, |
18 | size_t __n) |
19 | __attribute_pure__; |
20 | |
21 | extern int __strcasecmp (const char *__s1, const char *__s2) |
22 | __attribute_pure__; |
23 | |
24 | extern char *__strcasestr (const char *__haystack, const char *__needle) |
25 | __attribute_pure__; |
26 | |
27 | extern char *__strdup (const char *__string) |
28 | __attribute_malloc__; |
29 | extern char *__strndup (const char *__string, size_t __n) |
30 | __attribute_malloc__; |
31 | |
32 | extern void *__rawmemchr (const void *__s, int __c) |
33 | __attribute_pure__; |
34 | |
35 | extern char *__strchrnul (const char *__s, int __c) |
36 | __attribute_pure__; |
37 | |
38 | extern void *__memrchr (const void *__s, int __c, size_t __n) |
39 | __attribute_pure__; |
40 | |
41 | extern void *__memchr (const void *__s, int __c, size_t __n) |
42 | __attribute_pure__; |
43 | |
44 | extern int __ffs (int __i) __attribute__ ((const)); |
45 | |
46 | extern 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 |
57 | extern __typeof (strcoll_l) __strcoll_l; |
58 | extern __typeof (strxfrm_l) __strxfrm_l; |
59 | extern __typeof (strcasecmp_l) __strcasecmp_l; |
60 | extern __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 | |
76 | libc_hidden_proto (__mempcpy) |
77 | libc_hidden_proto (__stpcpy) |
78 | libc_hidden_proto (__stpncpy) |
79 | libc_hidden_proto (__rawmemchr) |
80 | libc_hidden_proto (__strcasecmp) |
81 | libc_hidden_proto (__strcasecmp_l) |
82 | libc_hidden_proto (__strncasecmp_l) |
83 | libc_hidden_proto (__strdup) |
84 | libc_hidden_proto (__strndup) |
85 | libc_hidden_proto (__strerror_r) |
86 | libc_hidden_proto (__strverscmp) |
87 | libc_hidden_proto (basename) |
88 | extern char *__basename (const char *__filename) __THROW __nonnull ((1)); |
89 | libc_hidden_proto (__basename) |
90 | libc_hidden_proto (strcoll) |
91 | libc_hidden_proto (__strcoll_l) |
92 | libc_hidden_proto (__strxfrm_l) |
93 | libc_hidden_proto (__strtok_r) |
94 | extern char *__strsep_g (char **__stringp, const char *__delim); |
95 | libc_hidden_proto (__strsep_g) |
96 | libc_hidden_proto (strnlen) |
97 | libc_hidden_proto (__strnlen) |
98 | libc_hidden_proto (memmem) |
99 | extern __typeof (memmem) __memmem; |
100 | libc_hidden_proto (__memmem) |
101 | libc_hidden_proto (__ffs) |
102 | |
103 | #if IS_IN (libc) |
104 | /* Avoid hidden reference to IFUNC symbol __explicit_bzero_chk. */ |
105 | void __explicit_bzero_chk_internal (void *, size_t, size_t) |
106 | __THROW __nonnull ((1)) attribute_hidden; |
107 | # define explicit_bzero(buf, len) \ |
108 | __explicit_bzero_chk_internal (buf, len, __bos0 (buf)) |
109 | #elif !IS_IN (nonlib) |
110 | void __explicit_bzero_chk (void *, size_t, size_t) __THROW __nonnull ((1)); |
111 | # define explicit_bzero(buf, len) __explicit_bzero_chk (buf, len, __bos0 (buf)) |
112 | #endif |
113 | |
114 | libc_hidden_builtin_proto (memchr) |
115 | libc_hidden_builtin_proto (memcpy) |
116 | libc_hidden_builtin_proto (mempcpy) |
117 | libc_hidden_builtin_proto (memcmp) |
118 | libc_hidden_builtin_proto (memmove) |
119 | libc_hidden_builtin_proto (memset) |
120 | libc_hidden_builtin_proto (strcat) |
121 | libc_hidden_builtin_proto (strchr) |
122 | libc_hidden_builtin_proto (strcmp) |
123 | libc_hidden_builtin_proto (strcpy) |
124 | libc_hidden_builtin_proto (strcspn) |
125 | libc_hidden_builtin_proto (strlen) |
126 | libc_hidden_builtin_proto (strncmp) |
127 | libc_hidden_builtin_proto (strncpy) |
128 | libc_hidden_builtin_proto (strpbrk) |
129 | libc_hidden_builtin_proto (stpcpy) |
130 | libc_hidden_builtin_proto (strrchr) |
131 | libc_hidden_builtin_proto (strspn) |
132 | libc_hidden_builtin_proto (strstr) |
133 | libc_hidden_builtin_proto (ffs) |
134 | |
135 | #if IS_IN (rtld) |
136 | extern __typeof (__stpcpy) __stpcpy attribute_hidden; |
137 | extern __typeof (__strdup) __strdup attribute_hidden; |
138 | extern __typeof (__strerror_r) __strerror_r attribute_hidden; |
139 | extern __typeof (__strsep_g) __strsep_g attribute_hidden; |
140 | |
141 | extern __typeof (memchr) memchr attribute_hidden; |
142 | extern __typeof (memcmp) memcmp attribute_hidden; |
143 | extern __typeof (memcpy) memcpy attribute_hidden; |
144 | extern __typeof (memmove) memmove attribute_hidden; |
145 | extern __typeof (memset) memset attribute_hidden; |
146 | extern __typeof (rawmemchr) rawmemchr attribute_hidden; |
147 | extern __typeof (stpcpy) stpcpy attribute_hidden; |
148 | extern __typeof (strchr) strchr attribute_hidden; |
149 | extern __typeof (strcmp) strcmp attribute_hidden; |
150 | extern __typeof (strlen) strlen attribute_hidden; |
151 | extern __typeof (strnlen) strnlen attribute_hidden; |
152 | extern __typeof (strsep) strsep attribute_hidden; |
153 | #endif |
154 | |
155 | #if (!IS_IN (libc) || !defined SHARED) \ |
156 | && !defined NO_MEMPCPY_STPCPY_REDIRECT |
157 | /* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call |
158 | __mempcpy and __stpcpy if not inlined. */ |
159 | extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy" ); |
160 | extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy" ); |
161 | #endif |
162 | |
163 | # ifndef _ISOMAC |
164 | # ifndef index |
165 | # define index(s, c) (strchr ((s), (c))) |
166 | # endif |
167 | # ifndef rindex |
168 | # define rindex(s, c) (strrchr ((s), (c))) |
169 | # endif |
170 | # endif |
171 | |
172 | extern void *__memcpy_chk (void *__restrict __dest, |
173 | const void *__restrict __src, size_t __len, |
174 | size_t __destlen) __THROW; |
175 | extern void *__memmove_chk (void *__dest, const void *__src, size_t __len, |
176 | size_t __destlen) __THROW; |
177 | extern void *__mempcpy_chk (void *__restrict __dest, |
178 | const void *__restrict __src, size_t __len, |
179 | size_t __destlen) __THROW; |
180 | extern void *__memset_chk (void *__dest, int __ch, size_t __len, |
181 | size_t __destlen) __THROW; |
182 | extern char *__strcpy_chk (char *__restrict __dest, |
183 | const char *__restrict __src, |
184 | size_t __destlen) __THROW; |
185 | extern char *__stpcpy_chk (char *__restrict __dest, |
186 | const char *__restrict __src, |
187 | size_t __destlen) __THROW; |
188 | extern char *__strncpy_chk (char *__restrict __dest, |
189 | const char *__restrict __src, |
190 | size_t __len, size_t __destlen) __THROW; |
191 | extern char *__strcat_chk (char *__restrict __dest, |
192 | const char *__restrict __src, |
193 | size_t __destlen) __THROW; |
194 | extern char *__strncat_chk (char *__restrict __dest, |
195 | const char *__restrict __src, |
196 | size_t __len, size_t __destlen) __THROW; |
197 | #endif |
198 | |
199 | #endif |
200 | |