[PATCH 1/3] Factor out multiple definitions of PPC64_ARCH and avoid non-portable defined use
William Cohen <[email protected]>
| Newsgroups | gmane.linux.oprofile |
|---|---|
| Message-ID | <[email protected]> |
When compiling oprofile with preliminary versions of GCC 7 the compiler would warn about PPC64_ARCH define non-portable use of "defined". The OProfile make file compiler flags settings treats warning as errors and stops the build. The PPC64_ARCH was defined in three different places. They have been consolidated into a single define and the PPC64_ARCH define has been rewritten in to avoid the non-portable use Signed-off-by: William Cohen <[email protected]> --- libop/op_cpu_type.c | 6 ------ libop/op_cpu_type.h | 8 ++++++++ libpe_utils/op_pe_utils.h | 6 ------ libperf_events/operf_utils.h | 7 +------ 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/libop/op_cpu_type.c b/libop/op_cpu_type.c index 0e1f6e4..3d3c9c8 100644 --- a/libop/op_cpu_type.c +++ b/libop/op_cpu_type.c @@ -27,12 +27,6 @@ #include "op_cpu_type.h" #include "op_hw_specific.h" -/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro - * is defined for both ppc64 and ppc32 architectures, so we must further qualify by - * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64. - */ -#define PPC64_ARCH (HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__))) - struct cpu_descr { char const * pretty; char const * name; diff --git a/libop/op_cpu_type.h b/libop/op_cpu_type.h index 8d2badd..78eb9bc 100644 --- a/libop/op_cpu_type.h +++ b/libop/op_cpu_type.h @@ -108,6 +108,14 @@ typedef enum { MAX_CPU_TYPE } op_cpu; +/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro + * is defined for both ppc64 and ppc32 architectures, so we must further qualify by + * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64. + */ +#if defined(HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__))) +#define PPC64_ARCH 1 +#endif + /** * the CPU lowest common denominator * diff --git a/libpe_utils/op_pe_utils.h b/libpe_utils/op_pe_utils.h index 3a4eb38..a790d91 100644 --- a/libpe_utils/op_pe_utils.h +++ b/libpe_utils/op_pe_utils.h @@ -26,12 +26,6 @@ #define OP_MAX_EVENTS 24 #define CALLGRAPH_MIN_COUNT_SCALE 15 -/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro - * is defined for both ppc64 and ppc32 architectures, so we must further qualify by - * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64. - */ -#define PPC64_ARCH (HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__))) - // Candidates for refactoring of operf namespace op_pe_utils { diff --git a/libperf_events/operf_utils.h b/libperf_events/operf_utils.h index 32954cc..8afdbc2 100644 --- a/libperf_events/operf_utils.h +++ b/libperf_events/operf_utils.h @@ -21,6 +21,7 @@ #include "config.h" #include "op_config.h" #include "op_types.h" +#include "op_cpu_type.h" #include "operf_event.h" #include <signal.h> @@ -47,12 +48,6 @@ extern bool throttled; #define OP_MAX_EVENTS 24 -/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro - * is defined for both ppc64 and ppc32 architectures, so we must further qualify by - * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64. - */ -#define PPC64_ARCH (HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__))) - # define likely(x) __builtin_expect(!!(x), 1) # define unlikely(x) __builtin_expect(!!(x), 0) -- 2.9.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot