1 From 48232d3d931c95953ce2ddfe7da7bb164aef6a73 Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Fri, 7 Jul 2017 17:03:16 +0200
4 Subject: fix portability of some includes files in tools/ used on the host
6 Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 tools/include/tools/be_byteshift.h | 4 ++++
9 tools/include/tools/le_byteshift.h | 4 ++++
10 tools/include/tools/linux_types.h | 22 ++++++++++++++++++++++
11 3 files changed, 30 insertions(+)
12 create mode 100644 tools/include/tools/linux_types.h
14 --- a/tools/include/tools/be_byteshift.h
15 +++ b/tools/include/tools/be_byteshift.h
17 #ifndef _TOOLS_BE_BYTESHIFT_H
18 #define _TOOLS_BE_BYTESHIFT_H
21 +#include "linux_types.h"
26 static inline uint16_t __get_unaligned_be16(const uint8_t *p)
27 --- a/tools/include/tools/le_byteshift.h
28 +++ b/tools/include/tools/le_byteshift.h
30 #ifndef _TOOLS_LE_BYTESHIFT_H
31 #define _TOOLS_LE_BYTESHIFT_H
34 +#include "linux_types.h"
39 static inline uint16_t __get_unaligned_le16(const uint8_t *p)
41 +++ b/tools/include/tools/linux_types.h
43 +#ifndef __LINUX_TYPES_H
44 +#define __LINUX_TYPES_H
49 +typedef uint8_t __u8;
51 +typedef int16_t __s16;
52 +typedef uint16_t __u16;
54 +typedef int32_t __s32;
55 +typedef uint32_t __u32;
57 +typedef int64_t __s64;
58 +typedef uint64_t __u64;
61 --- a/tools/include/linux/types.h
62 +++ b/tools/include/linux/types.h
64 #define __SANE_USERSPACE_TYPES__ /* For PPC64, to get LL64 types */
68 +#include <tools/linux_types.h>
70 #include <asm/types.h>
71 #include <asm/posix_types.h>
76 @@ -51,7 +55,9 @@ typedef __s8 s8;
84 typedef __u16 __bitwise __le16;
85 typedef __u16 __bitwise __be16;
86 --- a/tools/perf/pmu-events/jevents.py
87 +++ b/tools/perf/pmu-events/jevents.py
88 @@ -684,6 +684,7 @@ def main() -> None:
89 #include "util/header.h"
95 struct compact_pmu_event {
96 --- a/tools/arch/x86/include/asm/insn.h
97 +++ b/tools/arch/x86/include/asm/insn.h
99 * Copyright (C) IBM Corporation, 2009
102 -#include <asm/byteorder.h>
103 /* insn_attr_t is defined in inat.h */
104 +#include <linux/kernel.h>
105 #include "inat.h" /* __ignore_sync_check__ */
107 #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
108 --- a/tools/arch/x86/include/asm/orc_types.h
109 +++ b/tools/arch/x86/include/asm/orc_types.h
111 #define ORC_TYPE_REGS_PARTIAL 4
114 -#include <asm/byteorder.h>
117 * This struct is more or less a vastly simplified version of the DWARF Call
122 -#if defined(__LITTLE_ENDIAN_BITFIELD)
123 +#if __BYTE_ORDER == __LITTLE_ENDIAN
128 -#elif defined(__BIG_ENDIAN_BITFIELD)
129 +#elif __BYTE_ORDER == __BIG_ENDIAN
133 --- a/tools/arch/x86/lib/insn.c
134 +++ b/tools/arch/x86/lib/insn.c
136 #include "../include/asm/insn.h" /* __ignore_sync_check__ */
137 #include "../include/asm-generic/unaligned.h" /* __ignore_sync_check__ */
140 #include <linux/errno.h>
144 #include <linux/kconfig.h>
146 #include "../include/asm/emulate_prefix.h" /* __ignore_sync_check__ */
147 --- a/tools/include/asm-generic/bitops/fls.h
148 +++ b/tools/include/asm-generic/bitops/fls.h
150 #ifndef _ASM_GENERIC_BITOPS_FLS_H_
151 #define _ASM_GENERIC_BITOPS_FLS_H_
156 * fls - find last (most-significant) bit set
157 * @x: the word to search
159 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
162 -static __always_inline int fls(unsigned int x)
163 +static __always_inline int __generic_fls(unsigned int x)
167 @@ -38,5 +40,6 @@ static __always_inline int fls(unsigned
171 +#define fls __generic_fls
173 #endif /* _ASM_GENERIC_BITOPS_FLS_H_ */
174 --- a/tools/include/asm-generic/bitsperlong.h
175 +++ b/tools/include/asm-generic/bitsperlong.h
178 #include <uapi/asm-generic/bitsperlong.h>
180 +#ifndef BITS_PER_LONG
181 #ifdef __SIZEOF_LONG__
182 #define BITS_PER_LONG (__CHAR_BIT__ * __SIZEOF_LONG__)
184 #define BITS_PER_LONG __WORDSIZE
188 #if BITS_PER_LONG != __BITS_PER_LONG
189 #error Inconsistent word size. Check asm/bitsperlong.h
190 --- a/tools/include/linux/rbtree.h
191 +++ b/tools/include/linux/rbtree.h
193 #define __TOOLS_LINUX_PERF_RBTREE_H
195 #include <linux/kernel.h>
196 -#include <linux/stddef.h>
199 unsigned long __rb_parent_color;
200 --- a/tools/objtool/Makefile
201 +++ b/tools/objtool/Makefile
202 @@ -40,7 +40,7 @@ include ../scripts/Makefile.arch
203 OBJTOOL_CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
205 # Always want host compilation.
206 -HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)"
207 +HOST_OVERRIDES := CC="$(HOSTCC) $(HOST_EXTRACFLAGS)" LD="$(HOSTLD)" AR="$(HOSTAR)"
211 @@ -43,6 +43,7 @@ BUILD_ORC := n
213 ifeq ($(SRCARCH),x86)
215 + CFLAGS += -DBUILD_ORC
219 --- a/tools/objtool/check.c
220 +++ b/tools/objtool/check.c
221 @@ -1164,11 +1164,12 @@ static int add_ignore_alternatives(struc
227 * Symbols that replace INSN_CALL_DYNAMIC, every (tail) call to such a symbol
228 * will be added to the .retpoline_sites section.
230 -__weak bool arch_is_retpoline(struct symbol *sym)
231 +bool arch_is_retpoline(struct symbol *sym)
235 @@ -1177,7 +1178,7 @@ __weak bool arch_is_retpoline(struct sym
236 * Symbols that replace INSN_RETURN, every (tail) call to such a symbol
237 * will be added to the .return_sites section.
239 -__weak bool arch_is_rethunk(struct symbol *sym)
240 +bool arch_is_rethunk(struct symbol *sym)
244 @@ -1186,10 +1187,11 @@ __weak bool arch_is_rethunk(struct symbo
245 * Symbols that are embedded inside other instructions, because sometimes crazy
246 * code exists. These are mostly ignored for validation purposes.
248 -__weak bool arch_is_embedded_insn(struct symbol *sym)
249 +bool arch_is_embedded_insn(struct symbol *sym)
255 static struct reloc *insn_reloc(struct objtool_file *file, struct instruction *insn)
257 --- a/tools/objtool/include/objtool/objtool.h
258 +++ b/tools/objtool/include/objtool/objtool.h
261 #include <objtool/elf.h>
264 #define __weak __attribute__((weak))
269 --- a/tools/objtool/orc_dump.c
270 +++ b/tools/objtool/orc_dump.c
275 -#include <asm/orc_types.h>
276 #include <objtool/objtool.h>
277 #include <objtool/warn.h>
278 #include <objtool/endianness.h>
279 +#include <asm/orc_types.h>
281 static const char *reg_name(unsigned int reg)
283 --- a/tools/objtool/orc_gen.c
284 +++ b/tools/objtool/orc_gen.c
288 #include <linux/objtool_types.h>
289 -#include <asm/orc_types.h>
291 #include <objtool/check.h>
292 #include <objtool/warn.h>
293 #include <objtool/endianness.h>
294 +#include <asm/orc_types.h>
296 static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi,
297 struct instruction *insn)
298 --- a/tools/objtool/special.c
299 +++ b/tools/objtool/special.c
300 @@ -54,9 +54,11 @@ struct special_entry entries[] = {
304 -void __weak arch_handle_alternative(unsigned short feature, struct special_alt *alt)
306 +void arch_handle_alternative(unsigned short feature, struct special_alt *alt)
311 static void reloc_to_sec_off(struct reloc *reloc, struct section **sec,
313 --- a/tools/objtool/weak.c
314 +++ b/tools/objtool/weak.c
319 -int __weak orc_dump(const char *_objname)
321 +int orc_dump(const char *_objname)
326 -int __weak orc_create(struct objtool_file *file)
327 +int orc_create(struct objtool_file *file)
332 --- a/tools/scripts/Makefile.include
333 +++ b/tools/scripts/Makefile.include
334 @@ -92,7 +92,7 @@ LLVM_OBJCOPY ?= llvm-objcopy
335 LLVM_STRIP ?= llvm-strip
337 ifeq ($(CC_NO_CLANG), 1)
338 -EXTRA_WARNINGS += -Wstrict-aliasing=3
339 +# EXTRA_WARNINGS += -Wstrict-aliasing=3
341 else ifneq ($(CROSS_COMPILE),)
342 # Allow userspace to override CLANG_CROSS_FLAGS to specify their own