diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-07-08 15:26:03 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-07-08 15:26:30 -0400 |
commit | 4e973f190c90351fa0e56d0523877d8fe6a646bd (patch) | |
tree | a5f94efdff4f5d5c3a3a3559cf1bbeae66ad8560 /libbcachefs/compress.h | |
parent | 25c580652a8a7ed83f71e6762eaea8dba06f538b (diff) |
Update bcachefs sources to 6fc0b31163ea workqueue: Basic memory allocation profiling support
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'libbcachefs/compress.h')
-rw-r--r-- | libbcachefs/compress.h | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/libbcachefs/compress.h b/libbcachefs/compress.h index bec2f05b..667ddb91 100644 --- a/libbcachefs/compress.h +++ b/libbcachefs/compress.h @@ -10,41 +10,27 @@ static const unsigned __bch2_compression_opt_to_type[] = { #undef x }; -struct bch_compression_opt { - u8 type:4, - level:4; -}; - -static inline struct bch_compression_opt __bch2_compression_decode(unsigned v) -{ - return (struct bch_compression_opt) { - .type = v & 15, - .level = v >> 4, +union bch_compression_opt { + u8 value; + struct { +#if defined(__LITTLE_ENDIAN_BITFIELD) + u8 type:4, level:4; +#elif defined(__BIG_ENDIAN_BITFIELD) + u8 level:4, type:4; +#endif }; -} +}; static inline bool bch2_compression_opt_valid(unsigned v) { - struct bch_compression_opt opt = __bch2_compression_decode(v); + union bch_compression_opt opt = { .value = v }; return opt.type < ARRAY_SIZE(__bch2_compression_opt_to_type) && !(!opt.type && opt.level); } -static inline struct bch_compression_opt bch2_compression_decode(unsigned v) -{ - return bch2_compression_opt_valid(v) - ? __bch2_compression_decode(v) - : (struct bch_compression_opt) { 0 }; -} - -static inline unsigned bch2_compression_encode(struct bch_compression_opt opt) -{ - return opt.type|(opt.level << 4); -} - static inline enum bch_compression_type bch2_compression_opt_to_type(unsigned v) { - return __bch2_compression_opt_to_type[bch2_compression_decode(v).type]; + return __bch2_compression_opt_to_type[((union bch_compression_opt){ .value = v }).type]; } struct bch_write_op; |