From 6dca8ba7dec3b31acb7b43f5e4431676acf4e664 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 22 Sep 2021 08:13:04 -0400 Subject: [PATCH] common: compile libhashtable as C++ MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ia91d3207ffffb0cd45ee987107058dc9e4690c94 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- src/common/hashtable/Makefile.am | 9 ++++++--- src/common/hashtable/{hashtable.c => hashtable.cpp} | 4 ++-- src/common/hashtable/hashtable.h | 2 +- src/common/hashtable/{utils.c => utils.cpp} | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) rename src/common/hashtable/{hashtable.c => hashtable.cpp} (99%) rename src/common/hashtable/{utils.c => utils.cpp} (99%) diff --git a/src/common/hashtable/Makefile.am b/src/common/hashtable/Makefile.am index 5f6770a81..b14254b34 100644 --- a/src/common/hashtable/Makefile.am +++ b/src/common/hashtable/Makefile.am @@ -2,8 +2,11 @@ noinst_LTLIBRARIES = libhashtable.la -libhashtable_la_SOURCES = hashtable.c hashtable.h \ - utils.c utils.h \ - hashtable-symbols.h +libhashtable_la_SOURCES = \ + hashtable.cpp \ + hashtable.h \ + hashtable-symbols.h \ + utils.cpp \ + utils.h libhashtable_la_LIBADD = $(URCU_LIBS) $(URCU_CDS_LIBS) diff --git a/src/common/hashtable/hashtable.c b/src/common/hashtable/hashtable.cpp similarity index 99% rename from src/common/hashtable/hashtable.c rename to src/common/hashtable/hashtable.cpp index ac765808f..7112debf2 100644 --- a/src/common/hashtable/hashtable.c +++ b/src/common/hashtable/hashtable.cpp @@ -96,7 +96,7 @@ const char *lttng_ht_type_str(enum lttng_ht_type type) /* * Return an allocated lttng hashtable. */ -struct lttng_ht *lttng_ht_new(unsigned long size, int type) +struct lttng_ht *lttng_ht_new(unsigned long size, lttng_ht_type type) { struct lttng_ht *ht; @@ -111,7 +111,7 @@ struct lttng_ht *lttng_ht_new(unsigned long size, int type) } pthread_mutex_unlock(&seed_lock); - ht = zmalloc(sizeof(*ht)); + ht = (lttng_ht *) zmalloc(sizeof(*ht)); if (ht == NULL) { PERROR("zmalloc lttng_ht"); goto error; diff --git a/src/common/hashtable/hashtable.h b/src/common/hashtable/hashtable.h index cefd43833..e15019041 100644 --- a/src/common/hashtable/hashtable.h +++ b/src/common/hashtable/hashtable.h @@ -71,7 +71,7 @@ struct lttng_ht_node_two_u64 { }; /* Hashtable new and destroy */ -struct lttng_ht *lttng_ht_new(unsigned long size, int type); +struct lttng_ht *lttng_ht_new(unsigned long size, enum lttng_ht_type type); void lttng_ht_destroy(struct lttng_ht *ht); /* Specialized node init and free functions */ diff --git a/src/common/hashtable/utils.c b/src/common/hashtable/utils.cpp similarity index 99% rename from src/common/hashtable/utils.c rename to src/common/hashtable/utils.cpp index eb51554b2..3bc2b5e91 100644 --- a/src/common/hashtable/utils.c +++ b/src/common/hashtable/utils.cpp @@ -527,7 +527,7 @@ int hash_match_key_u64(const void *key1, const void *key2) */ int hash_match_key_str(const void *key1, const void *key2) { - if (strcmp(key1, key2) == 0) { + if (strcmp((const char *) key1, (const char *) key2) == 0) { return 1; } -- 2.34.1