Skip to content

Commit d6e6a27

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
tools: Fix math.h breakage
Commit 98e1385 ("include/linux/radix-tree.h: replace kernel.h with the necessary inclusions") broke the radix tree test suite in two different ways; first by including math.h which didn't exist in the tools directory, and second by removing an implicit include of spinlock.h before lockdep.h. Fix both issues. Cc: Andy Shevchenko <[email protected]> Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Acked-by: Andy Shevchenko <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ddca5b0 commit d6e6a27

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

tools/include/linux/kernel.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
#include <assert.h>
88
#include <linux/build_bug.h>
99
#include <linux/compiler.h>
10+
#include <linux/math.h>
1011
#include <endian.h>
1112
#include <byteswap.h>
1213

1314
#ifndef UINT_MAX
1415
#define UINT_MAX (~0U)
1516
#endif
1617

17-
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
18-
1918
#define PERF_ALIGN(x, a) __PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
2019
#define __PERF_ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
2120

@@ -52,15 +51,6 @@
5251
_min1 < _min2 ? _min1 : _min2; })
5352
#endif
5453

55-
#ifndef roundup
56-
#define roundup(x, y) ( \
57-
{ \
58-
const typeof(y) __y = y; \
59-
(((x) + (__y - 1)) / __y) * __y; \
60-
} \
61-
)
62-
#endif
63-
6454
#ifndef BUG_ON
6555
#ifdef NDEBUG
6656
#define BUG_ON(cond) do { if (cond) {} } while (0)
@@ -104,16 +94,6 @@ int scnprintf_pad(char * buf, size_t size, const char * fmt, ...);
10494

10595
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
10696

107-
/*
108-
* This looks more complex than it should be. But we need to
109-
* get the type for the ~ right in round_down (it needs to be
110-
* as wide as the result!), and we want to evaluate the macro
111-
* arguments just once each.
112-
*/
113-
#define __round_mask(x, y) ((__typeof__(x))((y)-1))
114-
#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
115-
#define round_down(x, y) ((x) & ~__round_mask(x, y))
116-
11797
#define current_gfp_context(k) 0
11898
#define synchronize_rcu()
11999

tools/include/linux/math.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef _TOOLS_MATH_H
2+
#define _TOOLS_MATH_H
3+
4+
/*
5+
* This looks more complex than it should be. But we need to
6+
* get the type for the ~ right in round_down (it needs to be
7+
* as wide as the result!), and we want to evaluate the macro
8+
* arguments just once each.
9+
*/
10+
#define __round_mask(x, y) ((__typeof__(x))((y)-1))
11+
#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
12+
#define round_down(x, y) ((x) & ~__round_mask(x, y))
13+
14+
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
15+
16+
#ifndef roundup
17+
#define roundup(x, y) ( \
18+
{ \
19+
const typeof(y) __y = y; \
20+
(((x) + (__y - 1)) / __y) * __y; \
21+
} \
22+
)
23+
#endif
24+
25+
#endif

tools/testing/radix-tree/linux/lockdep.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#ifndef _LINUX_LOCKDEP_H
22
#define _LINUX_LOCKDEP_H
3+
4+
#include <linux/spinlock.h>
5+
36
struct lock_class_key {
47
unsigned int a;
58
};

0 commit comments

Comments
 (0)