DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: david.hunt@intel.com
Cc: dev@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [RFC PATCH 3/4] examples/vm_power_manager: always compile all C files
Date: Fri,  3 May 2019 15:09:00 +0100	[thread overview]
Message-ID: <20190503140901.59064-4-bruce.richardson@intel.com> (raw)
Message-ID: <20190503140900.jfn7MWMcDwIAiatZq4wuGkVnvQqm80n9VJErRSKygeg@z> (raw)
In-Reply-To: <20190503140901.59064-1-bruce.richardson@intel.com>

Rather than having an "if" statement in the makefile to select one of two
files to build, we can put #ifdefs into the C files themselves so that all
files are always built.

This is a better approach as the makefile-based approach relies on having
the DPDK build system with all it's config settings available. When
building using info from a pkg-config file, this build configuration
information is not going to be available to the makefile - though it will
be available to the preprocessor through rte_config.h header.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 examples/vm_power_manager/Makefile          |  3 ---
 examples/vm_power_manager/meson.build       | 16 ++++++++--------
 examples/vm_power_manager/oob_monitor_nop.c |  4 ++++
 examples/vm_power_manager/oob_monitor_x86.c |  4 ++++
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/examples/vm_power_manager/Makefile b/examples/vm_power_manager/Makefile
index d93f900f7..6e573916a 100644
--- a/examples/vm_power_manager/Makefile
+++ b/examples/vm_power_manager/Makefile
@@ -20,11 +20,8 @@ APP = vm_power_mgr
 # all source are stored in SRCS-y
 SRCS-y := main.c vm_power_cli.c power_manager.c channel_manager.c
 SRCS-y += channel_monitor.c parse.c
-ifeq ($(CONFIG_RTE_ARCH_X86_64),y)
 SRCS-y += oob_monitor_x86.c
-else
 SRCS-y += oob_monitor_nop.c
-endif
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
diff --git a/examples/vm_power_manager/meson.build b/examples/vm_power_manager/meson.build
index f98445bc6..384c778ef 100644
--- a/examples/vm_power_manager/meson.build
+++ b/examples/vm_power_manager/meson.build
@@ -22,16 +22,16 @@ deps += ['power']
 
 
 sources = files(
-	'channel_manager.c', 'channel_monitor.c', 'main.c', 'parse.c', 'power_manager.c', 'vm_power_cli.c'
+	'channel_manager.c',
+	'channel_monitor.c',
+	'main.c',
+	'oob_monitor_nop.c',
+	'oob_monitor_x86.c',
+	'parse.c',
+	'power_manager.c',
+	'vm_power_cli.c'
 )
 
-# If we're on X86, pull in the x86 code for the branch monitor algo.
-if dpdk_conf.has('RTE_ARCH_X86_64')
-	sources += files('oob_monitor_x86.c')
-else
-	sources += files('oob_monitor_nop.c')
-endif
-
 opt_dep = cc.find_library('virt', required : false)
 build = opt_dep.found()
 ext_deps += opt_dep
diff --git a/examples/vm_power_manager/oob_monitor_nop.c b/examples/vm_power_manager/oob_monitor_nop.c
index 7e7b8bc14..90daa7e9b 100644
--- a/examples/vm_power_manager/oob_monitor_nop.c
+++ b/examples/vm_power_manager/oob_monitor_nop.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#ifndef RTE_ARCH_X86_64 /* X86_64 has separate implementation in another file */
+
 #include "oob_monitor.h"
 
 void branch_monitor_exit(void)
@@ -36,3 +38,5 @@ void
 run_branch_monitor(void)
 {
 }
+
+#endif
diff --git a/examples/vm_power_manager/oob_monitor_x86.c b/examples/vm_power_manager/oob_monitor_x86.c
index ebd96b205..f41bba6ab 100644
--- a/examples/vm_power_manager/oob_monitor_x86.c
+++ b/examples/vm_power_manager/oob_monitor_x86.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#ifdef RTE_ARCH_X86_64 /* this file is only for X86_64 */
+
 #include <unistd.h>
 #include <fcntl.h>
 #include <rte_log.h>
@@ -269,3 +271,5 @@ run_branch_monitor(void)
 		}
 	}
 }
+
+#endif /* RTE_ARCH_X86_64 */
-- 
2.20.1


  parent reply	other threads:[~2019-05-03 14:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-03 14:08 [dpdk-dev] [RFC PATCH 0/4] allow vm_power_manager to build using pkg-config Bruce Richardson
2019-05-03 14:08 ` Bruce Richardson
2019-05-03 14:08 ` [dpdk-dev] [RFC PATCH 1/4] power: make channel commands header public Bruce Richardson
2019-05-03 14:08   ` Bruce Richardson
2019-05-03 14:08 ` [dpdk-dev] [RFC PATCH 2/4] power: add namespace prefix to public header elements Bruce Richardson
2019-05-03 14:08   ` Bruce Richardson
2019-05-03 14:09 ` Bruce Richardson [this message]
2019-05-03 14:09   ` [dpdk-dev] [RFC PATCH 3/4] examples/vm_power_manager: always compile all C files Bruce Richardson
2019-05-03 14:09 ` [dpdk-dev] [RFC PATCH 4/4] examples/vm_power_manager: support build using pkg-config Bruce Richardson
2019-05-03 14:09   ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190503140901.59064-4-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).