[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211119113644.1600-14-alx.manpages@gmail.com>
Date: Fri, 19 Nov 2021 12:36:41 +0100
From: Alejandro Colomar <alx.manpages@...il.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Alejandro Colomar <alx.manpages@...il.com>
Subject: [PATCH 13/17] linux/sizeof_field.h: Move sizeof_field(T, m) to a separate header
Touching files so used for the kernel,
forces 'make' to recompile most of the kernel.
Having those definitions in more granular files
helps avoid recompiling so much of the kernel.
Signed-off-by: Alejandro Colomar <alx.manpages@...il.com>
---
include/linux/efi.h | 1 +
include/linux/filter.h | 1 +
include/linux/kvm_host.h | 1 +
include/linux/phy_led_triggers.h | 1 +
include/linux/sizeof_field.h | 14 ++++++++++++++
include/linux/slab.h | 1 +
include/linux/stddef.h | 9 +--------
7 files changed, 20 insertions(+), 8 deletions(-)
create mode 100644 include/linux/sizeof_field.h
diff --git a/include/linux/efi.h b/include/linux/efi.h
index dbd39b20e034..47aecde48326 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -25,6 +25,7 @@
#include <linux/reboot.h>
#include <linux/uuid.h>
#include <linux/screen_info.h>
+#include <linux/sizeof_field.h>
#include <asm/page.h>
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 3b6bd782e1d6..ebb0ae480533 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -18,6 +18,7 @@
#include <linux/kallsyms.h>
#include <linux/if_vlan.h>
#include <linux/offsetof.h>
+#include <linux/sizeof_field.h>
#include <linux/vmalloc.h>
#include <linux/sockptr.h>
#include <crypto/sha1.h>
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 289778b9e6fa..f89a516f3a39 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -30,6 +30,7 @@
#include <linux/nospec.h>
#include <linux/notifier.h>
#include <linux/offsetof.h>
+#include <linux/sizeof_field.h>
#include <asm/signal.h>
#include <linux/kvm.h>
diff --git a/include/linux/phy_led_triggers.h b/include/linux/phy_led_triggers.h
index 5c4d7a755101..86581b985161 100644
--- a/include/linux/phy_led_triggers.h
+++ b/include/linux/phy_led_triggers.h
@@ -10,6 +10,7 @@ struct phy_device;
#include <linux/leds.h>
#include <linux/phy.h>
+#include <linux/sizeof_field.h>
#define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 11
diff --git a/include/linux/sizeof_field.h b/include/linux/sizeof_field.h
new file mode 100644
index 000000000000..7ff541cb21af
--- /dev/null
+++ b/include/linux/sizeof_field.h
@@ -0,0 +1,14 @@
+/* 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
+ *
+ * @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))
+
+
+#endif /* _LINUX_SIZEOF_FIELD_H */
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 61cb3191566f..c2bd24c60803 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -18,6 +18,7 @@
#include <linux/types.h>
#include <linux/workqueue.h>
#include <linux/percpu-refcount.h>
+#include <linux/sizeof_field.h>
/*
diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index 6ab0f57eccde..5c9aedb5e6ad 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -5,6 +5,7 @@
#include <uapi/linux/stddef.h>
#include <linux/NULL.h>
#include <linux/offsetof.h>
+#include <linux/sizeof_field.h>
enum {
@@ -12,14 +13,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