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