diff options
author | delphij <delphij@FreeBSD.org> | 2014-10-02 17:41:27 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2014-10-02 17:41:27 +0000 |
commit | 0bbb133a516a472ce6215fb37ab2487ff207356e (patch) | |
tree | 1a884d34cecb4286e3d0de7dec0d8b01ef8f45ec /sys/cddl | |
parent | 88af6200b62eec907d364735083085c41268f31c (diff) | |
download | FreeBSD-src-0bbb133a516a472ce6215fb37ab2487ff207356e.zip FreeBSD-src-0bbb133a516a472ce6215fb37ab2487ff207356e.tar.gz |
MFC r272389:
Diff reduction with kernel code: instruct the compiler that the data of
these types may be unaligned to their "normal" alignment and exercise
caution when accessing them.
PR: 194071
Approved by: re (gjb)
Diffstat (limited to 'sys/cddl')
-rw-r--r-- | sys/cddl/boot/zfs/lz4.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/cddl/boot/zfs/lz4.c b/sys/cddl/boot/zfs/lz4.c index 78af959..055bd62 100644 --- a/sys/cddl/boot/zfs/lz4.c +++ b/sys/cddl/boot/zfs/lz4.c @@ -83,6 +83,17 @@ lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int dum #endif /* + * Unaligned memory access is automatically enabled for "common" CPU, + * such as x86. For others CPU, the compiler will be more cautious, and + * insert extra code to ensure aligned access is respected. If you know + * your target CPU supports unaligned memory access, you may want to + * force this option manually to improve performance + */ +#if defined(__ARM_FEATURE_UNALIGNED) +#define LZ4_FORCE_UNALIGNED_ACCESS 1 +#endif + +/* * Compiler Options */ #if __STDC_VERSION__ >= 199901L /* C99 */ @@ -113,6 +124,10 @@ lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int dum #define S32 int32_t #define U64 uint64_t +#ifndef LZ4_FORCE_UNALIGNED_ACCESS +#pragma pack(1) +#endif + typedef struct _U16_S { U16 v; } U16_S; @@ -123,6 +138,10 @@ typedef struct _U64_S { U64 v; } U64_S; +#ifndef LZ4_FORCE_UNALIGNED_ACCESS +#pragma pack() +#endif + #define A64(x) (((U64_S *)(x))->v) #define A32(x) (((U32_S *)(x))->v) #define A16(x) (((U16_S *)(x))->v) |