From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: pablo.de.lara.guarch@intel.com, declan.doherty@intel.com,
remy.horton@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 1/3] eal: fix keep alive header for C++
Date: Tue, 16 Feb 2016 08:14:23 +0100 [thread overview]
Message-ID: <1455606865-22680-2-git-send-email-thomas.monjalon@6wind.com> (raw)
In-Reply-To: <1455606865-22680-1-git-send-email-thomas.monjalon@6wind.com>
When built in a C++ application, the keepalive include fails:
rte_keepalive.h:142:41: error: ‘ALIVE’ was not declared in this scope
keepcfg->state_flags[rte_lcore_id()] = ALIVE;
^
C++ requires to use a scope operator to access an enum inside a struct.
There was also a namespace issue for the values (no RTE prefix).
The solution is to move the struct and related code out of the header file.
Fixes: 75583b0d1efd ("eal: add keep alive monitoring")
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
lib/librte_eal/common/include/rte_keepalive.h | 37 +++-----------------------
lib/librte_eal/common/rte_keepalive.c | 38 +++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 34 deletions(-)
v2:
- move keep-alive struct out of header
- uninline mark_alive function
diff --git a/lib/librte_eal/common/include/rte_keepalive.h b/lib/librte_eal/common/include/rte_keepalive.h
index 02472c0..f4cec04 100644
--- a/lib/librte_eal/common/include/rte_keepalive.h
+++ b/lib/librte_eal/common/include/rte_keepalive.h
@@ -64,35 +64,7 @@ typedef void (*rte_keepalive_failure_callback_t)(
* Keepalive state structure.
* @internal
*/
-struct rte_keepalive {
- /** Core Liveness. */
- enum {
- ALIVE = 1,
- MISSING = 0,
- DEAD = 2,
- GONE = 3
- } __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES];
-
- /** Last-seen-alive timestamps */
- uint64_t last_alive[RTE_KEEPALIVE_MAXCORES];
-
- /**
- * Cores to check.
- * Indexed by core id, non-zero if the core should be checked.
- */
- uint8_t active_cores[RTE_KEEPALIVE_MAXCORES];
-
- /** Dead core handler. */
- rte_keepalive_failure_callback_t callback;
-
- /**
- * Dead core handler app data.
- * Pointer is passed to dead core handler.
- */
- void *callback_data;
- uint64_t tsc_initial;
- uint64_t tsc_mhz;
-};
+struct rte_keepalive;
/**
@@ -136,11 +108,8 @@ void rte_keepalive_register_core(struct rte_keepalive *keepcfg,
* This function needs to be called from within the main process loop of
* the LCore to be checked.
*/
-static inline void
-rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
-{
- keepcfg->state_flags[rte_lcore_id()] = ALIVE;
-}
+void
+rte_keepalive_mark_alive(struct rte_keepalive *keepcfg);
#endif /* _KEEPALIVE_H_ */
diff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c
index 736fd0f..bd1f16b 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -39,6 +39,37 @@
#include <rte_keepalive.h>
#include <rte_malloc.h>
+struct rte_keepalive {
+ /** Core Liveness. */
+ enum rte_keepalive_state {
+ ALIVE = 1,
+ MISSING = 0,
+ DEAD = 2,
+ GONE = 3
+ } __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES];
+
+ /** Last-seen-alive timestamps */
+ uint64_t last_alive[RTE_KEEPALIVE_MAXCORES];
+
+ /**
+ * Cores to check.
+ * Indexed by core id, non-zero if the core should be checked.
+ */
+ uint8_t active_cores[RTE_KEEPALIVE_MAXCORES];
+
+ /** Dead core handler. */
+ rte_keepalive_failure_callback_t callback;
+
+ /**
+ * Dead core handler app data.
+ * Pointer is passed to dead core handler.
+ */
+ void *callback_data;
+ uint64_t tsc_initial;
+ uint64_t tsc_mhz;
+};
+
+
static void
print_trace(const char *msg, struct rte_keepalive *keepcfg, int idx_core)
{
@@ -111,3 +142,10 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
if (id_core < RTE_KEEPALIVE_MAXCORES)
keepcfg->active_cores[id_core] = 1;
}
+
+
+void
+rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
+{
+ keepcfg->state_flags[rte_lcore_id()] = ALIVE;
+}
--
2.7.0
next prev parent reply other threads:[~2016-02-16 7:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 17:06 [dpdk-dev] [PATCH 0/3] fix C++ includes Thomas Monjalon
2016-02-05 17:06 ` [dpdk-dev] [PATCH 1/3] eal: fix keep alive header for C++ Thomas Monjalon
2016-02-15 11:16 ` Remy Horton
2016-02-05 17:06 ` [dpdk-dev] [PATCH 2/3] hash: fix " Thomas Monjalon
2016-02-08 13:42 ` De Lara Guarch, Pablo
2016-02-05 17:06 ` [dpdk-dev] [PATCH 3/3] mbuf_offload: " Thomas Monjalon
2016-02-05 21:33 ` Thomas Monjalon
2016-02-16 7:14 ` [dpdk-dev] [PATCH v2 0/3] fix C++ includes Thomas Monjalon
2016-02-16 7:14 ` Thomas Monjalon [this message]
2016-02-16 10:16 ` [dpdk-dev] [PATCH v2 1/3] eal: fix keep alive header for C++ Remy Horton
2016-02-16 7:14 ` [dpdk-dev] [PATCH v2 2/3] hash: fix " Thomas Monjalon
2016-02-16 7:14 ` [dpdk-dev] [PATCH v2 3/3] mbuf_offload: " Thomas Monjalon
2016-02-16 16:21 ` [dpdk-dev] [PATCH v2 0/3] fix C++ includes Ferruh Yigit
2016-02-16 16:26 ` Thomas Monjalon
2016-02-16 18:33 ` Marc
2016-02-21 10:49 ` Thomas Monjalon
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=1455606865-22680-2-git-send-email-thomas.monjalon@6wind.com \
--to=thomas.monjalon@6wind.com \
--cc=declan.doherty@intel.com \
--cc=dev@dpdk.org \
--cc=pablo.de.lara.guarch@intel.com \
--cc=remy.horton@intel.com \
/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).