This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Revert commit 05a910f7
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>, Wilco Dijkstra <wdijkstr at arm dot com>
- Date: Mon, 7 Mar 2016 13:47:43 -0800
- Subject: [PATCH] Revert commit 05a910f7
- Authentication-results: sourceware.org; auth=none
On Mon, Mar 7, 2016 at 1:20 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Mar 7, 2016 at 12:57 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>> Since x86 has an optimized mempcpy and GCC can inline mempcpy on x86,
>> define _HAVE_STRING_ARCH_mempcpy to 1 for x86.
>>
>> If duplicated code between optimized memcpy and mempcpy is a concern,
>> we can add an entry point in memcpy and use it to implement mempcpy,
>> similar to the set of patches for __mempcpy_sse2_unaligned:
>>
>> https://sourceware.org/ml/libc-alpha/2016-03/msg00166.html
>>
>> OK for master?
>>
>>
>> H.J.
>> ---
>> [BZ #19759]
>> * sysdeps/x86/bits/string.h (_HAVE_STRING_ARCH_mempcpy): New.
>> ---
>> sysdeps/x86/bits/string.h | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
>> index e4e019f..f5885b4 100644
>> --- a/sysdeps/x86/bits/string.h
>> +++ b/sysdeps/x86/bits/string.h
>> @@ -62,6 +62,9 @@
>> | ((const unsigned char *) (src))[idx])
>>
>>
>> +/* Don't inline mempcpy into memcpy as x86 has an optimized mempcpy. */
>> +# define _HAVE_STRING_ARCH_mempcpy 1
>> +
>> /* Copy N bytes of SRC to DEST. */
>> # define _HAVE_STRING_ARCH_memcpy 1
>> # define memcpy(dest, src, n) \
>> --
>> 2.5.0
>>
>
> It doesn't work since <bits/string.h> is included only if
>
> #if defined __GNUC__ && __GNUC__ >= 2
> # if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
> && !defined __NO_INLINE__ && !defined __cplusplus
>
> is true.
>
I believe commit 05a910f7 was wrong. At minimum,
mempcpy shouldn't be inlined in 2 different header files.
--
H.J.
From 786bb62f66da6ffe6b2614191ca19a0f0d161af9 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 7 Mar 2016 13:40:54 -0800
Subject: [PATCH] Revert commit 05a910f7
mempcpy is inlined in string/bits/string2.h. Any improvement for mempcpy
should be made in string/bits/string2.h, not in string/string.h.
[BZ #19759]
* string/string.h (mempcpy): Removed.
(__mempcpy): Likewise.
(__mempcpy_inline): Likewise.
* sysdeps/sparc/bits/string.h (_HAVE_STRING_ARCH_mempcpy):
Likewise.
---
string/string.h | 19 -------------------
sysdeps/sparc/bits/string.h | 3 ---
2 files changed, 22 deletions(-)
diff --git a/string/string.h b/string/string.h
index 1f3e348..f46e3eb 100644
--- a/string/string.h
+++ b/string/string.h
@@ -636,25 +636,6 @@ extern char *basename (const char *__filename) __THROW __nonnull ((1));
# endif
#endif
-#if defined __USE_GNU && defined __OPTIMIZE__ \
- && defined __extern_always_inline && __GNUC_PREREQ (3,2)
-# if !defined _FORCE_INLINES && !defined _HAVE_STRING_ARCH_mempcpy
-
-#undef mempcpy
-#undef __mempcpy
-#define mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
-#define __mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
-
-__extern_always_inline void *
-__mempcpy_inline (void *__restrict __dest,
- const void *__restrict __src, size_t __n)
-{
- return (char *) memcpy (__dest, __src, __n) + __n;
-}
-
-# endif
-#endif
-
__END_DECLS
#endif /* string.h */
diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
index 10beca6..1ef4243 100644
--- a/sysdeps/sparc/bits/string.h
+++ b/sysdeps/sparc/bits/string.h
@@ -26,6 +26,3 @@
/* sparc32 and sparc64 strchr(x, '\0') perform better than
__rawmemchr(x, '\0'). */
#define _HAVE_STRING_ARCH_strchr 1
-
-/* Don't inline mempcpy into memcpy as sparc has an optimized mempcpy. */
-#define _HAVE_STRING_ARCH_mempcpy 1
--
2.5.0