[AArch64] Inline mempcpy again
Commit Message
ping
From: Wilco Dijkstra
Sent: 29 June 2017 17:20
To: libc-alpha@sourceware.org
Cc: nd
Subject: [PATCH][AArch64] Inline mempcpy again
Recent changes removed the generic mempcpy inline. Given GCC still
doesn't optimize mempcpy (PR70140), I am adding it again. Since
string/string.h no longer includes an architecture specific header, do this
inside include/string.h and for now only on AArch64.
OK for commit?
ChangeLog:
2017-06-29 Wilco Dijkstra <wdijkstr@arm.com>
* include/string.h: (mempcpy): Redirect to __mempcpy_inline.
(__mempcpy): Likewise.
(__mempcpy_inline): New inline function.
* sysdeps/aarch64/string_private.h: Define _INLINE_mempcpy.
--
@@ -197,4 +197,23 @@ extern char *__strncat_chk (char *__restrict __dest,
                            size_t __len, size_t __destlen) __THROW;
 #endif
Â
+#if defined __USE_GNU && defined __OPTIMIZE__ \
+Â Â Â && defined __extern_always_inline && __GNUC_PREREQ (3,2) \
+Â Â Â && defined _INLINE_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
@@ -18,3 +18,6 @@
Â
 /* AArch64 implementations support efficient unaligned access. */
 #define _STRING_ARCH_unaligned 1
+
+/* Inline mempcpy since GCC doesn't optimize it (PR70140). */
+#define _INLINE_mempcpy 1