1From: Simon McVittie <smcv@debian.org> 2Date: Sun, 23 Nov 2014 22:50:33 +0000 3Subject: Use memcpy() instead of reinventing it 4 5gcc inlines memcpy() with results as fast as handwritten code (at 6least in my brief testing with lzop), and knows the alignment 7constraints for our architectures. 8 9Change suggested by Julian Taylor. 10 11Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=757037 12 13RP: Patch is still in debian as of 20220524 in a revised form: 14https://sources.debian.org/patches/lzo2/2.10-2/ 15https://sources.debian.org/patches/lzo2/2.10-2/0001-Conditionally-replace-reinvention-of-memcpy-with-cal.patch/ 16It was submitted in 2015, no reply to an email from RP in 2022 either. 17 18We likely need this in OE to prevent against unaligned accesses 19on systems such as armv5. 20 21Upstream-Status: Inactive-Upstream 22Signed-off-by: Saul Wold <sgw@linux.intel.com> 23--- 24 minilzo/minilzo.c | 14 ++++++++++++++ 25 src/lzo_func.h | 14 ++++++++++++++ 26 2 files changed, 28 insertions(+) 27 28 29diff --git a/minilzo/minilzo.c b/minilzo/minilzo.c 30index ab2be5f..6913c2f 100644 31--- a/minilzo/minilzo.c 32+++ b/minilzo/minilzo.c 33@@ -3523,6 +3523,20 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) 34 if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \ 35 LZO_BLOCK_END 36 37+/* Debian-specific change: we know that our compiler inlines memcpy() with 38+ * constant n to be as fast as handwritten code, and knows which architectures 39+ * need things correctly aligned. */ 40+#undef LZO_MEMOPS_COPY1 41+#undef LZO_MEMOPS_COPY2 42+#undef LZO_MEMOPS_COPY4 43+#undef LZO_MEMOPS_COPY8 44+#undef LZO_MEMOPS_COPYN 45+#define LZO_MEMOPS_COPY1(dd,ss) memcpy(dd, ss, 1) 46+#define LZO_MEMOPS_COPY2(dd,ss) memcpy(dd, ss, 2) 47+#define LZO_MEMOPS_COPY4(dd,ss) memcpy(dd, ss, 4) 48+#define LZO_MEMOPS_COPY8(dd,ss) memcpy(dd, ss, 8) 49+#define LZO_MEMOPS_COPYN(dd,ss,nn) memcpy(dd, ss, nn) 50+ 51 __lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss) 52 { 53 lzo_uint16_t v; 54diff --git a/src/lzo_func.h b/src/lzo_func.h 55index dfaa676..1cc1b53 100644 56--- a/src/lzo_func.h 57+++ b/src/lzo_func.h 58@@ -333,6 +333,20 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) 59 if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \ 60 LZO_BLOCK_END 61 62+/* Debian-specific change: we know that our compiler inlines memcpy() with 63+ * constant n to be as fast as handwritten code, and knows which architectures 64+ * need things correctly aligned. */ 65+#undef LZO_MEMOPS_COPY1 66+#undef LZO_MEMOPS_COPY2 67+#undef LZO_MEMOPS_COPY4 68+#undef LZO_MEMOPS_COPY8 69+#undef LZO_MEMOPS_COPYN 70+#define LZO_MEMOPS_COPY1(dd,ss) memcpy(dd, ss, 1) 71+#define LZO_MEMOPS_COPY2(dd,ss) memcpy(dd, ss, 2) 72+#define LZO_MEMOPS_COPY4(dd,ss) memcpy(dd, ss, 4) 73+#define LZO_MEMOPS_COPY8(dd,ss) memcpy(dd, ss, 8) 74+#define LZO_MEMOPS_COPYN(dd,ss,nn) memcpy(dd, ss, nn) 75+ 76 __lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss) 77 { 78 lzo_uint16_t v; 79