Skip to content

Commit 4e88118

Browse files
iii-iacmel
authored andcommitted
perf tools: Use __BYTE_ORDER__
Switch from the libc-defined __BYTE_ORDER to the compiler-defined __BYTE_ORDER__ in order to make endianness detection more robust, like it was done for libbpf. Signed-off-by: Ilya Leoshkevich <[email protected]> Suggested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Thomas Richter <[email protected]> Cc: Vasily Gorbik <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent b3a018f commit 4e88118

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "arm-spe-pkt-decoder.h"
1515

16-
#if __BYTE_ORDER == __BIG_ENDIAN
16+
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1717
#define le16_to_cpu bswap_16
1818
#define le32_to_cpu bswap_32
1919
#define le64_to_cpu bswap_64

tools/perf/util/data-convert-bt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ static struct bt_ctf_field_type *create_int_type(int size, bool sign, bool hex)
14371437
bt_ctf_field_type_integer_set_base(type, BT_CTF_INTEGER_BASE_HEXADECIMAL))
14381438
goto err;
14391439

1440-
#if __BYTE_ORDER == __BIG_ENDIAN
1440+
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
14411441
bt_ctf_field_type_set_byte_order(type, BT_CTF_BYTE_ORDER_BIG_ENDIAN);
14421442
#else
14431443
bt_ctf_field_type_set_byte_order(type, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN);

tools/perf/util/genelf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int jit_add_debug_info(Elf *e, uint64_t code_addr, void *debug, int nr_debug_ent
4242
#error "unsupported architecture"
4343
#endif
4444

45-
#if __BYTE_ORDER == __BIG_ENDIAN
45+
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
4646
#define GEN_ELF_ENDIAN ELFDATA2MSB
4747
#else
4848
#define GEN_ELF_ENDIAN ELFDATA2LSB

tools/perf/util/intel-bts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define INTEL_BTS_ERR_NOINSN 5
3636
#define INTEL_BTS_ERR_LOST 9
3737

38-
#if __BYTE_ORDER == __BIG_ENDIAN
38+
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
3939
#define le64_to_cpu bswap_64
4040
#else
4141
#define le64_to_cpu

tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static void intel_pt_insn_decoder(struct insn *insn,
143143

144144
if (branch == INTEL_PT_BR_CONDITIONAL ||
145145
branch == INTEL_PT_BR_UNCONDITIONAL) {
146-
#if __BYTE_ORDER == __BIG_ENDIAN
146+
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
147147
switch (insn->immediate.nbytes) {
148148
case 1:
149149
intel_pt_insn->rel = insn->immediate.value;

tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#define BIT63 ((uint64_t)1 << 63)
1818

19-
#if __BYTE_ORDER == __BIG_ENDIAN
19+
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
2020
#define le16_to_cpu bswap_16
2121
#define le32_to_cpu bswap_32
2222
#define le64_to_cpu bswap_64

tools/perf/util/s390-cpumsf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static bool s390_cpumsf_basic_show(const char *color, size_t pos,
244244
struct hws_basic_entry *basicp)
245245
{
246246
struct hws_basic_entry *basic = basicp;
247-
#if __BYTE_ORDER == __LITTLE_ENDIAN
247+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
248248
struct hws_basic_entry local;
249249
unsigned long long word = be64toh(*(unsigned long long *)basicp);
250250

@@ -288,7 +288,7 @@ static bool s390_cpumsf_diag_show(const char *color, size_t pos,
288288
struct hws_diag_entry *diagp)
289289
{
290290
struct hws_diag_entry *diag = diagp;
291-
#if __BYTE_ORDER == __LITTLE_ENDIAN
291+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
292292
struct hws_diag_entry local;
293293
unsigned long long word = be64toh(*(unsigned long long *)diagp);
294294

@@ -322,7 +322,7 @@ static unsigned long long trailer_timestamp(struct hws_trailer_entry *te,
322322
static bool s390_cpumsf_trailer_show(const char *color, size_t pos,
323323
struct hws_trailer_entry *te)
324324
{
325-
#if __BYTE_ORDER == __LITTLE_ENDIAN
325+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
326326
struct hws_trailer_entry local;
327327
const unsigned long long flags = be64toh(te->flags);
328328

@@ -552,7 +552,7 @@ static unsigned long long get_trailer_time(const unsigned char *buf)
552552
te = (struct hws_trailer_entry *)(buf + S390_CPUMSF_PAGESZ
553553
- sizeof(*te));
554554

555-
#if __BYTE_ORDER == __LITTLE_ENDIAN
555+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
556556
clock_base = be64toh(te->progusage[0]) >> 63 & 0x1;
557557
progusage2 = be64toh(te->progusage[1]);
558558
#else

0 commit comments

Comments
 (0)