From 657d1bf105996bf8f6e13af697fb1112afa61b28 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 3 Sep 2021 17:31:29 -0400 Subject: [PATCH] bin: compile lttng-consumerd as a C++ MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Same as the previous commits, but change lttng-consumerd to be a C++ program. Function lttng_consumer_get_type is dlsym-ed by tests/regression/tools/notification/consumer_testpoints.c, so we have two choices: make the dlsym use the mangled name or make the function have a C linkage name. The latter is better, because the mangled name is implementation-defined, and therefore more fragile. Change-Id: I1986e38c193a935721e52c89426c89fd434ccd6b Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- src/bin/lttng-consumerd/Makefile.am | 7 ++++--- .../{health-consumerd.c => health-consumerd.cpp} | 0 .../{lttng-consumerd.c => lttng-consumerd.cpp} | 0 src/bin/lttng-consumerd/lttng-consumerd.h | 6 +++++- src/common/consumer/consumer-timer.h | 8 ++++++++ src/common/consumer/consumer.h | 8 ++++++++ 6 files changed, 25 insertions(+), 4 deletions(-) rename src/bin/lttng-consumerd/{health-consumerd.c => health-consumerd.cpp} (100%) rename src/bin/lttng-consumerd/{lttng-consumerd.c => lttng-consumerd.cpp} (100%) diff --git a/src/bin/lttng-consumerd/Makefile.am b/src/bin/lttng-consumerd/Makefile.am index 112e360d0..37fc6d524 100644 --- a/src/bin/lttng-consumerd/Makefile.am +++ b/src/bin/lttng-consumerd/Makefile.am @@ -2,10 +2,11 @@ lttnglibexec_PROGRAMS = lttng-consumerd -lttng_consumerd_SOURCES = lttng-consumerd.c \ +lttng_consumerd_SOURCES = \ + lttng-consumerd.cpp \ lttng-consumerd.h \ - health-consumerd.h \ - health-consumerd.c + health-consumerd.cpp \ + health-consumerd.h lttng_consumerd_LDADD = \ $(top_builddir)/src/common/consumer/libconsumer.la \ diff --git a/src/bin/lttng-consumerd/health-consumerd.c b/src/bin/lttng-consumerd/health-consumerd.cpp similarity index 100% rename from src/bin/lttng-consumerd/health-consumerd.c rename to src/bin/lttng-consumerd/health-consumerd.cpp diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.cpp similarity index 100% rename from src/bin/lttng-consumerd/lttng-consumerd.c rename to src/bin/lttng-consumerd/lttng-consumerd.cpp diff --git a/src/bin/lttng-consumerd/lttng-consumerd.h b/src/bin/lttng-consumerd/lttng-consumerd.h index 8e40c9fee..7621877d3 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.h +++ b/src/bin/lttng-consumerd/lttng-consumerd.h @@ -15,6 +15,10 @@ extern int lttng_consumer_ready; extern const char *tracing_group_name; -enum lttng_consumer_type lttng_consumer_get_type(void); +/* + * This function is dlsym-ed from a test, making it have a C linkage name + * makes it easier. + */ +extern "C" enum lttng_consumer_type lttng_consumer_get_type(); #endif /* _LTTNG_CONSUMERD_H */ diff --git a/src/common/consumer/consumer-timer.h b/src/common/consumer/consumer-timer.h index 85751442f..084eb017d 100644 --- a/src/common/consumer/consumer-timer.h +++ b/src/common/consumer/consumer-timer.h @@ -14,6 +14,10 @@ #include "consumer.h" +#ifdef __cplusplus +extern "C" { +#endif + #define LTTNG_CONSUMER_SIG_SWITCH SIGRTMIN + 10 #define LTTNG_CONSUMER_SIG_TEARDOWN SIGRTMIN + 11 #define LTTNG_CONSUMER_SIG_LIVE SIGRTMIN + 12 @@ -53,4 +57,8 @@ int consumer_flush_ust_index(struct lttng_consumer_stream *stream); int consumer_timer_thread_get_channel_monitor_pipe(void); int consumer_timer_thread_set_channel_monitor_pipe(int fd); +#ifdef __cplusplus +} +#endif + #endif /* CONSUMER_TIMER_H */ diff --git a/src/common/consumer/consumer.h b/src/common/consumer/consumer.h index 0c83baa8c..6f2aae31b 100644 --- a/src/common/consumer/consumer.h +++ b/src/common/consumer/consumer.h @@ -29,6 +29,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + struct lttng_consumer_local_data; /* Commands for consumer */ @@ -1061,4 +1065,8 @@ enum lttcomm_return_code lttng_consumer_open_channel_packets( int consumer_metadata_wakeup_pipe(const struct lttng_consumer_channel *channel); void lttng_consumer_sigbus_handle(void *addr); +#ifdef __cplusplus +} +#endif + #endif /* LIB_CONSUMER_H */ -- 2.34.1