Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <iii@linux.ibm.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: https://lore.kernel.org/r/20211104132311.984703-1-iii@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ilya Leoshkevich and committed by
Arnaldo Carvalho de Melo
4e88118c b3a018fc

+10 -10
+1 -1
tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
··· 13 13 14 14 #include "arm-spe-pkt-decoder.h" 15 15 16 - #if __BYTE_ORDER == __BIG_ENDIAN 16 + #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 17 17 #define le16_to_cpu bswap_16 18 18 #define le32_to_cpu bswap_32 19 19 #define le64_to_cpu bswap_64
+1 -1
tools/perf/util/data-convert-bt.c
··· 1437 1437 bt_ctf_field_type_integer_set_base(type, BT_CTF_INTEGER_BASE_HEXADECIMAL)) 1438 1438 goto err; 1439 1439 1440 - #if __BYTE_ORDER == __BIG_ENDIAN 1440 + #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 1441 1441 bt_ctf_field_type_set_byte_order(type, BT_CTF_BYTE_ORDER_BIG_ENDIAN); 1442 1442 #else 1443 1443 bt_ctf_field_type_set_byte_order(type, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN);
+1 -1
tools/perf/util/genelf.h
··· 42 42 #error "unsupported architecture" 43 43 #endif 44 44 45 - #if __BYTE_ORDER == __BIG_ENDIAN 45 + #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 46 46 #define GEN_ELF_ENDIAN ELFDATA2MSB 47 47 #else 48 48 #define GEN_ELF_ENDIAN ELFDATA2LSB
+1 -1
tools/perf/util/intel-bts.c
··· 35 35 #define INTEL_BTS_ERR_NOINSN 5 36 36 #define INTEL_BTS_ERR_LOST 9 37 37 38 - #if __BYTE_ORDER == __BIG_ENDIAN 38 + #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 39 39 #define le64_to_cpu bswap_64 40 40 #else 41 41 #define le64_to_cpu
+1 -1
tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
··· 143 143 144 144 if (branch == INTEL_PT_BR_CONDITIONAL || 145 145 branch == INTEL_PT_BR_UNCONDITIONAL) { 146 - #if __BYTE_ORDER == __BIG_ENDIAN 146 + #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 147 147 switch (insn->immediate.nbytes) { 148 148 case 1: 149 149 intel_pt_insn->rel = insn->immediate.value;
+1 -1
tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
··· 16 16 17 17 #define BIT63 ((uint64_t)1 << 63) 18 18 19 - #if __BYTE_ORDER == __BIG_ENDIAN 19 + #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 20 20 #define le16_to_cpu bswap_16 21 21 #define le32_to_cpu bswap_32 22 22 #define le64_to_cpu bswap_64
+4 -4
tools/perf/util/s390-cpumsf.c
··· 244 244 struct hws_basic_entry *basicp) 245 245 { 246 246 struct hws_basic_entry *basic = basicp; 247 - #if __BYTE_ORDER == __LITTLE_ENDIAN 247 + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 248 248 struct hws_basic_entry local; 249 249 unsigned long long word = be64toh(*(unsigned long long *)basicp); 250 250 ··· 288 288 struct hws_diag_entry *diagp) 289 289 { 290 290 struct hws_diag_entry *diag = diagp; 291 - #if __BYTE_ORDER == __LITTLE_ENDIAN 291 + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 292 292 struct hws_diag_entry local; 293 293 unsigned long long word = be64toh(*(unsigned long long *)diagp); 294 294 ··· 322 322 static bool s390_cpumsf_trailer_show(const char *color, size_t pos, 323 323 struct hws_trailer_entry *te) 324 324 { 325 - #if __BYTE_ORDER == __LITTLE_ENDIAN 325 + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 326 326 struct hws_trailer_entry local; 327 327 const unsigned long long flags = be64toh(te->flags); 328 328 ··· 552 552 te = (struct hws_trailer_entry *)(buf + S390_CPUMSF_PAGESZ 553 553 - sizeof(*te)); 554 554 555 - #if __BYTE_ORDER == __LITTLE_ENDIAN 555 + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 556 556 clock_base = be64toh(te->progusage[0]) >> 63 & 0x1; 557 557 progusage2 = be64toh(te->progusage[1]); 558 558 #else