summaryrefslogtreecommitdiffstats
path: root/sys/arm/include
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2016-05-26 00:03:23 +0000
committerian <ian@FreeBSD.org>2016-05-26 00:03:23 +0000
commit221ca14ee282d2a4c15a2e79f446f6d3e74f80b1 (patch)
treecac5ea9cc52db85de385267805bae04999e7f4fa /sys/arm/include
parent45ae491494493d7935a06c1ad0e655d974d1cf22 (diff)
downloadFreeBSD-src-221ca14ee282d2a4c15a2e79f446f6d3e74f80b1.zip
FreeBSD-src-221ca14ee282d2a4c15a2e79f446f6d3e74f80b1.tar.gz
Disable alignment faults on armv6, adjust various alignment-related macros
to match the new state of affairs. The hardware we support has always been able to do unaligned accesses, we've just never enabled it until now. This brings FreeBSD into line with all the other major OSes, and should help with the growing volume of 3rd-party software that assumes unaligned access will just work on armv6 and armv7.
Diffstat (limited to 'sys/arm/include')
-rw-r--r--sys/arm/include/_align.h4
-rw-r--r--sys/arm/include/_types.h4
-rw-r--r--sys/arm/include/param.h8
3 files changed, 16 insertions, 0 deletions
diff --git a/sys/arm/include/_align.h b/sys/arm/include/_align.h
index 0791e45..e382fe2 100644
--- a/sys/arm/include/_align.h
+++ b/sys/arm/include/_align.h
@@ -46,7 +46,11 @@
* is sufficient for any data type, pointer or numeric. The resulting type
* is equivelent to arm's uintptr_t (but is purposely spelled "unsigned" here).
*/
+#if __ARM_ARCH >= 6
+#define _ALIGNBYTES (sizeof(int) - 1)
+#else
#define _ALIGNBYTES (sizeof(long long) - 1)
+#endif
#define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
#endif /* !_ARM_INCLUDE__ALIGN_H_ */
diff --git a/sys/arm/include/_types.h b/sys/arm/include/_types.h
index b627963..267ea83 100644
--- a/sys/arm/include/_types.h
+++ b/sys/arm/include/_types.h
@@ -43,6 +43,10 @@
#error this file needs sys/cdefs.h as a prerequisite
#endif
+#if __ARM_ARCH >= 6
+#define __NO_STRICT_ALIGNMENT
+#endif
+
/*
* Basic types upon which most other types are built.
*/
diff --git a/sys/arm/include/param.h b/sys/arm/include/param.h
index e96fe4a..0ad5493 100644
--- a/sys/arm/include/param.h
+++ b/sys/arm/include/param.h
@@ -90,8 +90,16 @@
* is valid to fetch data elements of type t from on this architecture.
* This does not reflect the optimal alignment, just the possibility
* (within reasonable limits).
+ *
+ * armv4 and v5 require alignment to the type's size. armv6 and later require
+ * that an 8-byte type be aligned to at least a 4-byte boundary; access to
+ * smaller types can be unaligned.
*/
+#if __ARM_ARCH >= 6
+#define ALIGNED_POINTER(p, t) (((sizeof(t) != 8) || ((unsigned)(p) & 3) == 0))
+#else
#define ALIGNED_POINTER(p, t) ((((unsigned)(p)) & (sizeof(t)-1)) == 0)
+#endif
/*
* CACHE_LINE_SIZE is the compile-time maximum cache line size for an
OpenPOWER on IntegriCloud