mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-09 23:00:07 +00:00
(__mempcpy): For gcc 3.0+, don't use
__mempcpy_small but instead use __builtin_memcpy ( , , n) + n for short lengths and constant src. (strcpy): Don't optimize for gcc 3.0+. (__stpcpy): For gcc 3.0+, don't use __stpcpy_small but instead use __builtin_strcpy (, src) + strlen (src) for short string literal src.
This commit is contained in:
parent
58db8a88b0
commit
96f3aa5253
@ -1,5 +1,5 @@
|
|||||||
/* Machine-independant string function optimizations.
|
/* Machine-independant string function optimizations.
|
||||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
Copyright (C) 1997,1998,1999,2000,2001,2002 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
||||||
|
|
||||||
@ -198,26 +198,35 @@ __STRING2_COPY_TYPE (8);
|
|||||||
#ifdef __USE_GNU
|
#ifdef __USE_GNU
|
||||||
# if !defined _HAVE_STRING_ARCH_mempcpy || defined _FORCE_INLINES
|
# if !defined _HAVE_STRING_ARCH_mempcpy || defined _FORCE_INLINES
|
||||||
# ifndef _HAVE_STRING_ARCH_mempcpy
|
# ifndef _HAVE_STRING_ARCH_mempcpy
|
||||||
# define __mempcpy(dest, src, n) \
|
# if __GNUC_PREREQ (3, 0)
|
||||||
|
# define __mempcpy(dest, src, n) \
|
||||||
|
(__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
|
||||||
|
&& __string2_1bptr_p (src) && n <= 8 \
|
||||||
|
? __builtin_memcpy (dest, src, n) + n \
|
||||||
|
: __mempcpy (dest, src, n)))
|
||||||
|
# else
|
||||||
|
# define __mempcpy(dest, src, n) \
|
||||||
(__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
|
(__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
|
||||||
&& __string2_1bptr_p (src) && n <= 8 \
|
&& __string2_1bptr_p (src) && n <= 8 \
|
||||||
? __mempcpy_small (dest, __mempcpy_args (src), n) \
|
? __mempcpy_small (dest, __mempcpy_args (src), n) \
|
||||||
: __mempcpy (dest, src, n)))
|
: __mempcpy (dest, src, n)))
|
||||||
|
# endif
|
||||||
/* In glibc we use this function frequently but for namespace reasons
|
/* In glibc we use this function frequently but for namespace reasons
|
||||||
we have to use the name `__mempcpy'. */
|
we have to use the name `__mempcpy'. */
|
||||||
# define mempcpy(dest, src, n) __mempcpy (dest, src, n)
|
# define mempcpy(dest, src, n) __mempcpy (dest, src, n)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if _STRING_ARCH_unaligned
|
# if !__GNUC_PREREQ (3, 0) || defined _FORCE_INLINES
|
||||||
# ifndef _FORCE_INLINES
|
# if _STRING_ARCH_unaligned
|
||||||
# define __mempcpy_args(src) \
|
# ifndef _FORCE_INLINES
|
||||||
|
# define __mempcpy_args(src) \
|
||||||
((__const char *) (src))[0], ((__const char *) (src))[2], \
|
((__const char *) (src))[0], ((__const char *) (src))[2], \
|
||||||
((__const char *) (src))[4], ((__const char *) (src))[6], \
|
((__const char *) (src))[4], ((__const char *) (src))[6], \
|
||||||
__extension__ __STRING2_SMALL_GET16 (src, 0), \
|
__extension__ __STRING2_SMALL_GET16 (src, 0), \
|
||||||
__extension__ __STRING2_SMALL_GET16 (src, 4), \
|
__extension__ __STRING2_SMALL_GET16 (src, 4), \
|
||||||
__extension__ __STRING2_SMALL_GET32 (src, 0), \
|
__extension__ __STRING2_SMALL_GET32 (src, 0), \
|
||||||
__extension__ __STRING2_SMALL_GET32 (src, 4)
|
__extension__ __STRING2_SMALL_GET32 (src, 4)
|
||||||
# endif
|
# endif
|
||||||
__STRING_INLINE void *__mempcpy_small (void *, char, char, char, char,
|
__STRING_INLINE void *__mempcpy_small (void *, char, char, char, char,
|
||||||
__uint16_t, __uint16_t, __uint32_t,
|
__uint16_t, __uint16_t, __uint32_t,
|
||||||
__uint32_t, size_t);
|
__uint32_t, size_t);
|
||||||
@ -283,9 +292,9 @@ __mempcpy_small (void *__dest1,
|
|||||||
}
|
}
|
||||||
return (void *) __u;
|
return (void *) __u;
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
# ifndef _FORCE_INLINES
|
# ifndef _FORCE_INLINES
|
||||||
# define __mempcpy_args(src) \
|
# define __mempcpy_args(src) \
|
||||||
((__const char *) (src))[0], \
|
((__const char *) (src))[0], \
|
||||||
__extension__ ((__STRING2_COPY_ARR2) \
|
__extension__ ((__STRING2_COPY_ARR2) \
|
||||||
{ { ((__const char *) (src))[0], ((__const char *) (src))[1] } }), \
|
{ { ((__const char *) (src))[0], ((__const char *) (src))[1] } }), \
|
||||||
@ -313,7 +322,7 @@ __mempcpy_small (void *__dest1,
|
|||||||
((__const char *) (src))[2], ((__const char *) (src))[3], \
|
((__const char *) (src))[2], ((__const char *) (src))[3], \
|
||||||
((__const char *) (src))[4], ((__const char *) (src))[5], \
|
((__const char *) (src))[4], ((__const char *) (src))[5], \
|
||||||
((__const char *) (src))[6], ((__const char *) (src))[7] } })
|
((__const char *) (src))[6], ((__const char *) (src))[7] } })
|
||||||
# endif
|
# endif
|
||||||
__STRING_INLINE void *__mempcpy_small (void *, char, __STRING2_COPY_ARR2,
|
__STRING_INLINE void *__mempcpy_small (void *, char, __STRING2_COPY_ARR2,
|
||||||
__STRING2_COPY_ARR3,
|
__STRING2_COPY_ARR3,
|
||||||
__STRING2_COPY_ARR4,
|
__STRING2_COPY_ARR4,
|
||||||
@ -367,6 +376,7 @@ __mempcpy_small (void *__dest, char __src1,
|
|||||||
}
|
}
|
||||||
return __extension__ ((void *) __u + __srclen);
|
return __extension__ ((void *) __u + __srclen);
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@ -383,8 +393,9 @@ extern void *__rawmemchr (const void *__s, int __c);
|
|||||||
|
|
||||||
|
|
||||||
/* Copy SRC to DEST. */
|
/* Copy SRC to DEST. */
|
||||||
#if !defined _HAVE_STRING_ARCH_strcpy || defined _FORCE_INLINES
|
#if (!defined _HAVE_STRING_ARCH_strcpy && !__GNUC_PREREQ (3, 0)) \
|
||||||
# ifndef _HAVE_STRING_ARCH_strcpy
|
|| defined _FORCE_INLINES
|
||||||
|
# if !defined _HAVE_STRING_ARCH_strcpy && !__GNUC_PREREQ (3, 0)
|
||||||
# define strcpy(dest, src) \
|
# define strcpy(dest, src) \
|
||||||
(__extension__ (__builtin_constant_p (src) \
|
(__extension__ (__builtin_constant_p (src) \
|
||||||
? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \
|
? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \
|
||||||
@ -547,26 +558,38 @@ __strcpy_small (char *__dest,
|
|||||||
#ifdef __USE_GNU
|
#ifdef __USE_GNU
|
||||||
# if !defined _HAVE_STRING_ARCH_stpcpy || defined _FORCE_INLINES
|
# if !defined _HAVE_STRING_ARCH_stpcpy || defined _FORCE_INLINES
|
||||||
# ifndef _HAVE_STRING_ARCH_stpcpy
|
# ifndef _HAVE_STRING_ARCH_stpcpy
|
||||||
# define __stpcpy(dest, src) \
|
# if __GNUC_PREREQ (3, 0)
|
||||||
|
# define __stpcpy(dest, src) \
|
||||||
|
(__extension__ (__builtin_constant_p (src) \
|
||||||
|
? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \
|
||||||
|
? __builtin_strcpy (dest, src) + strlen (src) \
|
||||||
|
: ((char *) (__mempcpy) (dest, src, strlen (src) + 1) \
|
||||||
|
- 1)) \
|
||||||
|
: __stpcpy (dest, src)))
|
||||||
|
# else
|
||||||
|
# define __stpcpy(dest, src) \
|
||||||
(__extension__ (__builtin_constant_p (src) \
|
(__extension__ (__builtin_constant_p (src) \
|
||||||
? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \
|
? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \
|
||||||
? __stpcpy_small (dest, __stpcpy_args (src), \
|
? __stpcpy_small (dest, __stpcpy_args (src), \
|
||||||
strlen (src) + 1) \
|
strlen (src) + 1) \
|
||||||
: ((char *) __mempcpy (dest, src, strlen (src) + 1) - 1))\
|
: ((char *) (__mempcpy) (dest, src, strlen (src) + 1) \
|
||||||
|
- 1)) \
|
||||||
: __stpcpy (dest, src)))
|
: __stpcpy (dest, src)))
|
||||||
|
# endif
|
||||||
/* In glibc we use this function frequently but for namespace reasons
|
/* In glibc we use this function frequently but for namespace reasons
|
||||||
we have to use the name `__stpcpy'. */
|
we have to use the name `__stpcpy'. */
|
||||||
# define stpcpy(dest, src) __stpcpy (dest, src)
|
# define stpcpy(dest, src) __stpcpy (dest, src)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if _STRING_ARCH_unaligned
|
# if !__GNUC_PREREQ (3, 0) || _FORCE_INLINES
|
||||||
# ifndef _FORCE_INLINES
|
# if _STRING_ARCH_unaligned
|
||||||
# define __stpcpy_args(src) \
|
# ifndef _FORCE_INLINES
|
||||||
|
# define __stpcpy_args(src) \
|
||||||
__extension__ __STRING2_SMALL_GET16 (src, 0), \
|
__extension__ __STRING2_SMALL_GET16 (src, 0), \
|
||||||
__extension__ __STRING2_SMALL_GET16 (src, 4), \
|
__extension__ __STRING2_SMALL_GET16 (src, 4), \
|
||||||
__extension__ __STRING2_SMALL_GET32 (src, 0), \
|
__extension__ __STRING2_SMALL_GET32 (src, 0), \
|
||||||
__extension__ __STRING2_SMALL_GET32 (src, 4)
|
__extension__ __STRING2_SMALL_GET32 (src, 4)
|
||||||
# endif
|
# endif
|
||||||
__STRING_INLINE char *__stpcpy_small (char *, __uint16_t, __uint16_t,
|
__STRING_INLINE char *__stpcpy_small (char *, __uint16_t, __uint16_t,
|
||||||
__uint32_t, __uint32_t, size_t);
|
__uint32_t, __uint32_t, size_t);
|
||||||
__STRING_INLINE char *
|
__STRING_INLINE char *
|
||||||
@ -626,9 +649,9 @@ __stpcpy_small (char *__dest,
|
|||||||
}
|
}
|
||||||
return &__u->__c;
|
return &__u->__c;
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
# ifndef _FORCE_INLINES
|
# ifndef _FORCE_INLINES
|
||||||
# define __stpcpy_args(src) \
|
# define __stpcpy_args(src) \
|
||||||
__extension__ ((__STRING2_COPY_ARR2) \
|
__extension__ ((__STRING2_COPY_ARR2) \
|
||||||
{ { ((__const char *) (src))[0], '\0' } }), \
|
{ { ((__const char *) (src))[0], '\0' } }), \
|
||||||
__extension__ ((__STRING2_COPY_ARR3) \
|
__extension__ ((__STRING2_COPY_ARR3) \
|
||||||
@ -655,7 +678,7 @@ __stpcpy_small (char *__dest,
|
|||||||
((__const char *) (src))[2], ((__const char *) (src))[3], \
|
((__const char *) (src))[2], ((__const char *) (src))[3], \
|
||||||
((__const char *) (src))[4], ((__const char *) (src))[5], \
|
((__const char *) (src))[4], ((__const char *) (src))[5], \
|
||||||
((__const char *) (src))[6], '\0' } })
|
((__const char *) (src))[6], '\0' } })
|
||||||
# endif
|
# endif
|
||||||
__STRING_INLINE char *__stpcpy_small (char *, __STRING2_COPY_ARR2,
|
__STRING_INLINE char *__stpcpy_small (char *, __STRING2_COPY_ARR2,
|
||||||
__STRING2_COPY_ARR3,
|
__STRING2_COPY_ARR3,
|
||||||
__STRING2_COPY_ARR4,
|
__STRING2_COPY_ARR4,
|
||||||
@ -709,6 +732,7 @@ __stpcpy_small (char *__dest,
|
|||||||
}
|
}
|
||||||
return __dest + __srclen - 1;
|
return __dest + __srclen - 1;
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user