blob: c57671ea6311163d788b31a0f1dcb333250757eb [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#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/* 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>
52
53#ifndef _ISOMAC
54extern __typeof (strcoll_l) __strcoll_l;
55extern __typeof (strxfrm_l) __strxfrm_l;
56extern __typeof (strcasecmp_l) __strcasecmp_l;
57extern __typeof (strncasecmp_l) __strncasecmp_l;
58
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
72
73libc_hidden_proto (__mempcpy)
74libc_hidden_proto (__stpcpy)
75libc_hidden_proto (__stpncpy)
76libc_hidden_proto (__rawmemchr)
77libc_hidden_proto (__strcasecmp)
78libc_hidden_proto (__strcasecmp_l)
79libc_hidden_proto (__strncasecmp_l)
80libc_hidden_proto (__strdup)
81libc_hidden_proto (__strndup)
82libc_hidden_proto (__strerror_r)
83libc_hidden_proto (__strverscmp)
84libc_hidden_proto (basename)
85extern char *__basename (const char *__filename) __THROW __nonnull ((1));
86libc_hidden_proto (__basename)
87libc_hidden_proto (strcoll)
88libc_hidden_proto (__strcoll_l)
89libc_hidden_proto (__strxfrm_l)
90libc_hidden_proto (__strtok_r)
91extern char *__strsep_g (char **__stringp, const char *__delim);
92libc_hidden_proto (__strsep_g)
93libc_hidden_proto (strnlen)
94libc_hidden_proto (__strnlen)
95libc_hidden_proto (memmem)
96extern __typeof (memmem) __memmem;
97libc_hidden_proto (__memmem)
98libc_hidden_proto (__ffs)
99
100libc_hidden_builtin_proto (memchr)
101libc_hidden_builtin_proto (memcpy)
102libc_hidden_builtin_proto (mempcpy)
103libc_hidden_builtin_proto (memcmp)
104libc_hidden_builtin_proto (memmove)
105libc_hidden_builtin_proto (memset)
106libc_hidden_builtin_proto (strcat)
107libc_hidden_builtin_proto (strchr)
108libc_hidden_builtin_proto (strcmp)
109libc_hidden_builtin_proto (strcpy)
110libc_hidden_builtin_proto (strcspn)
111libc_hidden_builtin_proto (strlen)
112libc_hidden_builtin_proto (strncmp)
113libc_hidden_builtin_proto (strncpy)
114libc_hidden_builtin_proto (strpbrk)
115libc_hidden_builtin_proto (stpcpy)
116libc_hidden_builtin_proto (strrchr)
117libc_hidden_builtin_proto (strspn)
118libc_hidden_builtin_proto (strstr)
119libc_hidden_builtin_proto (ffs)
120
121#if (!IS_IN (libc) || !defined SHARED) \
122 && !defined NO_MEMPCPY_STPCPY_REDIRECT
123/* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call
124 __mempcpy and __stpcpy if not inlined. */
125extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy");
126extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy");
127#endif
128
129# ifndef _ISOMAC
130# ifndef index
131# define index(s, c) (strchr ((s), (c)))
132# endif
133# ifndef rindex
134# define rindex(s, c) (strrchr ((s), (c)))
135# endif
136# endif
137
138extern void *__memcpy_chk (void *__restrict __dest,
139 const void *__restrict __src, size_t __len,
140 size_t __destlen) __THROW;
141extern void *__memmove_chk (void *__dest, const void *__src, size_t __len,
142 size_t __destlen) __THROW;
143extern void *__mempcpy_chk (void *__restrict __dest,
144 const void *__restrict __src, size_t __len,
145 size_t __destlen) __THROW;
146extern void *__memset_chk (void *__dest, int __ch, size_t __len,
147 size_t __destlen) __THROW;
148extern char *__strcpy_chk (char *__restrict __dest,
149 const char *__restrict __src,
150 size_t __destlen) __THROW;
151extern char *__stpcpy_chk (char *__restrict __dest,
152 const char *__restrict __src,
153 size_t __destlen) __THROW;
154extern char *__strncpy_chk (char *__restrict __dest,
155 const char *__restrict __src,
156 size_t __len, size_t __destlen) __THROW;
157extern char *__strcat_chk (char *__restrict __dest,
158 const char *__restrict __src,
159 size_t __destlen) __THROW;
160extern char *__strncat_chk (char *__restrict __dest,
161 const char *__restrict __src,
162 size_t __len, size_t __destlen) __THROW;
163#endif
164
165#endif