1/* Copyright (C) 1991-1993,1995-2004,2007,2009 Free Software Foundation, Inc.
2   This file is part of the GNU C Library.
3
4   The GNU C Library is free software; you can redistribute it and/or
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.
8
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
12   Lesser General Public License for more details.
13
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.  */
18
19/*
20 *	ISO C99 Standard: 7.21 String handling	<string.h>
21 */
22
23#ifndef	_STRING_H
24#define	_STRING_H	1
25
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
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
40
41__BEGIN_NAMESPACE_STD
42/* Copy N bytes of SRC to DEST.  */
43extern void *memcpy (void *__restrict __dest,
44		     __const void *__restrict __src, size_t __n)
45     __THROW __nonnull ((1, 2));
46/* Copy N bytes of SRC to DEST, guaranteeing
47   correct behavior for overlapping strings.  */
48extern void *memmove (void *__dest, __const void *__src, size_t __n)
49     __THROW __nonnull ((1, 2));
50__END_NAMESPACE_STD
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.  */
55#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN
56extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
57		      int __c, size_t __n)
58     __THROW __nonnull ((1, 2));
59#endif /* SVID.  */
60
61
62__BEGIN_NAMESPACE_STD
63/* Set N bytes of S to C.  */
64extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
65
66/* Compare N bytes of S1 and S2.  */
67extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
68     __THROW __attribute_pure__ __nonnull ((1, 2));
69
70/* Search N bytes of S for C.  */
71#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
72extern "C++"
73{
74extern void *memchr (void *__s, int __c, size_t __n)
75      __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
76extern __const void *memchr (__const void *__s, int __c, size_t __n)
77      __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
78
79# ifdef __OPTIMIZE__
80__extern_always_inline void *
81memchr (void *__s, int __c, size_t __n) __THROW
82{
83  return __builtin_memchr (__s, __c, __n);
84}
85
86__extern_always_inline __const void *
87memchr (__const void *__s, int __c, size_t __n) __THROW
88{
89  return __builtin_memchr (__s, __c, __n);
90}
91# endif
92}
93#else
94extern void *memchr (__const void *__s, int __c, size_t __n)
95      __THROW __attribute_pure__ __nonnull ((1));
96#endif
97__END_NAMESPACE_STD
98
99#ifdef __USE_GNU
100/* Search in S for C.  This is similar to `memchr' but there is no
101   length limit.  */
102# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
103extern "C++" void *rawmemchr (void *__s, int __c)
104     __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
105extern "C++" __const void *rawmemchr (__const void *__s, int __c)
106     __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
107# else
108extern void *rawmemchr (__const void *__s, int __c)
109     __THROW __attribute_pure__ __nonnull ((1));
110# endif
111
112/* Search N bytes of S for the final occurrence of C.  */
113# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
114extern "C++" void *memrchr (void *__s, int __c, size_t __n)
115      __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
116extern "C++" __const void *memrchr (__const void *__s, int __c, size_t __n)
117      __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
118# else
119extern void *memrchr (__const void *__s, int __c, size_t __n)
120      __THROW __attribute_pure__ __nonnull ((1));
121# endif
122#endif
123
124
125__BEGIN_NAMESPACE_STD
126/* Copy SRC to DEST.  */
127extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
128     __THROW __nonnull ((1, 2));
129/* Copy no more than N characters of SRC to DEST.  */
130extern char *strncpy (char *__restrict __dest,
131		      __const char *__restrict __src, size_t __n)
132     __THROW __nonnull ((1, 2));
133
134/* Append SRC onto DEST.  */
135extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
136     __THROW __nonnull ((1, 2));
137/* Append no more than N characters from SRC onto DEST.  */
138extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
139		      size_t __n) __THROW __nonnull ((1, 2));
140
141/* Compare S1 and S2.  */
142extern int strcmp (__const char *__s1, __const char *__s2)
143     __THROW __attribute_pure__ __nonnull ((1, 2));
144/* Compare N characters of S1 and S2.  */
145extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
146     __THROW __attribute_pure__ __nonnull ((1, 2));
147
148/* Compare the collated forms of S1 and S2.  */
149extern int strcoll (__const char *__s1, __const char *__s2)
150     __THROW __attribute_pure__ __nonnull ((1, 2));
151/* Put a transformation of SRC into no more than N bytes of DEST.  */
152extern size_t strxfrm (char *__restrict __dest,
153		       __const char *__restrict __src, size_t __n)
154     __THROW __nonnull ((2));
155__END_NAMESPACE_STD
156
157#ifdef __USE_XOPEN2K8
158/* The following functions are equivalent to the both above but they
159   take the locale they use for the collation as an extra argument.
160   This is not standardsized but something like will come.  */
161# include <xlocale.h>
162
163/* Compare the collated forms of S1 and S2 using rules from L.  */
164extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
165     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
166/* Put a transformation of SRC into no more than N bytes of DEST.  */
167extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n,
168			 __locale_t __l) __THROW __nonnull ((2, 4));
169#endif
170
171#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
172/* Duplicate S, returning an identical malloc'd string.  */
173extern char *strdup (__const char *__s)
174     __THROW __attribute_malloc__ __nonnull ((1));
175#endif
176
177/* Return a malloc'd copy of at most N bytes of STRING.  The
178   resultant string is terminated even if no null terminator
179   appears before STRING[N].  */
180#if defined __USE_XOPEN2K8
181extern char *strndup (__const char *__string, size_t __n)
182     __THROW __attribute_malloc__ __nonnull ((1));
183#endif
184
185#if defined __USE_GNU && defined __GNUC__
186/* Duplicate S, returning an identical alloca'd string.  */
187# define strdupa(s)							      \
188  (__extension__							      \
189    ({									      \
190      __const char *__old = (s);					      \
191      size_t __len = strlen (__old) + 1;				      \
192      char *__new = (char *) __builtin_alloca (__len);			      \
193      (char *) memcpy (__new, __old, __len);				      \
194    }))
195
196/* Return an alloca'd copy of at most N bytes of string.  */
197# define strndupa(s, n)							      \
198  (__extension__							      \
199    ({									      \
200      __const char *__old = (s);					      \
201      size_t __len = strnlen (__old, (n));				      \
202      char *__new = (char *) __builtin_alloca (__len + 1);		      \
203      __new[__len] = '\0';						      \
204      (char *) memcpy (__new, __old, __len);				      \
205    }))
206#endif
207
208__BEGIN_NAMESPACE_STD
209/* Find the first occurrence of C in S.  */
210#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
211extern "C++"
212{
213extern char *strchr (char *__s, int __c)
214     __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
215extern __const char *strchr (__const char *__s, int __c)
216     __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
217
218# ifdef __OPTIMIZE__
219__extern_always_inline char *
220strchr (char *__s, int __c) __THROW
221{
222  return __builtin_strchr (__s, __c);
223}
224
225__extern_always_inline __const char *
226strchr (__const char *__s, int __c) __THROW
227{
228  return __builtin_strchr (__s, __c);
229}
230# endif
231}
232#else
233extern char *strchr (__const char *__s, int __c)
234     __THROW __attribute_pure__ __nonnull ((1));
235#endif
236/* Find the last occurrence of C in S.  */
237#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
238extern "C++"
239{
240extern char *strrchr (char *__s, int __c)
241     __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
242extern __const char *strrchr (__const char *__s, int __c)
243     __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
244
245# ifdef __OPTIMIZE__
246__extern_always_inline char *
247strrchr (char *__s, int __c) __THROW
248{
249  return __builtin_strrchr (__s, __c);
250}
251
252__extern_always_inline __const char *
253strrchr (__const char *__s, int __c) __THROW
254{
255  return __builtin_strrchr (__s, __c);
256}
257# endif
258}
259#else
260extern char *strrchr (__const char *__s, int __c)
261     __THROW __attribute_pure__ __nonnull ((1));
262#endif
263__END_NAMESPACE_STD
264
265#ifdef __USE_GNU
266/* This function is similar to `strchr'.  But it returns a pointer to
267   the closing NUL byte in case C is not found in S.  */
268# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
269extern "C++" char *strchrnul (char *__s, int __c)
270     __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
271extern "C++" __const char *strchrnul (__const char *__s, int __c)
272     __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
273# else
274extern char *strchrnul (__const char *__s, int __c)
275     __THROW __attribute_pure__ __nonnull ((1));
276# endif
277#endif
278
279__BEGIN_NAMESPACE_STD
280/* Return the length of the initial segment of S which
281   consists entirely of characters not in REJECT.  */
282extern size_t strcspn (__const char *__s, __const char *__reject)
283     __THROW __attribute_pure__ __nonnull ((1, 2));
284/* Return the length of the initial segment of S which
285   consists entirely of characters in ACCEPT.  */
286extern size_t strspn (__const char *__s, __const char *__accept)
287     __THROW __attribute_pure__ __nonnull ((1, 2));
288/* Find the first occurrence in S of any character in ACCEPT.  */
289#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
290extern "C++"
291{
292extern char *strpbrk (char *__s, __const char *__accept)
293     __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
294extern __const char *strpbrk (__const char *__s, __const char *__accept)
295     __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
296
297# ifdef __OPTIMIZE__
298__extern_always_inline char *
299strpbrk (char *__s, __const char *__accept) __THROW
300{
301  return __builtin_strpbrk (__s, __accept);
302}
303
304__extern_always_inline __const char *
305strpbrk (__const char *__s, __const char *__accept) __THROW
306{
307  return __builtin_strpbrk (__s, __accept);
308}
309# endif
310}
311#else
312extern char *strpbrk (__const char *__s, __const char *__accept)
313     __THROW __attribute_pure__ __nonnull ((1, 2));
314#endif
315/* Find the first occurrence of NEEDLE in HAYSTACK.  */
316#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
317extern "C++"
318{
319extern char *strstr (char *__haystack, __const char *__needle)
320     __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
321extern __const char *strstr (__const char *__haystack,
322			     __const char *__needle)
323     __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
324
325# ifdef __OPTIMIZE__
326__extern_always_inline char *
327strstr (char *__haystack, __const char *__needle) __THROW
328{
329  return __builtin_strstr (__haystack, __needle);
330}
331
332__extern_always_inline __const char *
333strstr (__const char *__haystack, __const char *__needle) __THROW
334{
335  return __builtin_strstr (__haystack, __needle);
336}
337# endif
338}
339#else
340extern char *strstr (__const char *__haystack, __const char *__needle)
341     __THROW __attribute_pure__ __nonnull ((1, 2));
342#endif
343
344
345/* Divide S into tokens separated by characters in DELIM.  */
346extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
347     __THROW __nonnull ((2));
348__END_NAMESPACE_STD
349
350/* Divide S into tokens separated by characters in DELIM.  Information
351   passed between calls are stored in SAVE_PTR.  */
352extern char *__strtok_r (char *__restrict __s,
353			 __const char *__restrict __delim,
354			 char **__restrict __save_ptr)
355     __THROW __nonnull ((2, 3));
356#if defined __USE_POSIX || defined __USE_MISC
357extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
358		       char **__restrict __save_ptr)
359     __THROW __nonnull ((2, 3));
360#endif
361
362#ifdef __USE_GNU
363/* Similar to `strstr' but this function ignores the case of both strings.  */
364# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
365extern "C++" char *strcasestr (char *__haystack, __const char *__needle)
366     __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
367extern "C++" __const char *strcasestr (__const char *__haystack,
368				       __const char *__needle)
369     __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
370# else
371extern char *strcasestr (__const char *__haystack, __const char *__needle)
372     __THROW __attribute_pure__ __nonnull ((1, 2));
373# endif
374#endif
375
376#ifdef __USE_GNU
377/* Find the first occurrence of NEEDLE in HAYSTACK.
378   NEEDLE is NEEDLELEN bytes long;
379   HAYSTACK is HAYSTACKLEN bytes long.  */
380extern void *memmem (__const void *__haystack, size_t __haystacklen,
381		     __const void *__needle, size_t __needlelen)
382     __THROW __attribute_pure__ __nonnull ((1, 3));
383
384/* Copy N bytes of SRC to DEST, return pointer to bytes after the
385   last written byte.  */
386extern void *__mempcpy (void *__restrict __dest,
387			__const void *__restrict __src, size_t __n)
388     __THROW __nonnull ((1, 2));
389extern void *mempcpy (void *__restrict __dest,
390		      __const void *__restrict __src, size_t __n)
391     __THROW __nonnull ((1, 2));
392#endif
393
394
395__BEGIN_NAMESPACE_STD
396/* Return the length of S.  */
397extern size_t strlen (__const char *__s)
398     __THROW __attribute_pure__ __nonnull ((1));
399__END_NAMESPACE_STD
400
401#ifdef	__USE_XOPEN2K8
402/* Find the length of STRING, but scan at most MAXLEN characters.
403   If no '\0' terminator is found in that many characters, return MAXLEN.  */
404extern size_t strnlen (__const char *__string, size_t __maxlen)
405     __THROW __attribute_pure__ __nonnull ((1));
406#endif
407
408
409__BEGIN_NAMESPACE_STD
410/* Return a string describing the meaning of the `errno' code in ERRNUM.  */
411extern char *strerror (int __errnum) __THROW;
412__END_NAMESPACE_STD
413#if defined __USE_XOPEN2K || defined __USE_MISC
414/* Reentrant version of `strerror'.
415   There are 2 flavors of `strerror_r', GNU which returns the string
416   and may or may not use the supplied temporary buffer and POSIX one
417   which fills the string into the buffer.
418   To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
419   without -D_GNU_SOURCE is needed, otherwise the GNU version is
420   preferred.  */
421# if defined __USE_XOPEN2K && !defined __USE_GNU
422/* Fill BUF with a string describing the meaning of the `errno' code in
423   ERRNUM.  */
424#  ifdef __REDIRECT_NTH
425extern int __REDIRECT_NTH (strerror_r,
426			   (int __errnum, char *__buf, size_t __buflen),
427			   __xpg_strerror_r) __nonnull ((2));
428#  else
429extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
430     __THROW __nonnull ((2));
431#   define strerror_r __xpg_strerror_r
432#  endif
433# else
434/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be
435   used.  */
436extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
437     __THROW __nonnull ((2));
438# endif
439#endif
440
441#ifdef __USE_XOPEN2K8
442/* Translate error number to string according to the locale L.  */
443extern char *strerror_l (int __errnum, __locale_t __l) __THROW;
444#endif
445
446
447/* We define this function always since `bzero' is sometimes needed when
448   the namespace rules does not allow this.  */
449extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
450
451#ifdef __USE_BSD
452/* Copy N bytes of SRC to DEST (like memmove, but args reversed).  */
453extern void bcopy (__const void *__src, void *__dest, size_t __n)
454     __THROW __nonnull ((1, 2));
455
456/* Set N bytes of S to 0.  */
457extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
458
459/* Compare N bytes of S1 and S2 (same as memcmp).  */
460extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
461     __THROW __attribute_pure__ __nonnull ((1, 2));
462
463/* Find the first occurrence of C in S (same as strchr).  */
464# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
465extern "C++"
466{
467extern char *index (char *__s, int __c)
468     __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
469extern __const char *index (__const char *__s, int __c)
470     __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
471
472#  if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO
473__extern_always_inline char *
474index (char *__s, int __c) __THROW
475{
476  return __builtin_index (__s, __c);
477}
478
479__extern_always_inline __const char *
480index (__const char *__s, int __c) __THROW
481{
482  return __builtin_index (__s, __c);
483}
484#  endif
485}
486# else
487extern char *index (__const char *__s, int __c)
488     __THROW __attribute_pure__ __nonnull ((1));
489# endif
490
491/* Find the last occurrence of C in S (same as strrchr).  */
492# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
493extern "C++"
494{
495extern char *rindex (char *__s, int __c)
496     __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
497extern __const char *rindex (__const char *__s, int __c)
498     __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
499
500#  if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO
501__extern_always_inline char *
502rindex (char *__s, int __c) __THROW
503{
504  return __builtin_rindex (__s, __c);
505}
506
507__extern_always_inline __const char *
508rindex (__const char *__s, int __c) __THROW
509{
510  return __builtin_rindex (__s, __c);
511}
512#endif
513}
514# else
515extern char *rindex (__const char *__s, int __c)
516     __THROW __attribute_pure__ __nonnull ((1));
517# endif
518
519/* Return the position of the first bit set in I, or 0 if none are set.
520   The least-significant bit is position 1, the most-significant 32.  */
521extern int ffs (int __i) __THROW __attribute__ ((__const__));
522
523/* The following two functions are non-standard but necessary for non-32 bit
524   platforms.  */
525# ifdef	__USE_GNU
526extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
527#  ifdef __GNUC__
528__extension__ extern int ffsll (long long int __ll)
529     __THROW __attribute__ ((__const__));
530#  endif
531# endif
532
533/* Compare S1 and S2, ignoring case.  */
534extern int strcasecmp (__const char *__s1, __const char *__s2)
535     __THROW __attribute_pure__ __nonnull ((1, 2));
536
537/* Compare no more than N chars of S1 and S2, ignoring case.  */
538extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
539     __THROW __attribute_pure__ __nonnull ((1, 2));
540#endif /* Use BSD.  */
541
542#ifdef	__USE_GNU
543/* Again versions of a few functions which use the given locale instead
544   of the global one.  */
545extern int strcasecmp_l (__const char *__s1, __const char *__s2,
546			 __locale_t __loc)
547     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
548
549extern int strncasecmp_l (__const char *__s1, __const char *__s2,
550			  size_t __n, __locale_t __loc)
551     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
552#endif
553
554#ifdef	__USE_BSD
555/* Return the next DELIM-delimited token from *STRINGP,
556   terminating it with a '\0', and update *STRINGP to point past it.  */
557extern char *strsep (char **__restrict __stringp,
558		     __const char *__restrict __delim)
559     __THROW __nonnull ((1, 2));
560#endif
561
562#ifdef	__USE_XOPEN2K8
563/* Return a string describing the meaning of the signal number in SIG.  */
564extern char *strsignal (int __sig) __THROW;
565
566/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST.  */
567extern char *__stpcpy (char *__restrict __dest, __const char *__restrict __src)
568     __THROW __nonnull ((1, 2));
569extern char *stpcpy (char *__restrict __dest, __const char *__restrict __src)
570     __THROW __nonnull ((1, 2));
571
572/* Copy no more than N characters of SRC to DEST, returning the address of
573   the last character written into DEST.  */
574extern char *__stpncpy (char *__restrict __dest,
575			__const char *__restrict __src, size_t __n)
576     __THROW __nonnull ((1, 2));
577extern char *stpncpy (char *__restrict __dest,
578		      __const char *__restrict __src, size_t __n)
579     __THROW __nonnull ((1, 2));
580#endif
581
582#ifdef	__USE_GNU
583/* Compare S1 and S2 as strings holding name & indices/version numbers.  */
584extern int strverscmp (__const char *__s1, __const char *__s2)
585     __THROW __attribute_pure__ __nonnull ((1, 2));
586
587/* Sautee STRING briskly.  */
588extern char *strfry (char *__string) __THROW __nonnull ((1));
589
590/* Frobnicate N bytes of S.  */
591extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1));
592
593# ifndef basename
594/* Return the file name within directory of FILENAME.  We don't
595   declare the function if the `basename' macro is available (defined
596   in <libgen.h>) which makes the XPG version of this function
597   available.  */
598#  ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
599extern "C++" char *basename (char *__filename)
600     __THROW __asm ("basename") __nonnull ((1));
601extern "C++" __const char *basename (__const char *__filename)
602     __THROW __asm ("basename") __nonnull ((1));
603#  else
604extern char *basename (__const char *__filename) __THROW __nonnull ((1));
605#  endif
606# endif
607#endif
608
609
610#if defined __GNUC__ && __GNUC__ >= 2
611# if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
612     && !defined __NO_INLINE__ && !defined __cplusplus
613/* When using GNU CC we provide some optimized versions of selected
614   functions from this header.  There are two kinds of optimizations:
615
616   - machine-dependent optimizations, most probably using inline
617     assembler code; these might be quite expensive since the code
618     size can increase significantly.
619     These optimizations are not used unless the symbol
620	__USE_STRING_INLINES
621     is defined before including this header.
622
623   - machine-independent optimizations which do not increase the
624     code size significantly and which optimize mainly situations
625     where one or more arguments are compile-time constants.
626     These optimizations are used always when the compiler is
627     taught to optimize.
628
629   One can inhibit all optimizations by defining __NO_STRING_INLINES.  */
630
631/* Get the machine-dependent optimizations (if any).  */
632#  include <bits/string.h>
633
634/* These are generic optimizations which do not add too much inline code.  */
635#  include <bits/string2.h>
636# endif
637
638# if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
639/* Functions with security checks.  */
640#  include <bits/string3.h>
641# endif
642#endif
643
644__END_DECLS
645
646#endif /* string.h  */
647