From be3594254605047d0623f905329d160544ca925c Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Wed, 24 Jun 2020 18:02:53 +0200 Subject: fs: btrfs: Crossport structure accessor into ctree.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This brings all structure accessors from btrfs-progs/ctree.h, as in kernel's ctree.h. All these accessors handle the endian convert at runtime, and since all of them are defined as static inline functions, those which aren't used won't take space in resulting binary. Signed-off-by: Qu Wenruo Reviewed-by: Marek BehĂșn --- fs/btrfs/compat.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'fs/btrfs/compat.h') diff --git a/fs/btrfs/compat.h b/fs/btrfs/compat.h index b354c17a5cd..12fb9f803c3 100644 --- a/fs/btrfs/compat.h +++ b/fs/btrfs/compat.h @@ -23,6 +23,20 @@ #define cpu_to_le8(v) (v) #define __le8 u8 +/* + * Macros to generate set/get funcs for the struct fields + * assume there is a lefoo_to_cpu for every type, so lets make a simple + * one for u8: + */ +#define le8_to_cpu(v) (v) +#define cpu_to_le8(v) (v) +#define __le8 u8 + +#define get_unaligned_le8(p) (*((u8 *)(p))) +#define get_unaligned_8(p) (*((u8 *)(p))) +#define put_unaligned_le8(val,p) ((*((u8 *)(p))) = (val)) +#define put_unaligned_8(val,p) ((*((u8 *)(p))) = (val)) + /* * Read data from device specified by @desc and @part * -- cgit v1.2.3