refcount: Split out refcount_types.h
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 11 Dec 2023 20:15:38 +0000 (15:15 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 21 Dec 2023 00:26:31 +0000 (19:26 -0500)
More trimming of sched.h dependencies.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
include/linux/refcount.h
include/linux/refcount_types.h [new file with mode: 0644]
include/linux/sched.h
include/linux/sched/task.h

index a62fcca974861b82f60f78c54d60728d374e1f42..85c6df0d1bef41c06be705ce1228bd243347f08a 100644 (file)
 #include <linux/bug.h>
 #include <linux/compiler.h>
 #include <linux/limits.h>
+#include <linux/refcount_types.h>
 #include <linux/spinlock_types.h>
 
 struct mutex;
 
-/**
- * typedef refcount_t - variant of atomic_t specialized for reference counts
- * @refs: atomic_t counter field
- *
- * The counter saturates at REFCOUNT_SATURATED and will not move once
- * there. This avoids wrapping the counter and causing 'spurious'
- * use-after-free bugs.
- */
-typedef struct refcount_struct {
-       atomic_t refs;
-} refcount_t;
-
 #define REFCOUNT_INIT(n)       { .refs = ATOMIC_INIT(n), }
 #define REFCOUNT_MAX           INT_MAX
 #define REFCOUNT_SATURATED     (INT_MIN / 2)
diff --git a/include/linux/refcount_types.h b/include/linux/refcount_types.h
new file mode 100644 (file)
index 0000000..162004f
--- /dev/null
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_REFCOUNT_TYPES_H
+#define _LINUX_REFCOUNT_TYPES_H
+
+#include <linux/types.h>
+
+/**
+ * typedef refcount_t - variant of atomic_t specialized for reference counts
+ * @refs: atomic_t counter field
+ *
+ * The counter saturates at REFCOUNT_SATURATED and will not move once
+ * there. This avoids wrapping the counter and causing 'spurious'
+ * use-after-free bugs.
+ */
+typedef struct refcount_struct {
+       atomic_t refs;
+} refcount_t;
+
+#endif /* _LINUX_REFCOUNT_TYPES_H */
index 925711edd7f70787bb7d82e447a563a2f4c067cf..414e4df701ecd6e7d8f75c13e890c405d6ef1480 100644 (file)
@@ -22,7 +22,7 @@
 #include <linux/seccomp.h>
 #include <linux/nodemask_types.h>
 #include <linux/rcupdate.h>
-#include <linux/refcount.h>
+#include <linux/refcount_types.h>
 #include <linux/resource.h>
 #include <linux/latencytop.h>
 #include <linux/sched/prio.h>
index a23af225c8983903b103e18c52520acb13e89407..1880ae21a9cb7ad69884b4114f8678ef51ef35f4 100644 (file)
@@ -7,6 +7,7 @@
  * functionality:
  */
 
+#include <linux/refcount.h>
 #include <linux/sched.h>
 #include <linux/uaccess.h>