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