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
|
---
include/linux/container_of.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
--- a/include/linux/container_of.h
+++ b/include/linux/container_of.h
@@ -15,7 +15,7 @@
*
* WARNING: any const qualifier of @ptr is lost.
*/
-#define container_of(ptr, type, member) ({ \
+#define __container_of(ptr, type, member) ({ \
void *__mptr = (void *)(ptr); \
static_assert(__same_type(*(ptr), ((type *)0)->member) || \
__same_type(*(ptr), void), \
@@ -31,8 +31,11 @@
*/
#define container_of_const(ptr, type, member) \
_Generic(ptr, \
- const typeof(*(ptr)) *: ((const type *)container_of(ptr, type, member)),\
- default: ((type *)container_of(ptr, type, member)) \
+ const typeof(*(ptr)) *: ((const type *)__container_of(ptr, type, member)),\
+ default: ((type *)__container_of(ptr, type, member)) \
)
+#define container_of(ptr, type, member) container_of_const(ptr, type, member)
+
+
#endif /* _LINUX_CONTAINER_OF_H */
|