* [PATCH v2 1/2] tools include: Adopt byte ordering macros from byteorder/generic.h @ 2016-06-16 10:41 He Kuang 2016-06-16 10:41 ` [PATCH v2 2/2] tools include: Fix wrong macro definitions for cpu_to_le* for big endian He Kuang 2016-06-16 11:36 ` [PATCH v2 1/2] tools include: Adopt byte ordering macros from byteorder/generic.h Jiri Olsa 0 siblings, 2 replies; 4+ messages in thread From: He Kuang @ 2016-06-16 10:41 UTC (permalink / raw) To: peterz, mingo, acme, alexander.shishkin, hekuang, wangnan0, adrian.hunter, ak, maddy, bp, dsahern, linux, jolsa, namhyung, linux, yury.norov, mpe Cc: linux-kernel, linuxppc-dev From: Wang Nan <wangnan0@huawei.com> This patch adopts the macros for byte order conversion from "include/linux/byteorder/generic.h" to "tools/include/linux/byteorder/generic.h" tools/perf/MANIFEST is also updated for 'make perf-*-src-pkg'. Signed-off-by: Wang Nan <wangnan0@huawei.com> Signed-off-by: He Kuang <hekuang@huawei.com> --- tools/include/linux/byteorder/generic.h | 48 +++++++++++++++++++++++++++++++++ tools/perf/MANIFEST | 1 + 2 files changed, 49 insertions(+) create mode 100644 tools/include/linux/byteorder/generic.h diff --git a/tools/include/linux/byteorder/generic.h b/tools/include/linux/byteorder/generic.h new file mode 100644 index 0000000..41b4507 --- /dev/null +++ b/tools/include/linux/byteorder/generic.h @@ -0,0 +1,48 @@ +#ifndef _TOOLS_LINUX_BYTEORDER_GENERIC_H +#define _TOOLS_LINUX_BYTEORDER_GENERIC_H + +#include <endian.h> +#include <byteswap.h> + +#define cpu_to_le64 __cpu_to_le64 +#define le64_to_cpu __le64_to_cpu +#define cpu_to_le32 __cpu_to_le32 +#define le32_to_cpu __le32_to_cpu +#define cpu_to_le16 __cpu_to_le16 +#define le16_to_cpu __le16_to_cpu +#define cpu_to_be64 __cpu_to_be64 +#define be64_to_cpu __be64_to_cpu +#define cpu_to_be32 __cpu_to_be32 +#define be32_to_cpu __be32_to_cpu +#define cpu_to_be16 __cpu_to_be16 +#define be16_to_cpu __be16_to_cpu + +#if __BYTE_ORDER == __BIG_ENDIAN +#define __cpu_to_le16 bswap_16 +#define __cpu_to_le32 bswap_32 +#define __cpu_to_le64 bswap_64 +#define __le16_to_cpu bswap_16 +#define __le32_to_cpu bswap_32 +#define __le64_to_cpu bswap_64 +#define __cpu_to_be16 +#define __cpu_to_be32 +#define __cpu_to_be64 +#define __be16_to_cpu +#define __be32_to_cpu +#define __be64_to_cpu +#else +#define __cpu_to_le16 +#define __cpu_to_le32 +#define __cpu_to_le64 +#define __le16_to_cpu +#define __le32_to_cpu +#define __le64_to_cpu +#define __cpu_to_be16 bswap_16 +#define __cpu_to_be32 bswap_32 +#define __cpu_to_be64 bswap_64 +#define __be16_to_cpu bswap_16 +#define __be32_to_cpu bswap_32 +#define __be64_to_cpu bswap_64 +#endif + +#endif /* _TOOLS_LINUX_BYTEORDER_GENERIC_H */ diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST index 8c8c6b9..80ac3d4 100644 --- a/tools/perf/MANIFEST +++ b/tools/perf/MANIFEST @@ -46,6 +46,7 @@ tools/include/asm-generic/bitops/hweight.h tools/include/asm-generic/bitops.h tools/include/linux/atomic.h tools/include/linux/bitops.h +tools/include/linux/byteorder/generic.h tools/include/linux/compiler.h tools/include/linux/filter.h tools/include/linux/hash.h -- 1.8.5.2 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] tools include: Fix wrong macro definitions for cpu_to_le* for big endian 2016-06-16 10:41 [PATCH v2 1/2] tools include: Adopt byte ordering macros from byteorder/generic.h He Kuang @ 2016-06-16 10:41 ` He Kuang 2016-06-16 11:36 ` [PATCH v2 1/2] tools include: Adopt byte ordering macros from byteorder/generic.h Jiri Olsa 1 sibling, 0 replies; 4+ messages in thread From: He Kuang @ 2016-06-16 10:41 UTC (permalink / raw) To: peterz, mingo, acme, alexander.shishkin, hekuang, wangnan0, adrian.hunter, ak, maddy, bp, dsahern, linux, jolsa, namhyung, linux, yury.norov, mpe Cc: linux-kernel, linuxppc-dev From: Wang Nan <wangnan0@huawei.com> The cpu_to_le* macros in kernel.h are defined without considering endianese. This patch includes "byteoder/generic.h" instead to fix the bug, and removes redundant definitions of those macros in intel-bts.c and intel-pt-pkt-decoder.c. Signed-off-by: Wang Nan <wangnan0@huawei.com> Signed-off-by: He Kuang <hekuang@huawei.com> --- tools/include/linux/kernel.h | 7 +------ tools/perf/util/intel-bts.c | 5 ----- tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c | 7 +------ 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h index 76df535..ccf8daf 100644 --- a/tools/include/linux/kernel.h +++ b/tools/include/linux/kernel.h @@ -63,12 +63,7 @@ #endif #endif -/* - * Both need more care to handle endianness - * (Don't use bitmap_copy_le() for now) - */ -#define cpu_to_le64(x) (x) -#define cpu_to_le32(x) (x) +#include <linux/byteorder/generic.h> static inline int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 9df9960..0e632c4 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -40,11 +40,6 @@ #define INTEL_BTS_ERR_NOINSN 5 #define INTEL_BTS_ERR_LOST 9 -#if __BYTE_ORDER == __BIG_ENDIAN -#define le64_to_cpu bswap_64 -#else -#define le64_to_cpu -#endif struct intel_bts { struct auxtrace auxtrace; diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c index b1257c8..9a428f7 100644 --- a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c @@ -17,6 +17,7 @@ #include <string.h> #include <endian.h> #include <byteswap.h> +#include <linux/byteorder/generic.h> #include "intel-pt-pkt-decoder.h" @@ -27,17 +28,11 @@ #define NR_FLAG BIT63 #if __BYTE_ORDER == __BIG_ENDIAN -#define le16_to_cpu bswap_16 -#define le32_to_cpu bswap_32 -#define le64_to_cpu bswap_64 #define memcpy_le64(d, s, n) do { \ memcpy((d), (s), (n)); \ *(d) = le64_to_cpu(*(d)); \ } while (0) #else -#define le16_to_cpu -#define le32_to_cpu -#define le64_to_cpu #define memcpy_le64 memcpy #endif -- 1.8.5.2 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] tools include: Adopt byte ordering macros from byteorder/generic.h 2016-06-16 10:41 [PATCH v2 1/2] tools include: Adopt byte ordering macros from byteorder/generic.h He Kuang 2016-06-16 10:41 ` [PATCH v2 2/2] tools include: Fix wrong macro definitions for cpu_to_le* for big endian He Kuang @ 2016-06-16 11:36 ` Jiri Olsa 2016-06-17 1:50 ` Hekuang 1 sibling, 1 reply; 4+ messages in thread From: Jiri Olsa @ 2016-06-16 11:36 UTC (permalink / raw) To: He Kuang Cc: peterz, mingo, acme, alexander.shishkin, wangnan0, adrian.hunter, ak, maddy, bp, dsahern, linux, namhyung, linux, yury.norov, mpe, linux-kernel, linuxppc-dev On Thu, Jun 16, 2016 at 10:41:31AM +0000, He Kuang wrote: > From: Wang Nan <wangnan0@huawei.com> > > This patch adopts the macros for byte order conversion from > "include/linux/byteorder/generic.h" to > "tools/include/linux/byteorder/generic.h" > > tools/perf/MANIFEST is also updated for 'make perf-*-src-pkg'. other than explanation for the kbuild test robot email: http://marc.info/?l=linux-kernel&m=146605819924421&w=2 it looks ok.. jirka ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] tools include: Adopt byte ordering macros from byteorder/generic.h 2016-06-16 11:36 ` [PATCH v2 1/2] tools include: Adopt byte ordering macros from byteorder/generic.h Jiri Olsa @ 2016-06-17 1:50 ` Hekuang 0 siblings, 0 replies; 4+ messages in thread From: Hekuang @ 2016-06-17 1:50 UTC (permalink / raw) To: Jiri Olsa Cc: peterz, mingo, acme, alexander.shishkin, wangnan0, adrian.hunter, ak, maddy, bp, dsahern, linux, namhyung, linux, yury.norov, mpe, linux-kernel, linuxppc-dev 在 2016/6/16 19:36, Jiri Olsa 写道: > On Thu, Jun 16, 2016 at 10:41:31AM +0000, He Kuang wrote: >> From: Wang Nan <wangnan0@huawei.com> >> >> This patch adopts the macros for byte order conversion from >> "include/linux/byteorder/generic.h" to >> "tools/include/linux/byteorder/generic.h" >> >> tools/perf/MANIFEST is also updated for 'make perf-*-src-pkg'. > other than explanation for the kbuild test robot email: > http://marc.info/?l=linux-kernel&m=146605819924421&w=2 I think that's because of yesterday I sent these two patches separately while the second one deponds on the first. Thank you. > > it looks ok.. > > jirka > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-06-17 1:55 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-06-16 10:41 [PATCH v2 1/2] tools include: Adopt byte ordering macros from byteorder/generic.h He Kuang 2016-06-16 10:41 ` [PATCH v2 2/2] tools include: Fix wrong macro definitions for cpu_to_le* for big endian He Kuang 2016-06-16 11:36 ` [PATCH v2 1/2] tools include: Adopt byte ordering macros from byteorder/generic.h Jiri Olsa 2016-06-17 1:50 ` Hekuang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).