Package: fuse3 / 3.17.2-3

Add-container_of-and-ROUND_UP-macros.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From d6a9799fc04e6ada5fd7fd7bbde14fb14981fc8b Mon Sep 17 00:00:00 2001
From: Bernd Schubert <bschubert@ddn.com>
Date: Tue, 15 Apr 2025 22:03:09 +0200
Subject: [PATCH] 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 <bschubert@ddn.com>
(cherry picked from commit c5a032b3410d7225ac0355355faa63565a209943)
---
 lib/fuse.c          | 4 ----
 lib/fuse_lowlevel.c | 4 ----
 lib/util.h          | 6 ++++++
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/lib/fuse.c b/lib/fuse.c
index c0d00edbc..4964de20f 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -92,10 +92,6 @@ struct node_table {
 	size_t split;
 };
 
-#define container_of(ptr, type, member) ({                              \
-			const typeof( ((type *)0)->member ) *__mptr = (ptr); \
-			(type *)( (char *)__mptr - offsetof(type,member) );})
-
 #define list_entry(ptr, type, member)           \
 	container_of(ptr, type, member)
 
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 9ee88b160..cb046aae0 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -44,10 +44,6 @@
 #define PARAM(inarg) (((char *)(inarg)) + sizeof(*(inarg)))
 #define OFFSET_MAX 0x7fffffffffffffffLL
 
-#define container_of(ptr, type, member) ({				\
-			const typeof( ((type *)0)->member ) *__mptr = (ptr); \
-			(type *)( (char *)__mptr - offsetof(type,member) );})
-
 struct fuse_pollhandle {
 	uint64_t kh;
 	struct fuse_session *se;
diff --git a/lib/util.h b/lib/util.h
index 508fafb12..ed03ad40e 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