summaryrefslogtreecommitdiffstats
path: root/mdadm.h
diff options
context:
space:
mode:
authorJes Sorensen <jsorensen@fb.com>2019-07-09 20:15:38 +0200
committerJes Sorensen <jsorensen@fb.com>2019-07-09 20:15:38 +0200
commit7039d1f8200b9599b23db5953934fdb43b0442e0 (patch)
treec4a18fdfc6f6be9b159aeadfe1df7995f8d0c02a /mdadm.h
parentsuper-intel: Fix issue with abs() being irrelevant (diff)
downloadmdadm-7039d1f8200b9599b23db5953934fdb43b0442e0.tar.xz
mdadm-7039d1f8200b9599b23db5953934fdb43b0442e0.zip
mdadm.h: Introduced unaligned {get,put}_unaligned{16,32}()
We need these to avoid gcc9 going all crazy on us. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'mdadm.h')
-rw-r--r--mdadm.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/mdadm.h b/mdadm.h
index 427cc523..0fa9e1bd 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -192,6 +192,36 @@ struct dlm_lksb {
#endif /* __KLIBC__ */
/*
+ * Partially stolen from include/linux/unaligned/packed_struct.h
+ */
+struct __una_u16 { __u16 x; } __attribute__ ((packed));
+struct __una_u32 { __u32 x; } __attribute__ ((packed));
+
+static inline __u16 __get_unaligned16(const void *p)
+{
+ const struct __una_u16 *ptr = (const struct __una_u16 *)p;
+ return ptr->x;
+}
+
+static inline __u32 __get_unaligned32(const void *p)
+{
+ const struct __una_u32 *ptr = (const struct __una_u32 *)p;
+ return ptr->x;
+}
+
+static inline void __put_unaligned16(__u16 val, void *p)
+{
+ struct __una_u16 *ptr = (struct __una_u16 *)p;
+ ptr->x = val;
+}
+
+static inline void __put_unaligned32(__u32 val, void *p)
+{
+ struct __una_u32 *ptr = (struct __una_u32 *)p;
+ ptr->x = val;
+}
+
+/*
* Check at compile time that something is of a particular type.
* Always evaluates to 1 so you may use it easily in comparisons.
*/