From 9925b6e7548d65696f745732617d25481b76acbe Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Tue, 15 Apr 2025 22:03:09 +0200 Subject: Add container_of and ROUND_UP macros Needed by follow up commits. container_of is actually just moved/consolidated to util.h. Signed-off-by: Bernd Schubert (cherry picked from commit c5a032b3410d7225ac0355355faa63565a209943) --- lib/util.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/util.h') diff --git a/lib/util.h b/lib/util.h index 508fafb..ed03ad4 100644 --- a/lib/util.h +++ b/lib/util.h @@ -30,4 +30,10 @@ static inline uint64_t fuse_higher_32_bits(uint64_t nr) #define FUSE_VAR_UNUSED(var) (__attribute__((unused)) var) #endif +#define container_of(ptr, type, member) \ + ({ \ + unsigned long __mptr = (unsigned long)(ptr); \ + ((type *)(__mptr - offsetof(type, member))); \ + }) + #endif -- cgit v1.2.3