Skip to content

Commit f9d6966

Browse files
author
Kent Overstreet
committed
refcount: Split out refcount_types.h
More trimming of sched.h dependencies. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 1ef8396 commit f9d6966

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

include/linux/refcount.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,11 @@
9696
#include <linux/bug.h>
9797
#include <linux/compiler.h>
9898
#include <linux/limits.h>
99+
#include <linux/refcount_types.h>
99100
#include <linux/spinlock_types.h>
100101

101102
struct mutex;
102103

103-
/**
104-
* typedef refcount_t - variant of atomic_t specialized for reference counts
105-
* @refs: atomic_t counter field
106-
*
107-
* The counter saturates at REFCOUNT_SATURATED and will not move once
108-
* there. This avoids wrapping the counter and causing 'spurious'
109-
* use-after-free bugs.
110-
*/
111-
typedef struct refcount_struct {
112-
atomic_t refs;
113-
} refcount_t;
114-
115104
#define REFCOUNT_INIT(n) { .refs = ATOMIC_INIT(n), }
116105
#define REFCOUNT_MAX INT_MAX
117106
#define REFCOUNT_SATURATED (INT_MIN / 2)

include/linux/refcount_types.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _LINUX_REFCOUNT_TYPES_H
3+
#define _LINUX_REFCOUNT_TYPES_H
4+
5+
#include <linux/types.h>
6+
7+
/**
8+
* typedef refcount_t - variant of atomic_t specialized for reference counts
9+
* @refs: atomic_t counter field
10+
*
11+
* The counter saturates at REFCOUNT_SATURATED and will not move once
12+
* there. This avoids wrapping the counter and causing 'spurious'
13+
* use-after-free bugs.
14+
*/
15+
typedef struct refcount_struct {
16+
atomic_t refs;
17+
} refcount_t;
18+
19+
#endif /* _LINUX_REFCOUNT_TYPES_H */

include/linux/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <linux/seccomp.h>
2323
#include <linux/nodemask_types.h>
2424
#include <linux/rcupdate.h>
25-
#include <linux/refcount.h>
25+
#include <linux/refcount_types.h>
2626
#include <linux/resource.h>
2727
#include <linux/latencytop.h>
2828
#include <linux/sched/prio.h>

include/linux/sched/task.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* functionality:
88
*/
99

10+
#include <linux/refcount.h>
1011
#include <linux/sched.h>
1112
#include <linux/uaccess.h>
1213

0 commit comments

Comments
 (0)