[PATCH] gprofng: Use __x86_64__ instead of __x86_64
Vladimir Mezentsev
vladimir.mezentsev@oracle.com
Fri May 30 21:32:51 GMT 2025
On 5/30/25 13:07, Andrew Pinski wrote:
> On Fri, May 30, 2025 at 1:02 PM Vladimir Mezentsev via Binutils
> <binutils@sourceware.org> wrote:
>>
>> Can we simply define __x86_64 in common/config.h.in ? Like this:
>> #ifndef __x86_64
>> #define __x86_64 __x86_64__
>> #endif
> Well config.h.in is generated via autoconf so I am not totally sure if
> that would work.
> There are already some uses of __x86_64__ in the same source files
> where __x86_64 is used when I was changing them.
> So we should at least fix that inconsistency. My patch fixes the
> inconsistency there too.
OK.
Thanks for the fixes gprofng.
Please push your fix to the master branch.
-Vladimir
>
> Thanks,
> Andrew
>
>> -Vladimir
>>
>>
>> On 5/30/25 11:55, Andrew Pinski wrote:
>>
>> With some compilers, only __x86_64__ is defined so use that
>> instead of __x86_64.
>>
>> gprofng/ChangeLog
>> 2025-05-30 Andrew Pinski <quic_apinski@quicinc.com>
>> * common/core_pcbe.c: s/__x86_64/__x86_64__/.
>> * common/cpu_frequency.h: Likewise.
>> * common/cpuid.c: Likewise.
>> * common/gp-defs.h: Likewise.
>> * common/hwctable.c: Likewise.
>> * libcollector/libcol-i386-dis.c: Likewise.
>> * libcollector/libcol_util.h: Likewise.
>>
>> Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
>> ---
>> gprofng/common/core_pcbe.c | 4 ++--
>> gprofng/common/cpu_frequency.h | 8 ++++----
>> gprofng/common/cpuid.c | 6 +++---
>> gprofng/common/gp-defs.h | 4 ++--
>> gprofng/common/hwctable.c | 8 ++++----
>> gprofng/libcollector/libcol-i386-dis.c | 2 +-
>> gprofng/libcollector/libcol_util.h | 2 +-
>> 7 files changed, 17 insertions(+), 17 deletions(-)
>>
>> diff --git a/gprofng/common/core_pcbe.c b/gprofng/common/core_pcbe.c
>> index 107a9941602..14080abbba8 100644
>> --- a/gprofng/common/core_pcbe.c
>> +++ b/gprofng/common/core_pcbe.c
>> @@ -2759,7 +2759,7 @@ core_pcbe_init (void)
>> return -1;
>> }
>>
>> -#if defined(__i386__) || defined(__x86_64)
>> +#if defined(__i386__) || defined(__x86_64__)
>> /* No Architectural Performance Monitoring Leaf returned by CPUID */
>> if (get_cpuid_info ()->cpi_maxeax < 0xa)
>> return (-1);
>> @@ -2918,7 +2918,7 @@ core_pcbe_cpuref (void)
>> {
>> #if defined(__aarch64__) || defined(__riscv)
>> return "";
>> -#elif defined(__i386__) || defined(__x86_64)
>> +#elif defined(__i386__) || defined(__x86_64__)
>> switch (cpuid_getmodel ())
>> {
>> case 60: /* Haswell */
>> diff --git a/gprofng/common/cpu_frequency.h b/gprofng/common/cpu_frequency.h
>> index 2371863307c..c6979c45e1f 100644
>> --- a/gprofng/common/cpu_frequency.h
>> +++ b/gprofng/common/cpu_frequency.h
>> @@ -41,7 +41,7 @@ extern "C"
>> #define COL_CPUFREQ_SCALING 0x0001
>> #define COL_CPUFREQ_TURBO 0x0002
>>
>> -#if defined(__i386__) || defined(__x86_64)
>> +#if defined(__i386__) || defined(__x86_64__)
>> // XXXX This is a rough table to estimate frequency increment due to intel turbo boost.
>> // CPU with different stepping and different core number have different turbo increment.
>> // It is used internally here, and is not implemented on SPARC
>> @@ -129,7 +129,7 @@ extern "C"
>> {
>> char temp[1024];
>> int cpu = -1;
>> -#if defined(__i386__) || defined(__x86_64)
>> +#if defined(__i386__) || defined(__x86_64__)
>> int model = -1;
>> int family = -1;
>> #endif
>> @@ -140,7 +140,7 @@ extern "C"
>> char *val = strchr (temp, ':');
>> cpu = val ? atoi (val + 1) : -1;
>> }
>> -#if defined(__i386__) || defined(__x86_64)
>> +#if defined(__i386__) || defined(__x86_64__)
>> else if (strncmp (temp, "model", strlen ("model")) == 0
>> && strstr (temp, "name") == 0)
>> {
>> @@ -241,7 +241,7 @@ extern "C"
>> frequency_scaling = 1;
>> if (tmpmhz > 1000)
>> {
>> -#if defined(__i386__) || defined(__x86_64)
>> +#if defined(__i386__) || defined(__x86_64__)
>> if (family == 6)
>> {
>> // test turbo mode
>> diff --git a/gprofng/common/cpuid.c b/gprofng/common/cpuid.c
>> index 9e45233a412..e40404c645a 100644
>> --- a/gprofng/common/cpuid.c
>> +++ b/gprofng/common/cpuid.c
>> @@ -18,7 +18,7 @@
>> Foundation, 51 Franklin Street - Fifth Floor, Boston,
>> MA 02110-1301, USA. */
>>
>> -#if defined(__i386__) || defined(__x86_64)
>> +#if defined(__i386__) || defined(__x86_64__)
>> #include <cpuid.h> /* GCC-provided */
>> #elif defined(__aarch64__)
>> #if !defined(ATTRIBUTE_UNUSED)
>> @@ -91,7 +91,7 @@ typedef struct
>> } cpuid_info_t;
>>
>>
>> -#if defined(__i386__) || defined(__x86_64)
>> +#if defined(__i386__) || defined(__x86_64__)
>> static uint_t
>> cpuid_vendorstr_to_vendorcode (char *vendorstr)
>> {
>> @@ -151,7 +151,7 @@ get_cpuid_info ()
>> Tprintf (DBG_LT0, "cpuid.c:%d read_cpuid_id() MIDR_EL1==0x%016x cpi_vendor=%d cpi_model=%d\n",
>> __LINE__, (unsigned int) reg, cpi->cpi_vendor, cpi->cpi_model);
>>
>> -#elif defined(__i386__) || defined(__x86_64)
>> +#elif defined(__i386__) || defined(__x86_64__)
>> cpuid_regs_t regs;
>> my_cpuid (0, ®s);
>> cpi->cpi_maxeax = regs.eax;
>> diff --git a/gprofng/common/gp-defs.h b/gprofng/common/gp-defs.h
>> index d6c94457fb9..4b5d6fa334f 100644
>> --- a/gprofng/common/gp-defs.h
>> +++ b/gprofng/common/gp-defs.h
>> @@ -42,7 +42,7 @@
>>
>> #if defined(sparc) || defined(__sparcv9)
>> #define ARCH_SPARC 1
>> -#elif defined(__i386__) || defined(__x86_64)
>> +#elif defined(__i386__) || defined(__x86_64__)
>> #define ARCH_Intel 1
>> #elif defined(__aarch64__)
>> #define ARCH_Aarch64 1
>> @@ -52,7 +52,7 @@
>> #error "Undefined platform"
>> #endif
>>
>> -#if defined(__sparcv9) || defined(__x86_64) || defined(__aarch64__) || defined(__riscv)
>> +#if defined(__sparcv9) || defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)
>> #define WSIZE_64 1
>> #else
>> #define WSIZE_32 1
>> diff --git a/gprofng/common/hwctable.c b/gprofng/common/hwctable.c
>> index 4b6f2a9e574..1ce365a5904 100644
>> --- a/gprofng/common/hwctable.c
>> +++ b/gprofng/common/hwctable.c
>> @@ -243,7 +243,7 @@ static Hwcentry papi_generic_list[] = {
>> {NULL, NULL, 0, NULL, 0, 0, 0, 0, ABST_NONE}
>> };
>>
>> -#if defined(__i386__) || defined(__x86_64)
>> +#if defined(__i386__) || defined(__x86_64__)
>> /* Kernel profiling pseudo-chip, OBSOLETE (To support 12.3 and earlier, TBR) */
>> static Hwcentry kproflist[] = {
>> {"kcycles", "kcycles", 0, STXT ("KCPU Cycles"), PRELOADS_5, 1, ABST_NONE},
>> @@ -1216,7 +1216,7 @@ static Hwcentry amd_15h[] = {
>> {"insts1", "EX_retired_instr_w_excp_intr", 1, NULL, PRELOADS_8, 0, ABST_NONE},
>> {NULL, NULL, 0, NULL, 0, 0, 0, 0, ABST_NONE}
>> };
>> -#endif /* __i386__ or __x86_64 */
>> +#endif /* __i386__ or __x86_64__ */
>>
>> #define INIT_HWC(nm, mtr, cfg, ty) .name = (nm), .metric = (mtr), \
>> .config = (cfg), .type = ty, .use_perf_event_type = 1, \
>> @@ -1303,7 +1303,7 @@ static Hwcentry generic_list[] = {
>> {NULL, NULL, 0, NULL, 0, 0, 0, 0, ABST_NONE}
>> };
>>
>> -#if defined(__i386__) || defined(__x86_64)
>> +#if defined(__i386__) || defined(__x86_64__)
>> #include "hwc_amd_zen3.h"
>> #include "hwc_amd_zen4.h"
>> #include "hwc_intel_icelake.h"
>> @@ -1332,7 +1332,7 @@ typedef struct
>> * If the string is not formatted that way, -h hi and -h lo will fail
>> */
>> static cpu_list_t cputabs[] = {
>> -#if defined(__i386__) || defined(__x86_64)
>> +#if defined(__i386__) || defined(__x86_64__)
>> {CPC_PENTIUM_PRO_MMX, pentiumIIlist, {"insts", 0}},
>> {CPC_PENTIUM_PRO, pentiumIIIlist, {"insts", 0}},
>> {CPC_PENTIUM_4, pentium4, {"insts", 0}},
>> diff --git a/gprofng/libcollector/libcol-i386-dis.c b/gprofng/libcollector/libcol-i386-dis.c
>> index 81ca3667c50..15c91f7ac5d 100644
>> --- a/gprofng/libcollector/libcol-i386-dis.c
>> +++ b/gprofng/libcollector/libcol-i386-dis.c
>> @@ -18,7 +18,7 @@
>> Foundation, 51 Franklin Street - Fifth Floor, Boston,
>> MA 02110-1301, USA. */
>>
>> -#if defined(__i386__) || defined(__x86_64)
>> +#if defined(__i386__) || defined(__x86_64__)
>> #include "opcodes/i386-dis.c"
>>
>> #undef _
>> diff --git a/gprofng/libcollector/libcol_util.h b/gprofng/libcollector/libcol_util.h
>> index afe75f8199a..08e34a180a9 100644
>> --- a/gprofng/libcollector/libcol_util.h
>> +++ b/gprofng/libcollector/libcol_util.h
>> @@ -183,7 +183,7 @@ static __attribute__ ((always_inline)) inline void *
>> __collector_getpc ()
>> {
>> void *r;
>> -#if defined(__x86_64)
>> +#if defined(__x86_64__)
>> __asm__ __volatile__("lea (%%rip), %0" : "=r" (r));
>> #else
>> __asm__ __volatile__("call 1f \n"
>>
>>
More information about the Binutils
mailing list