lkml.org 
[lkml]   [2021]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 02/20] linux/stddef.h, linux/sizeof_field.h: Split sizeof_field() into a separate header
Date
Include <linux/sizeof_field.h> from <linux/stddef.h> for compatibility.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
include/linux/sizeof_field.h | 15 +++++++++++++++
include/linux/stddef.h | 9 +--------
2 files changed, 16 insertions(+), 8 deletions(-)
create mode 100644 include/linux/sizeof_field.h

diff --git a/include/linux/sizeof_field.h b/include/linux/sizeof_field.h
new file mode 100644
index 000000000000..15dc10fce8f3
--- /dev/null
+++ b/include/linux/sizeof_field.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_SIZEOF_FIELD_H
+#define _LINUX_SIZEOF_FIELD_H
+
+
+/**
+ * sizeof_field() - Report the size of a struct field in bytes
+ *
+ * @T: The structure containing the field of interest
+ * @m: The field (member) to return the size of
+ */
+#define sizeof_field(T, m) sizeof((((T *)0)->m))
+
+
+#endif /* _LINUX_SIZEOF_FIELD_H */
diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index 41217710788e..1be2c71c1e85 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -6,6 +6,7 @@
#include <uapi/linux/stddef.h>

#include <linux/offsetof.h>
+#include <linux/sizeof_field.h>


#undef NULL
@@ -16,14 +17,6 @@ enum {
true = 1
};

-/**
- * sizeof_field() - Report the size of a struct field in bytes
- *
- * @TYPE: The structure containing the field of interest
- * @MEMBER: The field to return the size of
- */
-#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
-
/**
* offsetofend() - Report the offset of a struct field within the struct
*
--
2.33.1
\
 
 \ /
  Last update: 2021-11-20 14:03    [W:0.208 / U:1.700 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site