Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Oct 2014 00:13:09 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r272389 - head/sys/cddl/boot/zfs
Message-ID:  <201410020013.s920D9rt003617@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Thu Oct  2 00:13:08 2014
New Revision: 272389
URL: https://svnweb.freebsd.org/changeset/base/272389

Log:
  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
  MFC after:	3 days

Modified:
  head/sys/cddl/boot/zfs/lz4.c

Modified: head/sys/cddl/boot/zfs/lz4.c
==============================================================================
--- head/sys/cddl/boot/zfs/lz4.c	Wed Oct  1 23:15:23 2014	(r272388)
+++ head/sys/cddl/boot/zfs/lz4.c	Thu Oct  2 00:13:08 2014	(r272389)
@@ -83,6 +83,17 @@ lz4_decompress(void *s_start, void *d_st
 #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_st
 #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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410020013.s920D9rt003617>