Skip to content

Commit 10a04ff

Browse files
alobakindavem330
authored andcommitted
tools: move alignment-related macros to new <linux/align.h>
Currently, tools have *ALIGN*() macros scattered across the unrelated headers, as there are only 3 of them and they were added separately each time on an as-needed basis. Anyway, let's make it more consistent with the kernel headers and allow using those macros outside of the mentioned headers. Create <linux/align.h> inside the tools/ folder and include it where needed. Signed-off-by: Yury Norov <yury.norov@gmail.com> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4ca532d commit 10a04ff

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

tools/include/linux/align.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
3+
#ifndef _TOOLS_LINUX_ALIGN_H
4+
#define _TOOLS_LINUX_ALIGN_H
5+
6+
#include <uapi/linux/const.h>
7+
8+
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
9+
#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a))
10+
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
11+
12+
#endif /* _TOOLS_LINUX_ALIGN_H */

tools/include/linux/bitmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _TOOLS_LINUX_BITMAP_H
44

55
#include <string.h>
6+
#include <linux/align.h>
67
#include <linux/bitops.h>
78
#include <linux/find.h>
89
#include <stdlib.h>
@@ -126,7 +127,6 @@ static inline bool bitmap_and(unsigned long *dst, const unsigned long *src1,
126127
#define BITMAP_MEM_ALIGNMENT (8 * sizeof(unsigned long))
127128
#endif
128129
#define BITMAP_MEM_MASK (BITMAP_MEM_ALIGNMENT - 1)
129-
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
130130

131131
static inline bool bitmap_equal(const unsigned long *src1,
132132
const unsigned long *src2, unsigned int nbits)

tools/include/linux/mm.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
#ifndef _TOOLS_LINUX_MM_H
33
#define _TOOLS_LINUX_MM_H
44

5+
#include <linux/align.h>
56
#include <linux/mmzone.h>
6-
#include <uapi/linux/const.h>
77

88
#define PAGE_SHIFT 12
99
#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
1010
#define PAGE_MASK (~(PAGE_SIZE - 1))
1111

1212
#define PHYS_ADDR_MAX (~(phys_addr_t)0)
1313

14-
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
15-
#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a))
16-
1714
#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
1815

1916
#define __va(x) ((void *)((unsigned long)(x)))

0 commit comments

Comments
 (0)