1 /* Machine-independant string function optimizations.
2 Copyright (C) 1997-2004, 2007, 2008, 2012 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
21 # error "Never use <bits/string2.h> directly; include <string.h> instead."
24 #if !defined __NO_STRING_INLINES && !defined __BOUNDED_POINTERS__
26 /* Unlike the definitions in the header <bits/string.h> the
27 definitions contained here are not optimized down to assembler
28 level. Those optimizations are not always a good idea since this
29 means the code size increases a lot. Instead the definitions here
30 optimize some functions in a way which do not dramatically
31 increase the code size and which do not use assembler. The main
32 trick is to use GCC's `__builtin_constant_p' function.
34 Every function XXX which has a defined version in
35 <bits/string.h> must be accompanied by a symbol _HAVE_STRING_ARCH_XXX
36 to make sure we don't get redefinitions.
38 We must use here macros instead of inline functions since the
39 trick won't work with the latter. */
41 #ifndef __STRING_INLINE
43 # define __STRING_INLINE inline
45 # define __STRING_INLINE __extern_inline
49 #if _STRING_ARCH_unaligned
50 /* If we can do unaligned memory accesses we must know the endianess. */
52 # include <bits/types.h>
54 # if __BYTE_ORDER == __LITTLE_ENDIAN
55 # define __STRING2_SMALL_GET16(src, idx) \
56 (((const unsigned char *) (const char *) (src))[idx + 1] << 8 \
57 | ((const unsigned char *) (const char *) (src))[idx])
58 # define __STRING2_SMALL_GET32(src, idx) \
59 (((((const unsigned char *) (const char *) (src))[idx + 3] << 8 \
60 | ((const unsigned char *) (const char *) (src))[idx + 2]) << 8 \
61 | ((const unsigned char *) (const char *) (src))[idx + 1]) << 8 \
62 | ((const unsigned char *) (const char *) (src))[idx])
64 # define __STRING2_SMALL_GET16(src, idx) \
65 (((const unsigned char *) (const char *) (src))[idx] << 8 \
66 | ((const unsigned char *) (const char *) (src))[idx + 1])
67 # define __STRING2_SMALL_GET32(src, idx) \
68 (((((const unsigned char *) (const char *) (src))[idx] << 8 \
69 | ((const unsigned char *) (const char *) (src))[idx + 1]) << 8 \
70 | ((const unsigned char *) (const char *) (src))[idx + 2]) << 8 \
71 | ((const unsigned char *) (const char *) (src))[idx + 3])
74 /* These are a few types we need for the optimizations if we cannot
75 use unaligned memory accesses. */
76 # define __STRING2_COPY_TYPE(N) \
77 typedef struct { unsigned char __arr[N]; } \
78 __attribute__ ((__packed__)) __STRING2_COPY_ARR##N
79 __STRING2_COPY_TYPE (2);
80 __STRING2_COPY_TYPE (3);
81 __STRING2_COPY_TYPE (4);
82 __STRING2_COPY_TYPE (5);
83 __STRING2_COPY_TYPE (6);
84 __STRING2_COPY_TYPE (7);
85 __STRING2_COPY_TYPE (8);
86 # undef __STRING2_COPY_TYPE
89 /* Dereferencing a pointer arg to run sizeof on it fails for the void
90 pointer case, so we use this instead.
91 Note that __x is evaluated twice. */
92 #define __string2_1bptr_p(__x) \
93 ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1)
95 /* Set N bytes of S to C. */
96 #if !defined _HAVE_STRING_ARCH_memset
97 # if !__GNUC_PREREQ (3, 0)
98 # if _STRING_ARCH_unaligned
99 # define memset(s, c, n) \
100 (__extension__ (__builtin_constant_p (n) && (n) <= 16 \
102 ? __memset_1 (s, c) \
103 : __memset_gc (s, c, n)) \
104 : (__builtin_constant_p (c) && (c) == '\0' \
105 ? ({ void *__s = (s); __bzero (__s, n); __s; }) \
106 : memset (s, c, n))))
108 # define __memset_1(s, c) ({ void *__s = (s); \
109 *((__uint8_t *) __s) = (__uint8_t) c; __s; })
111 # define __memset_gc(s, c, n) \
112 ({ void *__s = (s); \
115 unsigned short int __usi; \
116 unsigned char __uc; \
118 __uint8_t __c = (__uint8_t) (c); \
120 /* This `switch' statement will be removed at compile-time. */ \
121 switch ((unsigned int) (n)) \
124 __u->__ui = __c * 0x01010101; \
125 __u = __extension__ ((void *) __u + 4); \
127 __u->__ui = __c * 0x01010101; \
128 __u = __extension__ ((void *) __u + 4); \
130 __u->__ui = __c * 0x01010101; \
131 __u = __extension__ ((void *) __u + 4); \
133 __u->__usi = (unsigned short int) __c * 0x0101; \
134 __u = __extension__ ((void *) __u + 2); \
135 __u->__uc = (unsigned char) __c; \
139 __u->__ui = __c * 0x01010101; \
140 __u = __extension__ ((void *) __u + 4); \
142 __u->__ui = __c * 0x01010101; \
143 __u = __extension__ ((void *) __u + 4); \
145 __u->__ui = __c * 0x01010101; \
146 __u = __extension__ ((void *) __u + 4); \
148 __u->__usi = (unsigned short int) __c * 0x0101; \
152 __u->__ui = __c * 0x01010101; \
153 __u = __extension__ ((void *) __u + 4); \
155 __u->__ui = __c * 0x01010101; \
156 __u = __extension__ ((void *) __u + 4); \
158 __u->__ui = __c * 0x01010101; \
159 __u = __extension__ ((void *) __u + 4); \
161 __u->__uc = (unsigned char) __c; \
165 __u->__ui = __c * 0x01010101; \
166 __u = __extension__ ((void *) __u + 4); \
168 __u->__ui = __c * 0x01010101; \
169 __u = __extension__ ((void *) __u + 4); \
171 __u->__ui = __c * 0x01010101; \
172 __u = __extension__ ((void *) __u + 4); \
174 __u->__ui = __c * 0x01010101; \
181 # define memset(s, c, n) \
182 (__extension__ (__builtin_constant_p (c) && (c) == '\0' \
183 ? ({ void *__s = (s); __bzero (__s, n); __s; }) \
188 /* GCC < 3.0 optimizes memset(s, 0, n) but not bzero(s, n).
189 The optimization is broken before EGCS 1.1.
190 GCC 3.0+ has __builtin_bzero as well, but at least till GCC 3.4
191 if it decides to call the library function, it calls memset
193 # if __GNUC_PREREQ (2, 91)
194 # define __bzero(s, n) __builtin_memset (s, '\0', n)
200 /* Copy N bytes from SRC to DEST, returning pointer to byte following the
203 # if !defined _HAVE_STRING_ARCH_mempcpy || defined _FORCE_INLINES
204 # ifndef _HAVE_STRING_ARCH_mempcpy
205 # if __GNUC_PREREQ (3, 4)
206 # define __mempcpy(dest, src, n) __builtin_mempcpy (dest, src, n)
207 # elif __GNUC_PREREQ (3, 0)
208 # define __mempcpy(dest, src, n) \
209 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
210 && __string2_1bptr_p (src) && n <= 8 \
211 ? __builtin_memcpy (dest, src, n) + (n) \
212 : __mempcpy (dest, src, n)))
214 # define __mempcpy(dest, src, n) \
215 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
216 && __string2_1bptr_p (src) && n <= 8 \
217 ? __mempcpy_small (dest, __mempcpy_args (src), n) \
218 : __mempcpy (dest, src, n)))
220 /* In glibc we use this function frequently but for namespace reasons
221 we have to use the name `__mempcpy'. */
222 # define mempcpy(dest, src, n) __mempcpy (dest, src, n)
225 # if !__GNUC_PREREQ (3, 0) || defined _FORCE_INLINES
226 # if _STRING_ARCH_unaligned
227 # ifndef _FORCE_INLINES
228 # define __mempcpy_args(src) \
229 ((const char *) (src))[0], ((const char *) (src))[2], \
230 ((const char *) (src))[4], ((const char *) (src))[6], \
231 __extension__ __STRING2_SMALL_GET16 (src, 0), \
232 __extension__ __STRING2_SMALL_GET16 (src, 4), \
233 __extension__ __STRING2_SMALL_GET32 (src, 0), \
234 __extension__ __STRING2_SMALL_GET32 (src, 4)
236 __STRING_INLINE
void *__mempcpy_small (void *, char, char, char, char,
237 __uint16_t
, __uint16_t
, __uint32_t
,
239 __STRING_INLINE
void *
240 __mempcpy_small (void *__dest1
,
241 char __src0_1
, char __src2_1
, char __src4_1
, char __src6_1
,
242 __uint16_t __src0_2
, __uint16_t __src4_2
,
243 __uint32_t __src0_4
, __uint32_t __src4_4
,
252 switch ((unsigned int) __srclen
)
256 __u
= __extension__ ((void *) __u
+ 1);
259 __u
->__usi
= __src0_2
;
260 __u
= __extension__ ((void *) __u
+ 2);
263 __u
->__usi
= __src0_2
;
264 __u
= __extension__ ((void *) __u
+ 2);
266 __u
= __extension__ ((void *) __u
+ 1);
269 __u
->__ui
= __src0_4
;
270 __u
= __extension__ ((void *) __u
+ 4);
273 __u
->__ui
= __src0_4
;
274 __u
= __extension__ ((void *) __u
+ 4);
276 __u
= __extension__ ((void *) __u
+ 1);
279 __u
->__ui
= __src0_4
;
280 __u
= __extension__ ((void *) __u
+ 4);
281 __u
->__usi
= __src4_2
;
282 __u
= __extension__ ((void *) __u
+ 2);
285 __u
->__ui
= __src0_4
;
286 __u
= __extension__ ((void *) __u
+ 4);
287 __u
->__usi
= __src4_2
;
288 __u
= __extension__ ((void *) __u
+ 2);
290 __u
= __extension__ ((void *) __u
+ 1);
293 __u
->__ui
= __src0_4
;
294 __u
= __extension__ ((void *) __u
+ 4);
295 __u
->__ui
= __src4_4
;
296 __u
= __extension__ ((void *) __u
+ 4);
302 # ifndef _FORCE_INLINES
303 # define __mempcpy_args(src) \
304 ((const char *) (src))[0], \
305 __extension__ ((__STRING2_COPY_ARR2) \
306 { { ((const char *) (src))[0], ((const char *) (src))[1] } }), \
307 __extension__ ((__STRING2_COPY_ARR3) \
308 { { ((const char *) (src))[0], ((const char *) (src))[1], \
309 ((const char *) (src))[2] } }), \
310 __extension__ ((__STRING2_COPY_ARR4) \
311 { { ((const char *) (src))[0], ((const char *) (src))[1], \
312 ((const char *) (src))[2], ((const char *) (src))[3] } }), \
313 __extension__ ((__STRING2_COPY_ARR5) \
314 { { ((const char *) (src))[0], ((const char *) (src))[1], \
315 ((const char *) (src))[2], ((const char *) (src))[3], \
316 ((const char *) (src))[4] } }), \
317 __extension__ ((__STRING2_COPY_ARR6) \
318 { { ((const char *) (src))[0], ((const char *) (src))[1], \
319 ((const char *) (src))[2], ((const char *) (src))[3], \
320 ((const char *) (src))[4], ((const char *) (src))[5] } }), \
321 __extension__ ((__STRING2_COPY_ARR7) \
322 { { ((const char *) (src))[0], ((const char *) (src))[1], \
323 ((const char *) (src))[2], ((const char *) (src))[3], \
324 ((const char *) (src))[4], ((const char *) (src))[5], \
325 ((const char *) (src))[6] } }), \
326 __extension__ ((__STRING2_COPY_ARR8) \
327 { { ((const char *) (src))[0], ((const char *) (src))[1], \
328 ((const char *) (src))[2], ((const char *) (src))[3], \
329 ((const char *) (src))[4], ((const char *) (src))[5], \
330 ((const char *) (src))[6], ((const char *) (src))[7] } })
332 __STRING_INLINE
void *__mempcpy_small (void *, char, __STRING2_COPY_ARR2
,
338 __STRING2_COPY_ARR8
, size_t);
339 __STRING_INLINE
void *
340 __mempcpy_small (void *__dest
, char __src1
,
341 __STRING2_COPY_ARR2 __src2
, __STRING2_COPY_ARR3 __src3
,
342 __STRING2_COPY_ARR4 __src4
, __STRING2_COPY_ARR5 __src5
,
343 __STRING2_COPY_ARR6 __src6
, __STRING2_COPY_ARR7 __src7
,
344 __STRING2_COPY_ARR8 __src8
, size_t __srclen
)
348 __STRING2_COPY_ARR2 __sca2
;
349 __STRING2_COPY_ARR3 __sca3
;
350 __STRING2_COPY_ARR4 __sca4
;
351 __STRING2_COPY_ARR5 __sca5
;
352 __STRING2_COPY_ARR6 __sca6
;
353 __STRING2_COPY_ARR7 __sca7
;
354 __STRING2_COPY_ARR8 __sca8
;
356 switch ((unsigned int) __srclen
)
362 __extension__ __u
->__sca2
= __src2
;
365 __extension__ __u
->__sca3
= __src3
;
368 __extension__ __u
->__sca4
= __src4
;
371 __extension__ __u
->__sca5
= __src5
;
374 __extension__ __u
->__sca6
= __src6
;
377 __extension__ __u
->__sca7
= __src7
;
380 __extension__ __u
->__sca8
= __src8
;
383 return __extension__ ((void *) __u
+ __srclen
);
391 /* Return pointer to C in S. */
392 #ifndef _HAVE_STRING_ARCH_strchr
393 extern void *__rawmemchr (const void *__s
, int __c
);
394 # if __GNUC_PREREQ (3, 2)
395 # define strchr(s, c) \
396 (__extension__ (__builtin_constant_p (c) && !__builtin_constant_p (s) \
398 ? (char *) __rawmemchr (s, c) \
399 : __builtin_strchr (s, c)))
401 # define strchr(s, c) \
402 (__extension__ (__builtin_constant_p (c) && (c) == '\0' \
403 ? (char *) __rawmemchr (s, c) \
409 /* Copy SRC to DEST. */
410 #if (!defined _HAVE_STRING_ARCH_strcpy && !__GNUC_PREREQ (3, 0)) \
411 || defined _FORCE_INLINES
412 # if !defined _HAVE_STRING_ARCH_strcpy && !__GNUC_PREREQ (3, 0)
413 # define strcpy(dest, src) \
414 (__extension__ (__builtin_constant_p (src) \
415 ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \
416 ? __strcpy_small (dest, __strcpy_args (src), \
418 : (char *) memcpy (dest, src, strlen (src) + 1)) \
419 : strcpy (dest, src)))
422 # if _STRING_ARCH_unaligned
423 # ifndef _FORCE_INLINES
424 # define __strcpy_args(src) \
425 __extension__ __STRING2_SMALL_GET16 (src, 0), \
426 __extension__ __STRING2_SMALL_GET16 (src, 4), \
427 __extension__ __STRING2_SMALL_GET32 (src, 0), \
428 __extension__ __STRING2_SMALL_GET32 (src, 4)
430 __STRING_INLINE
char *__strcpy_small (char *, __uint16_t
, __uint16_t
,
431 __uint32_t
, __uint32_t
, size_t);
432 __STRING_INLINE
char *
433 __strcpy_small (char *__dest
,
434 __uint16_t __src0_2
, __uint16_t __src4_2
,
435 __uint32_t __src0_4
, __uint32_t __src4_4
,
442 } *__u
= (void *) __dest
;
443 switch ((unsigned int) __srclen
)
449 __u
->__usi
= __src0_2
;
452 __u
->__usi
= __src0_2
;
453 __u
= __extension__ ((void *) __u
+ 2);
457 __u
->__ui
= __src0_4
;
460 __u
->__ui
= __src0_4
;
461 __u
= __extension__ ((void *) __u
+ 4);
465 __u
->__ui
= __src0_4
;
466 __u
= __extension__ ((void *) __u
+ 4);
467 __u
->__usi
= __src4_2
;
470 __u
->__ui
= __src0_4
;
471 __u
= __extension__ ((void *) __u
+ 4);
472 __u
->__usi
= __src4_2
;
473 __u
= __extension__ ((void *) __u
+ 2);
477 __u
->__ui
= __src0_4
;
478 __u
= __extension__ ((void *) __u
+ 4);
479 __u
->__ui
= __src4_4
;
485 # ifndef _FORCE_INLINES
486 # define __strcpy_args(src) \
487 __extension__ ((__STRING2_COPY_ARR2) \
488 { { ((const char *) (src))[0], '\0' } }), \
489 __extension__ ((__STRING2_COPY_ARR3) \
490 { { ((const char *) (src))[0], ((const char *) (src))[1], \
492 __extension__ ((__STRING2_COPY_ARR4) \
493 { { ((const char *) (src))[0], ((const char *) (src))[1], \
494 ((const char *) (src))[2], '\0' } }), \
495 __extension__ ((__STRING2_COPY_ARR5) \
496 { { ((const char *) (src))[0], ((const char *) (src))[1], \
497 ((const char *) (src))[2], ((const char *) (src))[3], \
499 __extension__ ((__STRING2_COPY_ARR6) \
500 { { ((const char *) (src))[0], ((const char *) (src))[1], \
501 ((const char *) (src))[2], ((const char *) (src))[3], \
502 ((const char *) (src))[4], '\0' } }), \
503 __extension__ ((__STRING2_COPY_ARR7) \
504 { { ((const char *) (src))[0], ((const char *) (src))[1], \
505 ((const char *) (src))[2], ((const char *) (src))[3], \
506 ((const char *) (src))[4], ((const char *) (src))[5], \
508 __extension__ ((__STRING2_COPY_ARR8) \
509 { { ((const char *) (src))[0], ((const char *) (src))[1], \
510 ((const char *) (src))[2], ((const char *) (src))[3], \
511 ((const char *) (src))[4], ((const char *) (src))[5], \
512 ((const char *) (src))[6], '\0' } })
514 __STRING_INLINE
char *__strcpy_small (char *, __STRING2_COPY_ARR2
,
520 __STRING2_COPY_ARR8
, size_t);
521 __STRING_INLINE
char *
522 __strcpy_small (char *__dest
,
523 __STRING2_COPY_ARR2 __src2
, __STRING2_COPY_ARR3 __src3
,
524 __STRING2_COPY_ARR4 __src4
, __STRING2_COPY_ARR5 __src5
,
525 __STRING2_COPY_ARR6 __src6
, __STRING2_COPY_ARR7 __src7
,
526 __STRING2_COPY_ARR8 __src8
, size_t __srclen
)
530 __STRING2_COPY_ARR2 __sca2
;
531 __STRING2_COPY_ARR3 __sca3
;
532 __STRING2_COPY_ARR4 __sca4
;
533 __STRING2_COPY_ARR5 __sca5
;
534 __STRING2_COPY_ARR6 __sca6
;
535 __STRING2_COPY_ARR7 __sca7
;
536 __STRING2_COPY_ARR8 __sca8
;
537 } *__u
= (void *) __dest
;
538 switch ((unsigned int) __srclen
)
544 __extension__ __u
->__sca2
= __src2
;
547 __extension__ __u
->__sca3
= __src3
;
550 __extension__ __u
->__sca4
= __src4
;
553 __extension__ __u
->__sca5
= __src5
;
556 __extension__ __u
->__sca6
= __src6
;
559 __extension__ __u
->__sca7
= __src7
;
562 __extension__ __u
->__sca8
= __src8
;
571 /* Copy SRC to DEST, returning pointer to final NUL byte. */
573 # if !defined _HAVE_STRING_ARCH_stpcpy || defined _FORCE_INLINES
574 # ifndef _HAVE_STRING_ARCH_stpcpy
575 # if __GNUC_PREREQ (3, 4)
576 # define __stpcpy(dest, src) __builtin_stpcpy (dest, src)
577 # elif __GNUC_PREREQ (3, 0)
578 # define __stpcpy(dest, src) \
579 (__extension__ (__builtin_constant_p (src) \
580 ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \
581 ? __builtin_strcpy (dest, src) + strlen (src) \
582 : ((char *) (__mempcpy) (dest, src, strlen (src) + 1) \
584 : __stpcpy (dest, src)))
586 # define __stpcpy(dest, src) \
587 (__extension__ (__builtin_constant_p (src) \
588 ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \
589 ? __stpcpy_small (dest, __stpcpy_args (src), \
591 : ((char *) (__mempcpy) (dest, src, strlen (src) + 1) \
593 : __stpcpy (dest, src)))
595 /* In glibc we use this function frequently but for namespace reasons
596 we have to use the name `__stpcpy'. */
597 # define stpcpy(dest, src) __stpcpy (dest, src)
600 # if !__GNUC_PREREQ (3, 0) || defined _FORCE_INLINES
601 # if _STRING_ARCH_unaligned
602 # ifndef _FORCE_INLINES
603 # define __stpcpy_args(src) \
604 __extension__ __STRING2_SMALL_GET16 (src, 0), \
605 __extension__ __STRING2_SMALL_GET16 (src, 4), \
606 __extension__ __STRING2_SMALL_GET32 (src, 0), \
607 __extension__ __STRING2_SMALL_GET32 (src, 4)
609 __STRING_INLINE
char *__stpcpy_small (char *, __uint16_t
, __uint16_t
,
610 __uint32_t
, __uint32_t
, size_t);
611 __STRING_INLINE
char *
612 __stpcpy_small (char *__dest
,
613 __uint16_t __src0_2
, __uint16_t __src4_2
,
614 __uint32_t __src0_4
, __uint32_t __src4_4
,
619 unsigned short int __usi
;
622 } *__u
= (void *) __dest
;
623 switch ((unsigned int) __srclen
)
629 __u
->__usi
= __src0_2
;
630 __u
= __extension__ ((void *) __u
+ 1);
633 __u
->__usi
= __src0_2
;
634 __u
= __extension__ ((void *) __u
+ 2);
638 __u
->__ui
= __src0_4
;
639 __u
= __extension__ ((void *) __u
+ 3);
642 __u
->__ui
= __src0_4
;
643 __u
= __extension__ ((void *) __u
+ 4);
647 __u
->__ui
= __src0_4
;
648 __u
= __extension__ ((void *) __u
+ 4);
649 __u
->__usi
= __src4_2
;
650 __u
= __extension__ ((void *) __u
+ 1);
653 __u
->__ui
= __src0_4
;
654 __u
= __extension__ ((void *) __u
+ 4);
655 __u
->__usi
= __src4_2
;
656 __u
= __extension__ ((void *) __u
+ 2);
660 __u
->__ui
= __src0_4
;
661 __u
= __extension__ ((void *) __u
+ 4);
662 __u
->__ui
= __src4_4
;
663 __u
= __extension__ ((void *) __u
+ 3);
669 # ifndef _FORCE_INLINES
670 # define __stpcpy_args(src) \
671 __extension__ ((__STRING2_COPY_ARR2) \
672 { { ((const char *) (src))[0], '\0' } }), \
673 __extension__ ((__STRING2_COPY_ARR3) \
674 { { ((const char *) (src))[0], ((const char *) (src))[1], \
676 __extension__ ((__STRING2_COPY_ARR4) \
677 { { ((const char *) (src))[0], ((const char *) (src))[1], \
678 ((const char *) (src))[2], '\0' } }), \
679 __extension__ ((__STRING2_COPY_ARR5) \
680 { { ((const char *) (src))[0], ((const char *) (src))[1], \
681 ((const char *) (src))[2], ((const char *) (src))[3], \
683 __extension__ ((__STRING2_COPY_ARR6) \
684 { { ((const char *) (src))[0], ((const char *) (src))[1], \
685 ((const char *) (src))[2], ((const char *) (src))[3], \
686 ((const char *) (src))[4], '\0' } }), \
687 __extension__ ((__STRING2_COPY_ARR7) \
688 { { ((const char *) (src))[0], ((const char *) (src))[1], \
689 ((const char *) (src))[2], ((const char *) (src))[3], \
690 ((const char *) (src))[4], ((const char *) (src))[5], \
692 __extension__ ((__STRING2_COPY_ARR8) \
693 { { ((const char *) (src))[0], ((const char *) (src))[1], \
694 ((const char *) (src))[2], ((const char *) (src))[3], \
695 ((const char *) (src))[4], ((const char *) (src))[5], \
696 ((const char *) (src))[6], '\0' } })
698 __STRING_INLINE
char *__stpcpy_small (char *, __STRING2_COPY_ARR2
,
704 __STRING2_COPY_ARR8
, size_t);
705 __STRING_INLINE
char *
706 __stpcpy_small (char *__dest
,
707 __STRING2_COPY_ARR2 __src2
, __STRING2_COPY_ARR3 __src3
,
708 __STRING2_COPY_ARR4 __src4
, __STRING2_COPY_ARR5 __src5
,
709 __STRING2_COPY_ARR6 __src6
, __STRING2_COPY_ARR7 __src7
,
710 __STRING2_COPY_ARR8 __src8
, size_t __srclen
)
714 __STRING2_COPY_ARR2 __sca2
;
715 __STRING2_COPY_ARR3 __sca3
;
716 __STRING2_COPY_ARR4 __sca4
;
717 __STRING2_COPY_ARR5 __sca5
;
718 __STRING2_COPY_ARR6 __sca6
;
719 __STRING2_COPY_ARR7 __sca7
;
720 __STRING2_COPY_ARR8 __sca8
;
721 } *__u
= (void *) __dest
;
722 switch ((unsigned int) __srclen
)
728 __extension__ __u
->__sca2
= __src2
;
731 __extension__ __u
->__sca3
= __src3
;
734 __extension__ __u
->__sca4
= __src4
;
737 __extension__ __u
->__sca5
= __src5
;
740 __extension__ __u
->__sca6
= __src6
;
743 __extension__ __u
->__sca7
= __src7
;
746 __extension__ __u
->__sca8
= __src8
;
749 return __dest
+ __srclen
- 1;
757 /* Copy no more than N characters of SRC to DEST. */
758 #ifndef _HAVE_STRING_ARCH_strncpy
759 # if __GNUC_PREREQ (3, 2)
760 # define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
762 # define strncpy(dest, src, n) \
763 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
764 ? (strlen (src) + 1 >= ((size_t) (n)) \
765 ? (char *) memcpy (dest, src, n) \
766 : strncpy (dest, src, n)) \
767 : strncpy (dest, src, n)))
772 /* Append no more than N characters from SRC onto DEST. */
773 #ifndef _HAVE_STRING_ARCH_strncat
774 # ifdef _USE_STRING_ARCH_strchr
775 # define strncat(dest, src, n) \
776 (__extension__ ({ char *__dest = (dest); \
777 __builtin_constant_p (src) && __builtin_constant_p (n) \
778 ? (strlen (src) < ((size_t) (n)) \
779 ? strcat (__dest, src) \
780 : (*((char *) __mempcpy (strchr (__dest, '\0'), \
781 src, n)) = '\0', __dest)) \
782 : strncat (dest, src, n); }))
783 # elif __GNUC_PREREQ (3, 2)
784 # define strncat(dest, src, n) __builtin_strncat (dest, src, n)
786 # define strncat(dest, src, n) \
787 (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
788 ? (strlen (src) < ((size_t) (n)) \
789 ? strcat (dest, src) \
790 : strncat (dest, src, n)) \
791 : strncat (dest, src, n)))
796 /* Compare characters of S1 and S2. */
797 #ifndef _HAVE_STRING_ARCH_strcmp
798 # if __GNUC_PREREQ (3, 2)
799 # define strcmp(s1, s2) \
801 ({ size_t __s1_len, __s2_len; \
802 (__builtin_constant_p (s1) && __builtin_constant_p (s2) \
803 && (__s1_len = strlen (s1), __s2_len = strlen (s2), \
804 (!__string2_1bptr_p (s1) || __s1_len >= 4) \
805 && (!__string2_1bptr_p (s2) || __s2_len >= 4)) \
806 ? __builtin_strcmp (s1, s2) \
807 : (__builtin_constant_p (s1) && __string2_1bptr_p (s1) \
808 && (__s1_len = strlen (s1), __s1_len < 4) \
809 ? (__builtin_constant_p (s2) && __string2_1bptr_p (s2) \
810 ? __builtin_strcmp (s1, s2) \
811 : __strcmp_cg (s1, s2, __s1_len)) \
812 : (__builtin_constant_p (s2) && __string2_1bptr_p (s2) \
813 && (__s2_len = strlen (s2), __s2_len < 4) \
814 ? (__builtin_constant_p (s1) && __string2_1bptr_p (s1) \
815 ? __builtin_strcmp (s1, s2) \
816 : __strcmp_gc (s1, s2, __s2_len)) \
817 : __builtin_strcmp (s1, s2)))); })
819 # define strcmp(s1, s2) \
821 ({ size_t __s1_len, __s2_len; \
822 (__builtin_constant_p (s1) && __builtin_constant_p (s2) \
823 && (__s1_len = strlen (s1), __s2_len = strlen (s2), \
824 (!__string2_1bptr_p (s1) || __s1_len >= 4) \
825 && (!__string2_1bptr_p (s2) || __s2_len >= 4)) \
826 ? memcmp ((const char *) (s1), (const char *) (s2), \
827 (__s1_len < __s2_len ? __s1_len : __s2_len) + 1) \
828 : (__builtin_constant_p (s1) && __string2_1bptr_p (s1) \
829 && (__s1_len = strlen (s1), __s1_len < 4) \
830 ? (__builtin_constant_p (s2) && __string2_1bptr_p (s2) \
831 ? __strcmp_cc (s1, s2, __s1_len) \
832 : __strcmp_cg (s1, s2, __s1_len)) \
833 : (__builtin_constant_p (s2) && __string2_1bptr_p (s2) \
834 && (__s2_len = strlen (s2), __s2_len < 4) \
835 ? (__builtin_constant_p (s1) && __string2_1bptr_p (s1) \
836 ? __strcmp_cc (s1, s2, __s2_len) \
837 : __strcmp_gc (s1, s2, __s2_len)) \
838 : strcmp (s1, s2)))); })
841 # define __strcmp_cc(s1, s2, l) \
842 (__extension__ ({ register int __result = \
843 (((const unsigned char *) (const char *) (s1))[0] \
844 - ((const unsigned char *) (const char *)(s2))[0]); \
845 if (l > 0 && __result == 0) \
847 __result = (((const unsigned char *) \
848 (const char *) (s1))[1] \
849 - ((const unsigned char *) \
850 (const char *) (s2))[1]); \
851 if (l > 1 && __result == 0) \
854 (((const unsigned char *) \
855 (const char *) (s1))[2] \
856 - ((const unsigned char *) \
857 (const char *) (s2))[2]); \
858 if (l > 2 && __result == 0) \
860 (((const unsigned char *) \
861 (const char *) (s1))[3] \
862 - ((const unsigned char *) \
863 (const char *) (s2))[3]); \
868 # define __strcmp_cg(s1, s2, l1) \
869 (__extension__ ({ const unsigned char *__s2 = \
870 (const unsigned char *) (const char *) (s2); \
871 register int __result = \
872 (((const unsigned char *) (const char *) (s1))[0] \
874 if (l1 > 0 && __result == 0) \
876 __result = (((const unsigned char *) \
877 (const char *) (s1))[1] - __s2[1]); \
878 if (l1 > 1 && __result == 0) \
880 __result = (((const unsigned char *) \
881 (const char *) (s1))[2] - __s2[2]); \
882 if (l1 > 2 && __result == 0) \
883 __result = (((const unsigned char *) \
884 (const char *) (s1))[3] \
890 # define __strcmp_gc(s1, s2, l2) \
891 (__extension__ ({ const unsigned char *__s1 = \
892 (const unsigned char *) (const char *) (s1); \
893 register int __result = \
894 __s1[0] - ((const unsigned char *) \
895 (const char *) (s2))[0]; \
896 if (l2 > 0 && __result == 0) \
898 __result = (__s1[1] \
899 - ((const unsigned char *) \
900 (const char *) (s2))[1]); \
901 if (l2 > 1 && __result == 0) \
904 (__s1[2] - ((const unsigned char *) \
905 (const char *) (s2))[2]); \
906 if (l2 > 2 && __result == 0) \
909 - ((const unsigned char *) \
910 (const char *) (s2))[3]); \
917 /* Compare N characters of S1 and S2. */
918 #ifndef _HAVE_STRING_ARCH_strncmp
919 # define strncmp(s1, s2, n) \
920 (__extension__ (__builtin_constant_p (n) \
921 && ((__builtin_constant_p (s1) \
922 && strlen (s1) < ((size_t) (n))) \
923 || (__builtin_constant_p (s2) \
924 && strlen (s2) < ((size_t) (n)))) \
925 ? strcmp (s1, s2) : strncmp (s1, s2, n)))
929 /* Return the length of the initial segment of S which
930 consists entirely of characters not in REJECT. */
931 #if !defined _HAVE_STRING_ARCH_strcspn || defined _FORCE_INLINES
932 # ifndef _HAVE_STRING_ARCH_strcspn
933 # if __GNUC_PREREQ (3, 2)
934 # define strcspn(s, reject) \
936 ({ char __r0, __r1, __r2; \
937 (__builtin_constant_p (reject) && __string2_1bptr_p (reject) \
938 ? ((__builtin_constant_p (s) && __string2_1bptr_p (s)) \
939 ? __builtin_strcspn (s, reject) \
940 : ((__r0 = ((const char *) (reject))[0], __r0 == '\0') \
942 : ((__r1 = ((const char *) (reject))[1], __r1 == '\0') \
943 ? __strcspn_c1 (s, __r0) \
944 : ((__r2 = ((const char *) (reject))[2], __r2 == '\0') \
945 ? __strcspn_c2 (s, __r0, __r1) \
946 : (((const char *) (reject))[3] == '\0' \
947 ? __strcspn_c3 (s, __r0, __r1, __r2) \
948 : __builtin_strcspn (s, reject)))))) \
949 : __builtin_strcspn (s, reject)); })
951 # define strcspn(s, reject) \
953 ({ char __r0, __r1, __r2; \
954 (__builtin_constant_p (reject) && __string2_1bptr_p (reject) \
955 ? ((__r0 = ((const char *) (reject))[0], __r0 == '\0') \
957 : ((__r1 = ((const char *) (reject))[1], __r1 == '\0') \
958 ? __strcspn_c1 (s, __r0) \
959 : ((__r2 = ((const char *) (reject))[2], __r2 == '\0') \
960 ? __strcspn_c2 (s, __r0, __r1) \
961 : (((const char *) (reject))[3] == '\0' \
962 ? __strcspn_c3 (s, __r0, __r1, __r2) \
963 : strcspn (s, reject))))) \
964 : strcspn (s, reject)); })
968 __STRING_INLINE
size_t __strcspn_c1 (const char *__s
, int __reject
);
969 __STRING_INLINE
size_t
970 __strcspn_c1 (const char *__s
, int __reject
)
972 register size_t __result
= 0;
973 while (__s
[__result
] != '\0' && __s
[__result
] != __reject
)
978 __STRING_INLINE
size_t __strcspn_c2 (const char *__s
, int __reject1
,
980 __STRING_INLINE
size_t
981 __strcspn_c2 (const char *__s
, int __reject1
, int __reject2
)
983 register size_t __result
= 0;
984 while (__s
[__result
] != '\0' && __s
[__result
] != __reject1
985 && __s
[__result
] != __reject2
)
990 __STRING_INLINE
size_t __strcspn_c3 (const char *__s
, int __reject1
,
991 int __reject2
, int __reject3
);
992 __STRING_INLINE
size_t
993 __strcspn_c3 (const char *__s
, int __reject1
, int __reject2
,
996 register size_t __result
= 0;
997 while (__s
[__result
] != '\0' && __s
[__result
] != __reject1
998 && __s
[__result
] != __reject2
&& __s
[__result
] != __reject3
)
1005 /* Return the length of the initial segment of S which
1006 consists entirely of characters in ACCEPT. */
1007 #if !defined _HAVE_STRING_ARCH_strspn || defined _FORCE_INLINES
1008 # ifndef _HAVE_STRING_ARCH_strspn
1009 # if __GNUC_PREREQ (3, 2)
1010 # define strspn(s, accept) \
1012 ({ char __a0, __a1, __a2; \
1013 (__builtin_constant_p (accept) && __string2_1bptr_p (accept) \
1014 ? ((__builtin_constant_p (s) && __string2_1bptr_p (s)) \
1015 ? __builtin_strspn (s, accept) \
1016 : ((__a0 = ((const char *) (accept))[0], __a0 == '\0') \
1017 ? ((void) (s), (size_t) 0) \
1018 : ((__a1 = ((const char *) (accept))[1], __a1 == '\0') \
1019 ? __strspn_c1 (s, __a0) \
1020 : ((__a2 = ((const char *) (accept))[2], __a2 == '\0') \
1021 ? __strspn_c2 (s, __a0, __a1) \
1022 : (((const char *) (accept))[3] == '\0' \
1023 ? __strspn_c3 (s, __a0, __a1, __a2) \
1024 : __builtin_strspn (s, accept)))))) \
1025 : __builtin_strspn (s, accept)); })
1027 # define strspn(s, accept) \
1029 ({ char __a0, __a1, __a2; \
1030 (__builtin_constant_p (accept) && __string2_1bptr_p (accept) \
1031 ? ((__a0 = ((const char *) (accept))[0], __a0 == '\0') \
1032 ? ((void) (s), (size_t) 0) \
1033 : ((__a1 = ((const char *) (accept))[1], __a1 == '\0') \
1034 ? __strspn_c1 (s, __a0) \
1035 : ((__a2 = ((const char *) (accept))[2], __a2 == '\0') \
1036 ? __strspn_c2 (s, __a0, __a1) \
1037 : (((const char *) (accept))[3] == '\0' \
1038 ? __strspn_c3 (s, __a0, __a1, __a2) \
1039 : strspn (s, accept))))) \
1040 : strspn (s, accept)); })
1044 __STRING_INLINE
size_t __strspn_c1 (const char *__s
, int __accept
);
1045 __STRING_INLINE
size_t
1046 __strspn_c1 (const char *__s
, int __accept
)
1048 register size_t __result
= 0;
1049 /* Please note that __accept never can be '\0'. */
1050 while (__s
[__result
] == __accept
)
1055 __STRING_INLINE
size_t __strspn_c2 (const char *__s
, int __accept1
,
1057 __STRING_INLINE
size_t
1058 __strspn_c2 (const char *__s
, int __accept1
, int __accept2
)
1060 register size_t __result
= 0;
1061 /* Please note that __accept1 and __accept2 never can be '\0'. */
1062 while (__s
[__result
] == __accept1
|| __s
[__result
] == __accept2
)
1067 __STRING_INLINE
size_t __strspn_c3 (const char *__s
, int __accept1
,
1068 int __accept2
, int __accept3
);
1069 __STRING_INLINE
size_t
1070 __strspn_c3 (const char *__s
, int __accept1
, int __accept2
, int __accept3
)
1072 register size_t __result
= 0;
1073 /* Please note that __accept1 to __accept3 never can be '\0'. */
1074 while (__s
[__result
] == __accept1
|| __s
[__result
] == __accept2
1075 || __s
[__result
] == __accept3
)
1082 /* Find the first occurrence in S of any character in ACCEPT. */
1083 #if !defined _HAVE_STRING_ARCH_strpbrk || defined _FORCE_INLINES
1084 # ifndef _HAVE_STRING_ARCH_strpbrk
1085 # if __GNUC_PREREQ (3, 2)
1086 # define strpbrk(s, accept) \
1088 ({ char __a0, __a1, __a2; \
1089 (__builtin_constant_p (accept) && __string2_1bptr_p (accept) \
1090 ? ((__builtin_constant_p (s) && __string2_1bptr_p (s)) \
1091 ? __builtin_strpbrk (s, accept) \
1092 : ((__a0 = ((const char *) (accept))[0], __a0 == '\0') \
1093 ? ((void) (s), (char *) NULL) \
1094 : ((__a1 = ((const char *) (accept))[1], __a1 == '\0') \
1095 ? __builtin_strchr (s, __a0) \
1096 : ((__a2 = ((const char *) (accept))[2], __a2 == '\0') \
1097 ? __strpbrk_c2 (s, __a0, __a1) \
1098 : (((const char *) (accept))[3] == '\0' \
1099 ? __strpbrk_c3 (s, __a0, __a1, __a2) \
1100 : __builtin_strpbrk (s, accept)))))) \
1101 : __builtin_strpbrk (s, accept)); })
1103 # define strpbrk(s, accept) \
1105 ({ char __a0, __a1, __a2; \
1106 (__builtin_constant_p (accept) && __string2_1bptr_p (accept) \
1107 ? ((__a0 = ((const char *) (accept))[0], __a0 == '\0') \
1108 ? ((void) (s), (char *) NULL) \
1109 : ((__a1 = ((const char *) (accept))[1], __a1 == '\0') \
1110 ? strchr (s, __a0) \
1111 : ((__a2 = ((const char *) (accept))[2], __a2 == '\0') \
1112 ? __strpbrk_c2 (s, __a0, __a1) \
1113 : (((const char *) (accept))[3] == '\0' \
1114 ? __strpbrk_c3 (s, __a0, __a1, __a2) \
1115 : strpbrk (s, accept))))) \
1116 : strpbrk (s, accept)); })
1120 __STRING_INLINE
char *__strpbrk_c2 (const char *__s
, int __accept1
,
1122 __STRING_INLINE
char *
1123 __strpbrk_c2 (const char *__s
, int __accept1
, int __accept2
)
1125 /* Please note that __accept1 and __accept2 never can be '\0'. */
1126 while (*__s
!= '\0' && *__s
!= __accept1
&& *__s
!= __accept2
)
1128 return *__s
== '\0' ? NULL
: (char *) (size_t) __s
;
1131 __STRING_INLINE
char *__strpbrk_c3 (const char *__s
, int __accept1
,
1132 int __accept2
, int __accept3
);
1133 __STRING_INLINE
char *
1134 __strpbrk_c3 (const char *__s
, int __accept1
, int __accept2
, int __accept3
)
1136 /* Please note that __accept1 to __accept3 never can be '\0'. */
1137 while (*__s
!= '\0' && *__s
!= __accept1
&& *__s
!= __accept2
1138 && *__s
!= __accept3
)
1140 return *__s
== '\0' ? NULL
: (char *) (size_t) __s
;
1145 /* Find the first occurrence of NEEDLE in HAYSTACK. Newer gcc versions
1147 #if !defined _HAVE_STRING_ARCH_strstr && !__GNUC_PREREQ (2, 97)
1148 # define strstr(haystack, needle) \
1149 (__extension__ (__builtin_constant_p (needle) && __string2_1bptr_p (needle) \
1150 ? (((const char *) (needle))[0] == '\0' \
1151 ? (char *) (size_t) (haystack) \
1152 : (((const char *) (needle))[1] == '\0' \
1153 ? strchr (haystack, \
1154 ((const char *) (needle))[0]) \
1155 : strstr (haystack, needle))) \
1156 : strstr (haystack, needle)))
1160 #if !defined _HAVE_STRING_ARCH_strtok_r || defined _FORCE_INLINES
1161 # ifndef _HAVE_STRING_ARCH_strtok_r
1162 # define __strtok_r(s, sep, nextp) \
1163 (__extension__ (__builtin_constant_p (sep) && __string2_1bptr_p (sep) \
1164 && ((const char *) (sep))[0] != '\0' \
1165 && ((const char *) (sep))[1] == '\0' \
1166 ? __strtok_r_1c (s, ((const char *) (sep))[0], nextp) \
1167 : __strtok_r (s, sep, nextp)))
1170 __STRING_INLINE
char *__strtok_r_1c (char *__s
, char __sep
, char **__nextp
);
1171 __STRING_INLINE
char *
1172 __strtok_r_1c (char *__s
, char __sep
, char **__nextp
)
1177 while (*__s
== __sep
)
1183 while (*__s
!= '\0')
1184 if (*__s
++ == __sep
)
1193 # if defined __USE_POSIX || defined __USE_MISC
1194 # define strtok_r(s, sep, nextp) __strtok_r (s, sep, nextp)
1199 #if !defined _HAVE_STRING_ARCH_strsep || defined _FORCE_INLINES
1200 # ifndef _HAVE_STRING_ARCH_strsep
1202 extern char *__strsep_g (char **__stringp
, const char *__delim
);
1203 # define __strsep(s, reject) \
1205 ({ char __r0, __r1, __r2; \
1206 (__builtin_constant_p (reject) && __string2_1bptr_p (reject) \
1207 && (__r0 = ((const char *) (reject))[0], \
1208 ((const char *) (reject))[0] != '\0') \
1209 ? ((__r1 = ((const char *) (reject))[1], \
1210 ((const char *) (reject))[1] == '\0') \
1211 ? __strsep_1c (s, __r0) \
1212 : ((__r2 = ((const char *) (reject))[2], __r2 == '\0') \
1213 ? __strsep_2c (s, __r0, __r1) \
1214 : (((const char *) (reject))[3] == '\0' \
1215 ? __strsep_3c (s, __r0, __r1, __r2) \
1216 : __strsep_g (s, reject)))) \
1217 : __strsep_g (s, reject)); })
1220 __STRING_INLINE
char *__strsep_1c (char **__s
, char __reject
);
1221 __STRING_INLINE
char *
1222 __strsep_1c (char **__s
, char __reject
)
1224 register char *__retval
= *__s
;
1225 if (__retval
!= NULL
&& (*__s
= strchr (__retval
, __reject
)) != NULL
)
1230 __STRING_INLINE
char *__strsep_2c (char **__s
, char __reject1
, char __reject2
);
1231 __STRING_INLINE
char *
1232 __strsep_2c (char **__s
, char __reject1
, char __reject2
)
1234 register char *__retval
= *__s
;
1235 if (__retval
!= NULL
)
1237 register char *__cp
= __retval
;
1245 if (*__cp
== __reject1
|| *__cp
== __reject2
)
1257 __STRING_INLINE
char *__strsep_3c (char **__s
, char __reject1
, char __reject2
,
1259 __STRING_INLINE
char *
1260 __strsep_3c (char **__s
, char __reject1
, char __reject2
, char __reject3
)
1262 register char *__retval
= *__s
;
1263 if (__retval
!= NULL
)
1265 register char *__cp
= __retval
;
1273 if (*__cp
== __reject1
|| *__cp
== __reject2
|| *__cp
== __reject3
)
1285 # define strsep(s, reject) __strsep (s, reject)
1289 /* We need the memory allocation functions for inline strdup().
1290 Referring to stdlib.h (even minimally) is not allowed
1291 in any of the tight standards compliant modes. */
1294 # if !defined _HAVE_STRING_ARCH_strdup || !defined _HAVE_STRING_ARCH_strndup
1295 # define __need_malloc_and_calloc
1296 # include <stdlib.h>
1299 # ifndef _HAVE_STRING_ARCH_strdup
1301 extern char *__strdup (const char *__string
) __THROW __attribute_malloc__
;
1302 # define __strdup(s) \
1303 (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s) \
1304 ? (((const char *) (s))[0] == '\0' \
1305 ? (char *) calloc ((size_t) 1, (size_t) 1) \
1306 : ({ size_t __len = strlen (s) + 1; \
1307 char *__retval = (char *) malloc (__len); \
1308 if (__retval != NULL) \
1309 __retval = (char *) memcpy (__retval, s, __len); \
1313 # if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
1314 # define strdup(s) __strdup (s)
1318 # ifndef _HAVE_STRING_ARCH_strndup
1320 extern char *__strndup (const char *__string
, size_t __n
)
1321 __THROW __attribute_malloc__
;
1322 # define __strndup(s, n) \
1323 (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s) \
1324 ? (((const char *) (s))[0] == '\0' \
1325 ? (char *) calloc ((size_t) 1, (size_t) 1) \
1326 : ({ size_t __len = strlen (s) + 1; \
1331 __retval = (char *) malloc (__len); \
1332 if (__retval != NULL) \
1334 __retval[__len - 1] = '\0'; \
1335 __retval = (char *) memcpy (__retval, s, \
1339 : __strndup (s, n)))
1342 # define strndup(s, n) __strndup (s, n)
1346 #endif /* Use misc. or use GNU. */
1348 #ifndef _FORCE_INLINES
1349 # undef __STRING_INLINE
1352 #endif /* No string inlines. */