[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211120130104.185699-3-alx.manpages@gmail.com>
Date: Sat, 20 Nov 2021 14:00:45 +0100
From: Alejandro Colomar <alx.manpages@...il.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Alejandro Colomar <alx.manpages@...il.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Arnd Bergmann <arnd@...db.de>,
Alexey Dobriyan <adobriyan@...il.com>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Kees Cook <keescook@...omium.org>,
Joe Perches <joe@...ches.com>
Subject: [PATCH v2 02/20] linux/stddef.h, linux/sizeof_field.h: Split sizeof_field() into a separate header
Include <linux/sizeof_field.h> from <linux/stddef.h> for compatibility.
Signed-off-by: Alejandro Colomar <alx.manpages@...il.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
Powered by blists - more mailing lists