blob: 0d8eb6fb9dc279a800b89bd55361304028bf03d3 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 48232d3d931c95953ce2ddfe7da7bb164aef6a73 Mon Sep 17 00:00:00 2001
2From: Felix Fietkau <nbd@nbd.name>
3Date: Fri, 7 Jul 2017 17:03:16 +0200
4Subject: fix portability of some includes files in tools/ used on the host
5
6Signed-off-by: Felix Fietkau <nbd@nbd.name>
7---
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
13
14--- a/tools/include/tools/be_byteshift.h
15+++ b/tools/include/tools/be_byteshift.h
16@@ -2,6 +2,10 @@
17 #ifndef _TOOLS_BE_BYTESHIFT_H
18 #define _TOOLS_BE_BYTESHIFT_H
19
20+#ifndef __linux__
21+#include "linux_types.h"
22+#endif
23+
24 #include <stdint.h>
25
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
29@@ -2,6 +2,10 @@
30 #ifndef _TOOLS_LE_BYTESHIFT_H
31 #define _TOOLS_LE_BYTESHIFT_H
32
33+#ifndef __linux__
34+#include "linux_types.h"
35+#endif
36+
37 #include <stdint.h>
38
39 static inline uint16_t __get_unaligned_le16(const uint8_t *p)
40--- /dev/null
41+++ b/tools/include/tools/linux_types.h
42@@ -0,0 +1,26 @@
43+#ifndef __LINUX_TYPES_H
44+#define __LINUX_TYPES_H
45+
46+#include <stdint.h>
47+
48+typedef int8_t __s8;
49+typedef uint8_t __u8;
50+typedef uint8_t __be8;
51+typedef uint8_t __le8;
52+
53+typedef int16_t __s16;
54+typedef uint16_t __u16;
55+typedef uint16_t __be16;
56+typedef uint16_t __le16;
57+
58+typedef int32_t __s32;
59+typedef uint32_t __u32;
60+typedef uint32_t __be32;
61+typedef uint32_t __le32;
62+
63+typedef int64_t __s64;
64+typedef uint64_t __u64;
65+typedef uint64_t __be64;
66+typedef uint64_t __le64;
67+
68+#endif
69--- a/tools/include/linux/types.h
70+++ b/tools/include/linux/types.h
71@@ -7,8 +7,12 @@
72 #include <stdint.h>
73
74 #define __SANE_USERSPACE_TYPES__ /* For PPC64, to get LL64 types */
75+#ifndef __linux__
76+#include <tools/linux_types.h>
77+#else
78 #include <asm/types.h>
79 #include <asm/posix_types.h>
80+#endif
81
82 struct page;
83 struct kmem_cache;
84--- a/tools/perf/pmu-events/jevents.c
85+++ b/tools/perf/pmu-events/jevents.c
86@@ -1,4 +1,6 @@
87+#ifdef __linux__
88 #define _XOPEN_SOURCE 500 /* needed for nftw() */
89+#endif
90 #define _GNU_SOURCE /* needed for asprintf() */
91
92 /* Parse event JSON files */
93@@ -35,6 +37,7 @@
94 #include <stdlib.h>
95 #include <errno.h>
96 #include <string.h>
97+#include <strings.h>
98 #include <ctype.h>
99 #include <unistd.h>
100 #include <stdarg.h>
101--- a/tools/perf/pmu-events/json.c
102+++ b/tools/perf/pmu-events/json.c
103@@ -38,7 +38,6 @@
104 #include <unistd.h>
105 #include "jsmn.h"
106 #include "json.h"
107-#include <linux/kernel.h>
108
109
110 static char *mapfile(const char *fn, size_t *size)