dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/0028-mdadm.h-Introduced-unaligned-get-put-_unaligned-16-3.patch

f9a9f5
From 7039d1f8200b9599b23db5953934fdb43b0442e0 Mon Sep 17 00:00:00 2001
f9a9f5
From: Jes Sorensen <jsorensen@fb.com>
f9a9f5
Date: Tue, 9 Jul 2019 14:15:38 -0400
f9a9f5
Subject: [RHEL7.8 PATCH V2 28/47] mdadm.h: Introduced unaligned
f9a9f5
 {get,put}_unaligned{16,32}()
f9a9f5
f9a9f5
We need these to avoid gcc9 going all crazy on us.
f9a9f5
f9a9f5
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
f9a9f5
---
f9a9f5
 mdadm.h | 30 ++++++++++++++++++++++++++++++
f9a9f5
 1 file changed, 30 insertions(+)
f9a9f5
f9a9f5
diff --git a/mdadm.h b/mdadm.h
f9a9f5
index 427cc52..0fa9e1b 100644
f9a9f5
--- a/mdadm.h
f9a9f5
+++ b/mdadm.h
f9a9f5
@@ -192,6 +192,36 @@ struct dlm_lksb {
f9a9f5
 #endif /* __KLIBC__ */
f9a9f5
 
f9a9f5
 /*
f9a9f5
+ * Partially stolen from include/linux/unaligned/packed_struct.h
f9a9f5
+ */
f9a9f5
+struct __una_u16 { __u16 x; } __attribute__ ((packed));
f9a9f5
+struct __una_u32 { __u32 x; } __attribute__ ((packed));
f9a9f5
+
f9a9f5
+static inline __u16 __get_unaligned16(const void *p)
f9a9f5
+{
f9a9f5
+	const struct __una_u16 *ptr = (const struct __una_u16 *)p;
f9a9f5
+	return ptr->x;
f9a9f5
+}
f9a9f5
+
f9a9f5
+static inline __u32 __get_unaligned32(const void *p)
f9a9f5
+{
f9a9f5
+	const struct __una_u32 *ptr = (const struct __una_u32 *)p;
f9a9f5
+	return ptr->x;
f9a9f5
+}
f9a9f5
+
f9a9f5
+static inline void __put_unaligned16(__u16 val, void *p)
f9a9f5
+{
f9a9f5
+	struct __una_u16 *ptr = (struct __una_u16 *)p;
f9a9f5
+	ptr->x = val;
f9a9f5
+}
f9a9f5
+
f9a9f5
+static inline void __put_unaligned32(__u32 val, void *p)
f9a9f5
+{
f9a9f5
+	struct __una_u32 *ptr = (struct __una_u32 *)p;
f9a9f5
+	ptr->x = val;
f9a9f5
+}
f9a9f5
+
f9a9f5
+/*
f9a9f5
   * Check at compile time that something is of a particular type.
f9a9f5
   * Always evaluates to 1 so you may use it easily in comparisons.
f9a9f5
 */
f9a9f5
-- 
f9a9f5
2.7.5
f9a9f5