Support __STDC_WANT_LIB_EXT2__ feature test macro.
[glibc.git] / string / string.h
blob57deaa4191a23049ff3c1a89203fe6b2eab46f39
1 /* Copyright (C) 1991-2016 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 * ISO C99 Standard: 7.21 String handling <string.h>
22 #ifndef _STRING_H
23 #define _STRING_H 1
25 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26 #include <bits/libc-header-start.h>
28 __BEGIN_DECLS
30 /* Get size_t and NULL from <stddef.h>. */
31 #define __need_size_t
32 #define __need_NULL
33 #include <stddef.h>
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
41 __BEGIN_NAMESPACE_STD
42 /* Copy N bytes of SRC to DEST. */
43 extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
44 size_t __n) __THROW __nonnull ((1, 2));
45 /* Copy N bytes of SRC to DEST, guaranteeing
46 correct behavior for overlapping strings. */
47 extern void *memmove (void *__dest, const void *__src, size_t __n)
48 __THROW __nonnull ((1, 2));
49 __END_NAMESPACE_STD
51 /* Copy no more than N bytes of SRC to DEST, stopping when C is found.
52 Return the position in DEST one byte past where C was copied,
53 or NULL if C was not found in the first N bytes of SRC. */
54 #if defined __USE_MISC || defined __USE_XOPEN
55 extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
56 int __c, size_t __n)
57 __THROW __nonnull ((1, 2));
58 #endif /* Misc || X/Open. */
61 __BEGIN_NAMESPACE_STD
62 /* Set N bytes of S to C. */
63 extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
65 /* Compare N bytes of S1 and S2. */
66 extern int memcmp (const void *__s1, const void *__s2, size_t __n)
67 __THROW __attribute_pure__ __nonnull ((1, 2));
69 /* Search N bytes of S for C. */
70 #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
71 extern "C++"
73 extern void *memchr (void *__s, int __c, size_t __n)
74 __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
75 extern const void *memchr (const void *__s, int __c, size_t __n)
76 __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
78 # ifdef __OPTIMIZE__
79 __extern_always_inline void *
80 memchr (void *__s, int __c, size_t __n) __THROW
82 return __builtin_memchr (__s, __c, __n);
85 __extern_always_inline const void *
86 memchr (const void *__s, int __c, size_t __n) __THROW
88 return __builtin_memchr (__s, __c, __n);
90 # endif
92 #else
93 extern void *memchr (const void *__s, int __c, size_t __n)
94 __THROW __attribute_pure__ __nonnull ((1));
95 #endif
96 __END_NAMESPACE_STD
98 #ifdef __USE_GNU
99 /* Search in S for C. This is similar to `memchr' but there is no
100 length limit. */
101 # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
102 extern "C++" void *rawmemchr (void *__s, int __c)
103 __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
104 extern "C++" const void *rawmemchr (const void *__s, int __c)
105 __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
106 # else
107 extern void *rawmemchr (const void *__s, int __c)
108 __THROW __attribute_pure__ __nonnull ((1));
109 # endif
111 /* Search N bytes of S for the final occurrence of C. */
112 # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
113 extern "C++" void *memrchr (void *__s, int __c, size_t __n)
114 __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
115 extern "C++" const void *memrchr (const void *__s, int __c, size_t __n)
116 __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
117 # else
118 extern void *memrchr (const void *__s, int __c, size_t __n)
119 __THROW __attribute_pure__ __nonnull ((1));
120 # endif
121 #endif
124 __BEGIN_NAMESPACE_STD
125 /* Copy SRC to DEST. */
126 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
127 __THROW __nonnull ((1, 2));
128 /* Copy no more than N characters of SRC to DEST. */
129 extern char *strncpy (char *__restrict __dest,
130 const char *__restrict __src, size_t __n)
131 __THROW __nonnull ((1, 2));
133 /* Append SRC onto DEST. */
134 extern char *strcat (char *__restrict __dest, const char *__restrict __src)
135 __THROW __nonnull ((1, 2));
136 /* Append no more than N characters from SRC onto DEST. */
137 extern char *strncat (char *__restrict __dest, const char *__restrict __src,
138 size_t __n) __THROW __nonnull ((1, 2));
140 /* Compare S1 and S2. */
141 extern int strcmp (const char *__s1, const char *__s2)
142 __THROW __attribute_pure__ __nonnull ((1, 2));
143 /* Compare N characters of S1 and S2. */
144 extern int strncmp (const char *__s1, const char *__s2, size_t __n)
145 __THROW __attribute_pure__ __nonnull ((1, 2));
147 /* Compare the collated forms of S1 and S2. */
148 extern int strcoll (const char *__s1, const char *__s2)
149 __THROW __attribute_pure__ __nonnull ((1, 2));
150 /* Put a transformation of SRC into no more than N bytes of DEST. */
151 extern size_t strxfrm (char *__restrict __dest,
152 const char *__restrict __src, size_t __n)
153 __THROW __nonnull ((2));
154 __END_NAMESPACE_STD
156 #ifdef __USE_XOPEN2K8
157 /* The following functions are equivalent to the both above but they
158 take the locale they use for the collation as an extra argument.
159 This is not standardsized but something like will come. */
160 # include <xlocale.h>
162 /* Compare the collated forms of S1 and S2 using rules from L. */
163 extern int strcoll_l (const char *__s1, const char *__s2, __locale_t __l)
164 __THROW __attribute_pure__ __nonnull ((1, 2, 3));
165 /* Put a transformation of SRC into no more than N bytes of DEST. */
166 extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,
167 __locale_t __l) __THROW __nonnull ((2, 4));
168 #endif
170 #if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 \
171 || __GLIBC_USE (LIB_EXT2))
172 /* Duplicate S, returning an identical malloc'd string. */
173 extern char *strdup (const char *__s)
174 __THROW __attribute_malloc__ __nonnull ((1));
175 #endif
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 || __GLIBC_USE (LIB_EXT2)
181 extern char *strndup (const char *__string, size_t __n)
182 __THROW __attribute_malloc__ __nonnull ((1));
183 #endif
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); \
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); \
206 #endif
208 __BEGIN_NAMESPACE_STD
209 /* Find the first occurrence of C in S. */
210 #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
211 extern "C++"
213 extern char *strchr (char *__s, int __c)
214 __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
215 extern const char *strchr (const char *__s, int __c)
216 __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
218 # ifdef __OPTIMIZE__
219 __extern_always_inline char *
220 strchr (char *__s, int __c) __THROW
222 return __builtin_strchr (__s, __c);
225 __extern_always_inline const char *
226 strchr (const char *__s, int __c) __THROW
228 return __builtin_strchr (__s, __c);
230 # endif
232 #else
233 extern 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
238 extern "C++"
240 extern char *strrchr (char *__s, int __c)
241 __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
242 extern const char *strrchr (const char *__s, int __c)
243 __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
245 # ifdef __OPTIMIZE__
246 __extern_always_inline char *
247 strrchr (char *__s, int __c) __THROW
249 return __builtin_strrchr (__s, __c);
252 __extern_always_inline const char *
253 strrchr (const char *__s, int __c) __THROW
255 return __builtin_strrchr (__s, __c);
257 # endif
259 #else
260 extern char *strrchr (const char *__s, int __c)
261 __THROW __attribute_pure__ __nonnull ((1));
262 #endif
263 __END_NAMESPACE_STD
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
269 extern "C++" char *strchrnul (char *__s, int __c)
270 __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
271 extern "C++" const char *strchrnul (const char *__s, int __c)
272 __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
273 # else
274 extern char *strchrnul (const char *__s, int __c)
275 __THROW __attribute_pure__ __nonnull ((1));
276 # endif
277 #endif
279 __BEGIN_NAMESPACE_STD
280 /* Return the length of the initial segment of S which
281 consists entirely of characters not in REJECT. */
282 extern 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. */
286 extern 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
290 extern "C++"
292 extern char *strpbrk (char *__s, const char *__accept)
293 __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
294 extern const char *strpbrk (const char *__s, const char *__accept)
295 __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
297 # ifdef __OPTIMIZE__
298 __extern_always_inline char *
299 strpbrk (char *__s, const char *__accept) __THROW
301 return __builtin_strpbrk (__s, __accept);
304 __extern_always_inline const char *
305 strpbrk (const char *__s, const char *__accept) __THROW
307 return __builtin_strpbrk (__s, __accept);
309 # endif
311 #else
312 extern 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
317 extern "C++"
319 extern char *strstr (char *__haystack, const char *__needle)
320 __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
321 extern const char *strstr (const char *__haystack, const char *__needle)
322 __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
324 # ifdef __OPTIMIZE__
325 __extern_always_inline char *
326 strstr (char *__haystack, const char *__needle) __THROW
328 return __builtin_strstr (__haystack, __needle);
331 __extern_always_inline const char *
332 strstr (const char *__haystack, const char *__needle) __THROW
334 return __builtin_strstr (__haystack, __needle);
336 # endif
338 #else
339 extern char *strstr (const char *__haystack, const char *__needle)
340 __THROW __attribute_pure__ __nonnull ((1, 2));
341 #endif
344 /* Divide S into tokens separated by characters in DELIM. */
345 extern char *strtok (char *__restrict __s, const char *__restrict __delim)
346 __THROW __nonnull ((2));
347 __END_NAMESPACE_STD
349 /* Divide S into tokens separated by characters in DELIM. Information
350 passed between calls are stored in SAVE_PTR. */
351 extern char *__strtok_r (char *__restrict __s,
352 const char *__restrict __delim,
353 char **__restrict __save_ptr)
354 __THROW __nonnull ((2, 3));
355 #ifdef __USE_POSIX
356 extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
357 char **__restrict __save_ptr)
358 __THROW __nonnull ((2, 3));
359 #endif
361 #ifdef __USE_GNU
362 /* Similar to `strstr' but this function ignores the case of both strings. */
363 # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
364 extern "C++" char *strcasestr (char *__haystack, const char *__needle)
365 __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
366 extern "C++" const char *strcasestr (const char *__haystack,
367 const char *__needle)
368 __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
369 # else
370 extern char *strcasestr (const char *__haystack, const char *__needle)
371 __THROW __attribute_pure__ __nonnull ((1, 2));
372 # endif
373 #endif
375 #ifdef __USE_GNU
376 /* Find the first occurrence of NEEDLE in HAYSTACK.
377 NEEDLE is NEEDLELEN bytes long;
378 HAYSTACK is HAYSTACKLEN bytes long. */
379 extern void *memmem (const void *__haystack, size_t __haystacklen,
380 const void *__needle, size_t __needlelen)
381 __THROW __attribute_pure__ __nonnull ((1, 3));
383 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
384 last written byte. */
385 extern void *__mempcpy (void *__restrict __dest,
386 const void *__restrict __src, size_t __n)
387 __THROW __nonnull ((1, 2));
388 extern void *mempcpy (void *__restrict __dest,
389 const void *__restrict __src, size_t __n)
390 __THROW __nonnull ((1, 2));
391 #endif
394 __BEGIN_NAMESPACE_STD
395 /* Return the length of S. */
396 extern size_t strlen (const char *__s)
397 __THROW __attribute_pure__ __nonnull ((1));
398 __END_NAMESPACE_STD
400 #ifdef __USE_XOPEN2K8
401 /* Find the length of STRING, but scan at most MAXLEN characters.
402 If no '\0' terminator is found in that many characters, return MAXLEN. */
403 extern size_t strnlen (const char *__string, size_t __maxlen)
404 __THROW __attribute_pure__ __nonnull ((1));
405 #endif
408 __BEGIN_NAMESPACE_STD
409 /* Return a string describing the meaning of the `errno' code in ERRNUM. */
410 extern char *strerror (int __errnum) __THROW;
411 __END_NAMESPACE_STD
412 #ifdef __USE_XOPEN2K
413 /* Reentrant version of `strerror'.
414 There are 2 flavors of `strerror_r', GNU which returns the string
415 and may or may not use the supplied temporary buffer and POSIX one
416 which fills the string into the buffer.
417 To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
418 without -D_GNU_SOURCE is needed, otherwise the GNU version is
419 preferred. */
420 # if defined __USE_XOPEN2K && !defined __USE_GNU
421 /* Fill BUF with a string describing the meaning of the `errno' code in
422 ERRNUM. */
423 # ifdef __REDIRECT_NTH
424 extern int __REDIRECT_NTH (strerror_r,
425 (int __errnum, char *__buf, size_t __buflen),
426 __xpg_strerror_r) __nonnull ((2));
427 # else
428 extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
429 __THROW __nonnull ((2));
430 # define strerror_r __xpg_strerror_r
431 # endif
432 # else
433 /* If a temporary buffer is required, at most BUFLEN bytes of BUF will be
434 used. */
435 extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
436 __THROW __nonnull ((2)) __wur;
437 # endif
438 #endif
440 #ifdef __USE_XOPEN2K8
441 /* Translate error number to string according to the locale L. */
442 extern char *strerror_l (int __errnum, __locale_t __l) __THROW;
443 #endif
446 /* We define this function always since `bzero' is sometimes needed when
447 the namespace rules does not allow this. */
448 extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
450 #ifdef __USE_MISC
451 /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
452 extern void bcopy (const void *__src, void *__dest, size_t __n)
453 __THROW __nonnull ((1, 2));
455 /* Set N bytes of S to 0. */
456 extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
458 /* Compare N bytes of S1 and S2 (same as memcmp). */
459 extern int bcmp (const void *__s1, const void *__s2, size_t __n)
460 __THROW __attribute_pure__ __nonnull ((1, 2));
462 /* Find the first occurrence of C in S (same as strchr). */
463 # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
464 extern "C++"
466 extern char *index (char *__s, int __c)
467 __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
468 extern const char *index (const char *__s, int __c)
469 __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
471 # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO
472 __extern_always_inline char *
473 index (char *__s, int __c) __THROW
475 return __builtin_index (__s, __c);
478 __extern_always_inline const char *
479 index (const char *__s, int __c) __THROW
481 return __builtin_index (__s, __c);
483 # endif
485 # else
486 extern char *index (const char *__s, int __c)
487 __THROW __attribute_pure__ __nonnull ((1));
488 # endif
490 /* Find the last occurrence of C in S (same as strrchr). */
491 # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
492 extern "C++"
494 extern char *rindex (char *__s, int __c)
495 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
496 extern const char *rindex (const char *__s, int __c)
497 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
499 # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO
500 __extern_always_inline char *
501 rindex (char *__s, int __c) __THROW
503 return __builtin_rindex (__s, __c);
506 __extern_always_inline const char *
507 rindex (const char *__s, int __c) __THROW
509 return __builtin_rindex (__s, __c);
511 #endif
513 # else
514 extern char *rindex (const char *__s, int __c)
515 __THROW __attribute_pure__ __nonnull ((1));
516 # endif
518 /* Return the position of the first bit set in I, or 0 if none are set.
519 The least-significant bit is position 1, the most-significant 32. */
520 extern int ffs (int __i) __THROW __attribute__ ((__const__));
522 /* The following two functions are non-standard but necessary for non-32 bit
523 platforms. */
524 # ifdef __USE_GNU
525 extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
526 __extension__ extern int ffsll (long long int __ll)
527 __THROW __attribute__ ((__const__));
528 # endif
530 /* Compare S1 and S2, ignoring case. */
531 extern int strcasecmp (const char *__s1, const char *__s2)
532 __THROW __attribute_pure__ __nonnull ((1, 2));
534 /* Compare no more than N chars of S1 and S2, ignoring case. */
535 extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
536 __THROW __attribute_pure__ __nonnull ((1, 2));
537 #endif /* Use misc. */
539 #ifdef __USE_GNU
540 /* Again versions of a few functions which use the given locale instead
541 of the global one. */
542 extern int strcasecmp_l (const char *__s1, const char *__s2,
543 __locale_t __loc)
544 __THROW __attribute_pure__ __nonnull ((1, 2, 3));
546 extern int strncasecmp_l (const char *__s1, const char *__s2,
547 size_t __n, __locale_t __loc)
548 __THROW __attribute_pure__ __nonnull ((1, 2, 4));
549 #endif
551 #ifdef __USE_MISC
552 /* Return the next DELIM-delimited token from *STRINGP,
553 terminating it with a '\0', and update *STRINGP to point past it. */
554 extern char *strsep (char **__restrict __stringp,
555 const char *__restrict __delim)
556 __THROW __nonnull ((1, 2));
557 #endif
559 #ifdef __USE_XOPEN2K8
560 /* Return a string describing the meaning of the signal number in SIG. */
561 extern char *strsignal (int __sig) __THROW;
563 /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
564 extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)
565 __THROW __nonnull ((1, 2));
566 extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
567 __THROW __nonnull ((1, 2));
569 /* Copy no more than N characters of SRC to DEST, returning the address of
570 the last character written into DEST. */
571 extern char *__stpncpy (char *__restrict __dest,
572 const char *__restrict __src, size_t __n)
573 __THROW __nonnull ((1, 2));
574 extern char *stpncpy (char *__restrict __dest,
575 const char *__restrict __src, size_t __n)
576 __THROW __nonnull ((1, 2));
577 #endif
579 #ifdef __USE_GNU
580 /* Compare S1 and S2 as strings holding name & indices/version numbers. */
581 extern int strverscmp (const char *__s1, const char *__s2)
582 __THROW __attribute_pure__ __nonnull ((1, 2));
584 /* Sautee STRING briskly. */
585 extern char *strfry (char *__string) __THROW __nonnull ((1));
587 /* Frobnicate N bytes of S. */
588 extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1));
590 # ifndef basename
591 /* Return the file name within directory of FILENAME. We don't
592 declare the function if the `basename' macro is available (defined
593 in <libgen.h>) which makes the XPG version of this function
594 available. */
595 # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
596 extern "C++" char *basename (char *__filename)
597 __THROW __asm ("basename") __nonnull ((1));
598 extern "C++" const char *basename (const char *__filename)
599 __THROW __asm ("basename") __nonnull ((1));
600 # else
601 extern char *basename (const char *__filename) __THROW __nonnull ((1));
602 # endif
603 # endif
604 #endif
607 #if __GNUC_PREREQ (3,4)
608 # if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
609 && !defined __NO_INLINE__ && !defined __cplusplus
610 /* When using GNU CC we provide some optimized versions of selected
611 functions from this header. There are two kinds of optimizations:
613 - machine-dependent optimizations, most probably using inline
614 assembler code; these might be quite expensive since the code
615 size can increase significantly.
616 These optimizations are not used unless the symbol
617 __USE_STRING_INLINES
618 is defined before including this header.
620 - machine-independent optimizations which do not increase the
621 code size significantly and which optimize mainly situations
622 where one or more arguments are compile-time constants.
623 These optimizations are used always when the compiler is
624 taught to optimize.
626 One can inhibit all optimizations by defining __NO_STRING_INLINES. */
628 /* Get the machine-dependent optimizations (if any). */
629 # include <bits/string.h>
631 /* These are generic optimizations which do not add too much inline code. */
632 # include <bits/string2.h>
633 # endif
635 # if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
636 /* Functions with security checks. */
637 # include <bits/string3.h>
638 # endif
639 #endif
641 #if defined __USE_GNU && defined __OPTIMIZE__ \
642 && defined __extern_always_inline && __GNUC_PREREQ (3,2)
643 # if !defined _FORCE_INLINES && !defined _HAVE_STRING_ARCH_mempcpy
645 #define mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
646 #define __mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
648 __extern_always_inline void *
649 __mempcpy_inline (void *__restrict __dest,
650 const void *__restrict __src, size_t __n)
652 return (char *) memcpy (__dest, __src, __n) + __n;
655 # endif
656 #endif
658 __END_DECLS
660 #endif /* string.h */