Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame^] | 1 | From: Simon McVittie <smcv@debian.org> |
| 2 | Date: Sun, 23 Nov 2014 22:50:33 +0000 |
| 3 | Subject: Use memcpy() instead of reinventing it |
| 4 | |
| 5 | gcc inlines memcpy() with results as fast as handwritten code (at |
| 6 | least in my brief testing with lzop), and knows the alignment |
| 7 | constraints for our architectures. |
| 8 | |
| 9 | Change suggested by Julian Taylor. |
| 10 | |
| 11 | Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=757037 |
| 12 | |
| 13 | Upstream-Status: Pending |
| 14 | Signed-off-by: Saul Wold <sgw@linux.intel.com> |
| 15 | --- |
| 16 | minilzo/minilzo.c | 14 ++++++++++++++ |
| 17 | src/lzo_func.h | 14 ++++++++++++++ |
| 18 | 2 files changed, 28 insertions(+) |
| 19 | |
| 20 | |
| 21 | diff --git a/minilzo/minilzo.c b/minilzo/minilzo.c |
| 22 | index ab2be5f..6913c2f 100644 |
| 23 | --- a/minilzo/minilzo.c |
| 24 | +++ b/minilzo/minilzo.c |
| 25 | @@ -3523,6 +3523,20 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) |
| 26 | if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \ |
| 27 | LZO_BLOCK_END |
| 28 | |
| 29 | +/* Debian-specific change: we know that our compiler inlines memcpy() with |
| 30 | + * constant n to be as fast as handwritten code, and knows which architectures |
| 31 | + * need things correctly aligned. */ |
| 32 | +#undef LZO_MEMOPS_COPY1 |
| 33 | +#undef LZO_MEMOPS_COPY2 |
| 34 | +#undef LZO_MEMOPS_COPY4 |
| 35 | +#undef LZO_MEMOPS_COPY8 |
| 36 | +#undef LZO_MEMOPS_COPYN |
| 37 | +#define LZO_MEMOPS_COPY1(dd,ss) memcpy(dd, ss, 1) |
| 38 | +#define LZO_MEMOPS_COPY2(dd,ss) memcpy(dd, ss, 2) |
| 39 | +#define LZO_MEMOPS_COPY4(dd,ss) memcpy(dd, ss, 4) |
| 40 | +#define LZO_MEMOPS_COPY8(dd,ss) memcpy(dd, ss, 8) |
| 41 | +#define LZO_MEMOPS_COPYN(dd,ss,nn) memcpy(dd, ss, nn) |
| 42 | + |
| 43 | __lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss) |
| 44 | { |
| 45 | lzo_uint16_t v; |
| 46 | diff --git a/src/lzo_func.h b/src/lzo_func.h |
| 47 | index dfaa676..1cc1b53 100644 |
| 48 | --- a/src/lzo_func.h |
| 49 | +++ b/src/lzo_func.h |
| 50 | @@ -333,6 +333,20 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) |
| 51 | if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \ |
| 52 | LZO_BLOCK_END |
| 53 | |
| 54 | +/* Debian-specific change: we know that our compiler inlines memcpy() with |
| 55 | + * constant n to be as fast as handwritten code, and knows which architectures |
| 56 | + * need things correctly aligned. */ |
| 57 | +#undef LZO_MEMOPS_COPY1 |
| 58 | +#undef LZO_MEMOPS_COPY2 |
| 59 | +#undef LZO_MEMOPS_COPY4 |
| 60 | +#undef LZO_MEMOPS_COPY8 |
| 61 | +#undef LZO_MEMOPS_COPYN |
| 62 | +#define LZO_MEMOPS_COPY1(dd,ss) memcpy(dd, ss, 1) |
| 63 | +#define LZO_MEMOPS_COPY2(dd,ss) memcpy(dd, ss, 2) |
| 64 | +#define LZO_MEMOPS_COPY4(dd,ss) memcpy(dd, ss, 4) |
| 65 | +#define LZO_MEMOPS_COPY8(dd,ss) memcpy(dd, ss, 8) |
| 66 | +#define LZO_MEMOPS_COPYN(dd,ss,nn) memcpy(dd, ss, nn) |
| 67 | + |
| 68 | __lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss) |
| 69 | { |
| 70 | lzo_uint16_t v; |