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