This is safe for the arches that currently use this as gcc says that
defining a struct as packed is equivalent to putting packed on each struct
member.
The reason this is needed is that there are some arches that define structs
to be aligned to something greater than a byte...so even if the first member
of the struct is marked as packed, gcc will still treat it as having the
default stuct alignment which will allow it to choose _builtin_memcpy...
see the comments in the memmove-using arches. This also turned out to be
the issue with ARM (needs confirmation) because _some_ ARM compilers
have this alignment set to 4 bytes.
If the struct _itself_ is marked as packed, the compiler cannot assume this default
alignment and _must_ do the bytewise access in whatever way the arch does it. By
making this change, the last 3 arches could move to the new asm-generic version
and the bits in linux/unaligned/ can be removed.
Signed-off-by: Harvey Harrison <[email protected]>
---
include/asm-generic/unaligned.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h
index 8dfca50..ac23e04 100644
--- a/include/asm-generic/unaligned.h
+++ b/include/asm-generic/unaligned.h
@@ -68,9 +68,9 @@ static inline void put_unaligned_be64(u64 val, void *p)
#else /* _UNALIGNED_ACCESS_OK */
-struct __una_u16 { u16 x __attribute__((packed)); };
-struct __una_u32 { u32 x __attribute__((packed)); };
-struct __una_u64 { u64 x __attribute__((packed)); };
+struct __una_u16 { u16 x; } __attribute__((packed));
+struct __una_u32 { u32 x; } __attribute__((packed));
+struct __una_u64 { u64 x; } __attribute__((packed));
static inline u16 __get_le16_noalign(const u8 *p)
{
--
1.6.0.4.994.g16bd3e