]> git.ipfire.org Git - thirdparty/glibc.git/blame - string/string.h
* sysdeps/pthread/unwind-forcedunwind.c: Encrypt all function
[thirdparty/glibc.git] / string / string.h
CommitLineData
d8387c7b 1/* Copyright (C) 1991-1993,1995-2004,2007,2009 Free Software Foundation, Inc.
ba1ffaa1 2 This file is part of the GNU C Library.
28f540f4 3
ba1ffaa1 4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
28f540f4 8
ba1ffaa1
UD
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12 Lesser General Public License for more details.
28f540f4 13
41bdb6e2
AJ
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
28f540f4
RM
18
19/*
d1646309 20 * ISO C99 Standard: 7.21 String handling <string.h>
28f540f4
RM
21 */
22
23#ifndef _STRING_H
28f540f4 24#define _STRING_H 1
5107cf1d 25
28f540f4
RM
26#include <features.h>
27
28__BEGIN_DECLS
29
30/* Get size_t and NULL from <stddef.h>. */
31#define __need_size_t
32#define __need_NULL
33#include <stddef.h>
34
d8387c7b
UD
35/* Tell the caller that we provide correct C++ prototypes. */
36#if defined __cplusplus && __GNUC_PREREQ (4, 4)
37# define __CORRECT_ISO_CPP_STRING_H_PROTO
38#endif
39
28f540f4 40
7a5affeb 41__BEGIN_NAMESPACE_STD
28f540f4 42/* Copy N bytes of SRC to DEST. */
c1422e5b 43extern void *memcpy (void *__restrict __dest,
be27d08c
UD
44 __const void *__restrict __src, size_t __n)
45 __THROW __nonnull ((1, 2));
28f540f4
RM
46/* Copy N bytes of SRC to DEST, guaranteeing
47 correct behavior for overlapping strings. */
c1422e5b 48extern void *memmove (void *__dest, __const void *__src, size_t __n)
be27d08c 49 __THROW __nonnull ((1, 2));
7a5affeb 50__END_NAMESPACE_STD
28f540f4
RM
51
52/* Copy no more than N bytes of SRC to DEST, stopping when C is found.
53 Return the position in DEST one byte past where C was copied,
54 or NULL if C was not found in the first N bytes of SRC. */
377a515b 55#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN
98cbe360
UD
56extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
57 int __c, size_t __n)
be27d08c 58 __THROW __nonnull ((1, 2));
28f540f4
RM
59#endif /* SVID. */
60
61
7a5affeb 62__BEGIN_NAMESPACE_STD
28f540f4 63/* Set N bytes of S to C. */
be27d08c 64extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
28f540f4
RM
65
66/* Compare N bytes of S1 and S2. */
c1422e5b 67extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
be27d08c 68 __THROW __attribute_pure__ __nonnull ((1, 2));
28f540f4
RM
69
70/* Search N bytes of S for C. */
d8387c7b
UD
71#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
72extern "C++" void *memchr (void *__s, int __c, size_t __n)
73 __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
74extern "C++" __const void *memchr (__const void *__s, int __c, size_t __n)
75 __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
76#else
ca5a4c3c 77extern void *memchr (__const void *__s, int __c, size_t __n)
be27d08c 78 __THROW __attribute_pure__ __nonnull ((1));
d8387c7b 79#endif
7a5affeb 80__END_NAMESPACE_STD
28f540f4 81
482eec0d
UD
82#ifdef __USE_GNU
83/* Search in S for C. This is similar to `memchr' but there is no
84 length limit. */
d8387c7b
UD
85# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
86extern "C++" void *rawmemchr (void *__s, int __c)
87 __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
88extern "C++" __const void *rawmemchr (__const void *__s, int __c)
89 __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
90# else
be27d08c
UD
91extern void *rawmemchr (__const void *__s, int __c)
92 __THROW __attribute_pure__ __nonnull ((1));
d8387c7b 93# endif
ca747856
RM
94
95/* Search N bytes of S for the final occurrence of C. */
d8387c7b
UD
96# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
97extern "C++" void *memrchr (void *__s, int __c, size_t __n)
98 __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
99extern "C++" __const void *memrchr (__const void *__s, int __c, size_t __n)
100 __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
101# else
ca5a4c3c 102extern void *memrchr (__const void *__s, int __c, size_t __n)
be27d08c 103 __THROW __attribute_pure__ __nonnull ((1));
d8387c7b 104# endif
482eec0d
UD
105#endif
106
28f540f4 107
7a5affeb 108__BEGIN_NAMESPACE_STD
28f540f4 109/* Copy SRC to DEST. */
c1422e5b 110extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
be27d08c 111 __THROW __nonnull ((1, 2));
28f540f4 112/* Copy no more than N characters of SRC to DEST. */
c1422e5b 113extern char *strncpy (char *__restrict __dest,
be27d08c
UD
114 __const char *__restrict __src, size_t __n)
115 __THROW __nonnull ((1, 2));
28f540f4
RM
116
117/* Append SRC onto DEST. */
c1422e5b 118extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
be27d08c 119 __THROW __nonnull ((1, 2));
28f540f4 120/* Append no more than N characters from SRC onto DEST. */
c1422e5b 121extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
be27d08c 122 size_t __n) __THROW __nonnull ((1, 2));
28f540f4
RM
123
124/* Compare S1 and S2. */
ca5a4c3c 125extern int strcmp (__const char *__s1, __const char *__s2)
be27d08c 126 __THROW __attribute_pure__ __nonnull ((1, 2));
28f540f4 127/* Compare N characters of S1 and S2. */
c1422e5b 128extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
be27d08c 129 __THROW __attribute_pure__ __nonnull ((1, 2));
28f540f4
RM
130
131/* Compare the collated forms of S1 and S2. */
ca5a4c3c 132extern int strcoll (__const char *__s1, __const char *__s2)
be27d08c 133 __THROW __attribute_pure__ __nonnull ((1, 2));
28f540f4 134/* Put a transformation of SRC into no more than N bytes of DEST. */
c1422e5b 135extern size_t strxfrm (char *__restrict __dest,
be27d08c
UD
136 __const char *__restrict __src, size_t __n)
137 __THROW __nonnull ((2));
7a5affeb 138__END_NAMESPACE_STD
28f540f4 139
c84142e8
UD
140#ifdef __USE_GNU
141/* The following functions are equivalent to the both above but they
142 take the locale they use for the collation as an extra argument.
143 This is not standardsized but something like will come. */
144# include <xlocale.h>
145
146/* Compare the collated forms of S1 and S2 using rules from L. */
1ab62b32 147extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
be27d08c 148 __THROW __attribute_pure__ __nonnull ((1, 2, 3));
c84142e8 149/* Put a transformation of SRC into no more than N bytes of DEST. */
1ab62b32 150extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n,
be27d08c 151 __locale_t __l) __THROW __nonnull ((2, 4));
c84142e8
UD
152#endif
153
377a515b 154#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
28f540f4 155/* Duplicate S, returning an identical malloc'd string. */
be27d08c
UD
156extern char *strdup (__const char *__s)
157 __THROW __attribute_malloc__ __nonnull ((1));
28f540f4
RM
158#endif
159
6dbe2837
RM
160/* Return a malloc'd copy of at most N bytes of STRING. The
161 resultant string is terminated even if no null terminator
162 appears before STRING[N]. */
377a515b 163#if defined __USE_GNU
e9e9b245 164extern char *strndup (__const char *__string, size_t __n)
be27d08c 165 __THROW __attribute_malloc__ __nonnull ((1));
6d52618b 166#endif
6dbe2837 167
377a515b 168#if defined __USE_GNU && defined __GNUC__
036cc82f 169/* Duplicate S, returning an identical alloca'd string. */
3996f34b 170# define strdupa(s) \
036cc82f
RM
171 (__extension__ \
172 ({ \
173 __const char *__old = (s); \
174 size_t __len = strlen (__old) + 1; \
8c8f3704 175 char *__new = (char *) __builtin_alloca (__len); \
3996f34b 176 (char *) memcpy (__new, __old, __len); \
036cc82f
RM
177 }))
178
6dbe2837 179/* Return an alloca'd copy of at most N bytes of string. */
3996f34b 180# define strndupa(s, n) \
036cc82f
RM
181 (__extension__ \
182 ({ \
183 __const char *__old = (s); \
184 size_t __len = strnlen (__old, (n)); \
8c8f3704 185 char *__new = (char *) __builtin_alloca (__len + 1); \
036cc82f 186 __new[__len] = '\0'; \
3996f34b 187 (char *) memcpy (__new, __old, __len); \
036cc82f 188 }))
02ac66c5
RM
189#endif
190
7a5affeb 191__BEGIN_NAMESPACE_STD
28f540f4 192/* Find the first occurrence of C in S. */
d8387c7b
UD
193#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
194extern "C++" char *strchr (char *__s, int __c)
195 __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
196extern "C++" __const char *strchr (__const char *__s, int __c)
197 __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
198#else
be27d08c
UD
199extern char *strchr (__const char *__s, int __c)
200 __THROW __attribute_pure__ __nonnull ((1));
d8387c7b 201#endif
28f540f4 202/* Find the last occurrence of C in S. */
d8387c7b
UD
203#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
204extern "C++" char *strrchr (char *__s, int __c)
205 __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
206extern "C++" __const char *strrchr (__const char *__s, int __c)
207 __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
208#else
be27d08c
UD
209extern char *strrchr (__const char *__s, int __c)
210 __THROW __attribute_pure__ __nonnull ((1));
d8387c7b 211#endif
7a5affeb 212__END_NAMESPACE_STD
28f540f4 213
c4563d2d 214#ifdef __USE_GNU
557a9213 215/* This function is similar to `strchr'. But it returns a pointer to
c4563d2d 216 the closing NUL byte in case C is not found in S. */
d8387c7b
UD
217# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
218extern "C++" char *strchrnul (char *__s, int __c)
219 __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
220extern "C++" __const char *strchrnul (__const char *__s, int __c)
221 __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
222# else
be27d08c
UD
223extern char *strchrnul (__const char *__s, int __c)
224 __THROW __attribute_pure__ __nonnull ((1));
d8387c7b 225# endif
c4563d2d
UD
226#endif
227
7a5affeb 228__BEGIN_NAMESPACE_STD
28f540f4
RM
229/* Return the length of the initial segment of S which
230 consists entirely of characters not in REJECT. */
ca5a4c3c 231extern size_t strcspn (__const char *__s, __const char *__reject)
be27d08c 232 __THROW __attribute_pure__ __nonnull ((1, 2));
28f540f4
RM
233/* Return the length of the initial segment of S which
234 consists entirely of characters in ACCEPT. */
ca5a4c3c 235extern size_t strspn (__const char *__s, __const char *__accept)
be27d08c 236 __THROW __attribute_pure__ __nonnull ((1, 2));
6d52618b 237/* Find the first occurrence in S of any character in ACCEPT. */
d8387c7b
UD
238#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
239extern "C++" char *strpbrk (char *__s, __const char *__accept)
240 __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
241extern "C++" __const char *strpbrk (__const char *__s, __const char *__accept)
242 __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
243#else
ca5a4c3c 244extern char *strpbrk (__const char *__s, __const char *__accept)
be27d08c 245 __THROW __attribute_pure__ __nonnull ((1, 2));
d8387c7b 246#endif
6d52618b 247/* Find the first occurrence of NEEDLE in HAYSTACK. */
d8387c7b
UD
248#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
249extern "C++" char *strstr (char *__haystack, __const char *__needle)
250 __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
251extern "C++" __const char *strstr (__const char *__haystack,
252 __const char *__needle)
253 __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
254#else
ca5a4c3c 255extern char *strstr (__const char *__haystack, __const char *__needle)
be27d08c 256 __THROW __attribute_pure__ __nonnull ((1, 2));
d8387c7b 257#endif
f4017d20 258
f4017d20 259
28f540f4 260/* Divide S into tokens separated by characters in DELIM. */
c1422e5b 261extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
be27d08c 262 __THROW __nonnull ((2));
7a5affeb 263__END_NAMESPACE_STD
28f540f4 264
59dd8641
RM
265/* Divide S into tokens separated by characters in DELIM. Information
266 passed between calls are stored in SAVE_PTR. */
c1422e5b
UD
267extern char *__strtok_r (char *__restrict __s,
268 __const char *__restrict __delim,
be27d08c
UD
269 char **__restrict __save_ptr)
270 __THROW __nonnull ((2, 3));
89a9e37b 271#if defined __USE_POSIX || defined __USE_MISC
c1422e5b 272extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
be27d08c
UD
273 char **__restrict __save_ptr)
274 __THROW __nonnull ((2, 3));
9d187dd4 275#endif
59dd8641 276
7a5affeb
UD
277#ifdef __USE_GNU
278/* Similar to `strstr' but this function ignores the case of both strings. */
d8387c7b
UD
279# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
280extern "C++" char *strcasestr (char *__haystack, __const char *__needle)
281 __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
282extern "C++" __const char *strcasestr (__const char *__haystack,
283 __const char *__needle)
284 __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
285# else
7a5affeb 286extern char *strcasestr (__const char *__haystack, __const char *__needle)
be27d08c 287 __THROW __attribute_pure__ __nonnull ((1, 2));
d8387c7b 288# endif
7a5affeb
UD
289#endif
290
9d187dd4 291#ifdef __USE_GNU
6d52618b 292/* Find the first occurrence of NEEDLE in HAYSTACK.
28f540f4
RM
293 NEEDLE is NEEDLELEN bytes long;
294 HAYSTACK is HAYSTACKLEN bytes long. */
c1422e5b 295extern void *memmem (__const void *__haystack, size_t __haystacklen,
ca5a4c3c 296 __const void *__needle, size_t __needlelen)
be27d08c 297 __THROW __attribute_pure__ __nonnull ((1, 3));
9a0a462c
UD
298
299/* Copy N bytes of SRC to DEST, return pointer to bytes after the
300 last written byte. */
c1422e5b 301extern void *__mempcpy (void *__restrict __dest,
be27d08c
UD
302 __const void *__restrict __src, size_t __n)
303 __THROW __nonnull ((1, 2));
c1422e5b 304extern void *mempcpy (void *__restrict __dest,
be27d08c
UD
305 __const void *__restrict __src, size_t __n)
306 __THROW __nonnull ((1, 2));
28f540f4
RM
307#endif
308
8d71c7b0 309
7a5affeb 310__BEGIN_NAMESPACE_STD
28f540f4 311/* Return the length of S. */
be27d08c
UD
312extern size_t strlen (__const char *__s)
313 __THROW __attribute_pure__ __nonnull ((1));
7a5affeb 314__END_NAMESPACE_STD
28f540f4 315
8d71c7b0
RM
316#ifdef __USE_GNU
317/* Find the length of STRING, but scan at most MAXLEN characters.
318 If no '\0' terminator is found in that many characters, return MAXLEN. */
ca5a4c3c 319extern size_t strnlen (__const char *__string, size_t __maxlen)
be27d08c 320 __THROW __attribute_pure__ __nonnull ((1));
8d71c7b0
RM
321#endif
322
323
7a5affeb 324__BEGIN_NAMESPACE_STD
73299943
UD
325/* Return a string describing the meaning of the `errno' code in ERRNUM. */
326extern char *strerror (int __errnum) __THROW;
7a5affeb 327__END_NAMESPACE_STD
47cbdebd 328#if defined __USE_XOPEN2K || defined __USE_MISC
61645263
UD
329/* Reentrant version of `strerror'.
330 There are 2 flavors of `strerror_r', GNU which returns the string
331 and may or may not use the supplied temporary buffer and POSIX one
332 which fills the string into the buffer.
333 To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
334 without -D_GNU_SOURCE is needed, otherwise the GNU version is
335 preferred. */
336# if defined __USE_XOPEN2K && !defined __USE_GNU
337/* Fill BUF with a string describing the meaning of the `errno' code in
338 ERRNUM. */
f377d022
UD
339# ifdef __REDIRECT_NTH
340extern int __REDIRECT_NTH (strerror_r,
341 (int __errnum, char *__buf, size_t __buflen),
be27d08c 342 __xpg_strerror_r) __nonnull ((2));
61645263
UD
343# else
344extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
be27d08c 345 __THROW __nonnull ((2));
61645263
UD
346# define strerror_r __xpg_strerror_r
347# endif
348# else
349/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be
350 used. */
be27d08c
UD
351extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
352 __THROW __nonnull ((2));
61645263 353# endif
60478656 354#endif
28f540f4 355
4a44ce79
UD
356#ifdef __USE_GNU
357/* Translate error number to string according to the locale L. */
358extern char *strerror_l (int __errnum, __locale_t __l) __THROW;
359#endif
360
361
61eb22d3
UD
362/* We define this function always since `bzero' is sometimes needed when
363 the namespace rules does not allow this. */
be27d08c 364extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
61eb22d3 365
47cbdebd 366#ifdef __USE_BSD
28f540f4 367/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
be27d08c
UD
368extern void bcopy (__const void *__src, void *__dest, size_t __n)
369 __THROW __nonnull ((1, 2));
28f540f4
RM
370
371/* Set N bytes of S to 0. */
be27d08c 372extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
28f540f4
RM
373
374/* Compare N bytes of S1 and S2 (same as memcmp). */
ca5a4c3c 375extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
be27d08c 376 __THROW __attribute_pure__ __nonnull ((1, 2));
28f540f4 377
2c6fe0bd 378/* Find the first occurrence of C in S (same as strchr). */
d8387c7b
UD
379# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
380extern "C++" char *index (char *__s, int __c)
381 __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
382extern "C++" __const char *index (__const char *__s, int __c)
383 __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
384# else
be27d08c
UD
385extern char *index (__const char *__s, int __c)
386 __THROW __attribute_pure__ __nonnull ((1));
d8387c7b 387# endif
2c6fe0bd
UD
388
389/* Find the last occurrence of C in S (same as strrchr). */
d8387c7b
UD
390# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
391extern "C++" char *rindex (char *__s, int __c)
392 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
393extern "C++" __const char *rindex (__const char *__s, int __c)
394 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
395# else
be27d08c
UD
396extern char *rindex (__const char *__s, int __c)
397 __THROW __attribute_pure__ __nonnull ((1));
d8387c7b 398# endif
2c6fe0bd 399
28f540f4
RM
400/* Return the position of the first bit set in I, or 0 if none are set.
401 The least-significant bit is position 1, the most-significant 32. */
976da847 402extern int ffs (int __i) __THROW __attribute__ ((__const__));
bdd421cc
UD
403
404/* The following two functions are non-standard but necessary for non-32 bit
405 platforms. */
406# ifdef __USE_GNU
976da847 407extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
bdd421cc 408# ifdef __GNUC__
c1422e5b 409__extension__ extern int ffsll (long long int __ll)
976da847 410 __THROW __attribute__ ((__const__));
bdd421cc
UD
411# endif
412# endif
28f540f4
RM
413
414/* Compare S1 and S2, ignoring case. */
ca5a4c3c 415extern int strcasecmp (__const char *__s1, __const char *__s2)
be27d08c 416 __THROW __attribute_pure__ __nonnull ((1, 2));
28f540f4 417
6e86a7c2 418/* Compare no more than N chars of S1 and S2, ignoring case. */
c1422e5b 419extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
be27d08c 420 __THROW __attribute_pure__ __nonnull ((1, 2));
002e2dc4 421#endif /* Use BSD. */
6e86a7c2 422
0501d603
UD
423#ifdef __USE_GNU
424/* Again versions of a few functions which use the given locale instead
425 of the global one. */
1ab62b32 426extern int strcasecmp_l (__const char *__s1, __const char *__s2,
be27d08c
UD
427 __locale_t __loc)
428 __THROW __attribute_pure__ __nonnull ((1, 2, 3));
0501d603 429
1ab62b32
RM
430extern int strncasecmp_l (__const char *__s1, __const char *__s2,
431 size_t __n, __locale_t __loc)
be27d08c 432 __THROW __attribute_pure__ __nonnull ((1, 2, 4));
0501d603
UD
433#endif
434
2c6fe0bd 435#ifdef __USE_BSD
28f540f4
RM
436/* Return the next DELIM-delimited token from *STRINGP,
437 terminating it with a '\0', and update *STRINGP to point past it. */
c1422e5b 438extern char *strsep (char **__restrict __stringp,
be27d08c
UD
439 __const char *__restrict __delim)
440 __THROW __nonnull ((1, 2));
28f540f4
RM
441#endif
442
28f540f4 443#ifdef __USE_GNU
1f205a47 444/* Compare S1 and S2 as strings holding name & indices/version numbers. */
ca5a4c3c 445extern int strverscmp (__const char *__s1, __const char *__s2)
be27d08c 446 __THROW __attribute_pure__ __nonnull ((1, 2));
1f205a47 447
28f540f4 448/* Return a string describing the meaning of the signal number in SIG. */
c1422e5b 449extern char *strsignal (int __sig) __THROW;
28f540f4
RM
450
451/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
c1422e5b 452extern char *__stpcpy (char *__restrict __dest, __const char *__restrict __src)
be27d08c 453 __THROW __nonnull ((1, 2));
c1422e5b 454extern char *stpcpy (char *__restrict __dest, __const char *__restrict __src)
be27d08c 455 __THROW __nonnull ((1, 2));
28f540f4
RM
456
457/* Copy no more than N characters of SRC to DEST, returning the address of
458 the last character written into DEST. */
c1422e5b 459extern char *__stpncpy (char *__restrict __dest,
be27d08c
UD
460 __const char *__restrict __src, size_t __n)
461 __THROW __nonnull ((1, 2));
c1422e5b 462extern char *stpncpy (char *__restrict __dest,
be27d08c
UD
463 __const char *__restrict __src, size_t __n)
464 __THROW __nonnull ((1, 2));
28f540f4 465
28f540f4 466/* Sautee STRING briskly. */
be27d08c 467extern char *strfry (char *__string) __THROW __nonnull ((1));
28f540f4
RM
468
469/* Frobnicate N bytes of S. */
be27d08c 470extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1));
28f540f4 471
92f1da4d 472# ifndef basename
dd33e89f
UD
473/* Return the file name within directory of FILENAME. We don't
474 declare the function if the `basename' macro is available (defined
475 in <libgen.h>) which makes the XPG version of this function
476 available. */
d8387c7b
UD
477# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
478extern "C++" char *basename (char *__filename)
479 __THROW __asm ("basename") __nonnull ((1));
480extern "C++" __const char *basename (__const char *__filename)
481 __THROW __asm ("basename") __nonnull ((1));
482# else
be27d08c 483extern char *basename (__const char *__filename) __THROW __nonnull ((1));
d8387c7b 484# endif
92f1da4d 485# endif
84724245
RM
486#endif
487
55c14926 488
847a35a0 489#if defined __GNUC__ && __GNUC__ >= 2
07c416ed
AJ
490# if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
491 && !defined __NO_INLINE__ && !defined __cplusplus
9a0a462c
UD
492/* When using GNU CC we provide some optimized versions of selected
493 functions from this header. There are two kinds of optimizations:
494
61952351
UD
495 - machine-dependent optimizations, most probably using inline
496 assembler code; these might be quite expensive since the code
497 size can increase significantly.
9a0a462c
UD
498 These optimizations are not used unless the symbol
499 __USE_STRING_INLINES
61952351 500 is defined before including this header.
9a0a462c
UD
501
502 - machine-independent optimizations which do not increase the
503 code size significantly and which optimize mainly situations
504 where one or more arguments are compile-time constants.
505 These optimizations are used always when the compiler is
61952351 506 taught to optimize.
9a0a462c 507
61eb22d3
UD
508 One can inhibit all optimizations by defining __NO_STRING_INLINES. */
509
510/* Get the machine-dependent optimizations (if any). */
847a35a0 511# include <bits/string.h>
9a0a462c
UD
512
513/* These are generic optimizations which do not add too much inline code. */
847a35a0
UD
514# include <bits/string2.h>
515# endif
b5cc329c 516
de1c3ebb 517# if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
b5cc329c
UD
518/* Functions with security checks. */
519# include <bits/string3.h>
520# endif
92f1da4d
UD
521#endif
522
28f540f4
RM
523__END_DECLS
524
525#endif /* string.h */