summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomáš Kopal <Tomas.Kopal@altap.cz>2020-11-07 01:10:50 +0100
committerGitHub <noreply@github.com>2020-11-07 00:10:50 +0000
commitbcb9c868275062212f20127c6b450e2770fe418c (patch)
tree8fd021439217072da0be22d18be5a931b1a16b25
parentb362797e98422b30d9f755888936c96221d2392f (diff)
Make libnetdata headers compilable by C++. (#10185)
-rw-r--r--collectors/apps.plugin/apps_plugin.c4
-rw-r--r--collectors/statsd.plugin/statsd.c2
-rw-r--r--collectors/tc.plugin/plugin_tc.c4
-rw-r--r--database/rrdcalc.c6
-rw-r--r--libnetdata/avl/avl.c10
-rw-r--r--libnetdata/avl/avl.h16
-rw-r--r--libnetdata/config/appconfig.h4
-rw-r--r--libnetdata/dictionary/dictionary.h4
-rw-r--r--libnetdata/eval/eval.c2
-rw-r--r--libnetdata/eval/eval.h2
-rw-r--r--libnetdata/libnetdata.h8
-rw-r--r--libnetdata/log/log.h8
-rw-r--r--registry/registry_internals.h2
-rw-r--r--registry/registry_person.h2
-rw-r--r--spawn/spawn.h2
15 files changed, 46 insertions, 30 deletions
diff --git a/collectors/apps.plugin/apps_plugin.c b/collectors/apps.plugin/apps_plugin.c
index 4ec8c29ae7..b440bcd5ec 100644
--- a/collectors/apps.plugin/apps_plugin.c
+++ b/collectors/apps.plugin/apps_plugin.c
@@ -535,7 +535,7 @@ enum user_or_group_id_type {
struct user_or_group_ids{
enum user_or_group_id_type type;
- avl_tree index;
+ avl_tree_type index;
struct user_or_group_id *root;
char filename[FILENAME_MAX + 1];
@@ -1691,7 +1691,7 @@ int file_descriptor_compare(void* a, void* b) {
// int file_descriptor_iterator(avl *a) { if(a) {}; return 0; }
-avl_tree all_files_index = {
+avl_tree_type all_files_index = {
NULL,
file_descriptor_compare
};
diff --git a/collectors/statsd.plugin/statsd.c b/collectors/statsd.plugin/statsd.c
index 7fedb4f17e..d9b326f605 100644
--- a/collectors/statsd.plugin/statsd.c
+++ b/collectors/statsd.plugin/statsd.c
@@ -22,7 +22,7 @@
#define STATSD_FIRST_PTR_MUTEX_UNLOCK(index) netdata_mutex_unlock(&((index)->first_mutex))
#define STATSD_DICTIONARY_OPTIONS DICTIONARY_FLAG_DEFAULT
#else
-#define STATSD_AVL_TREE avl_tree
+#define STATSD_AVL_TREE avl_tree_type
#define STATSD_AVL_INSERT avl_insert
#define STATSD_AVL_SEARCH avl_search
#define STATSD_AVL_INDEX_INIT { .root = NULL, .compar = statsd_metric_compare }
diff --git a/collectors/tc.plugin/plugin_tc.c b/collectors/tc.plugin/plugin_tc.c
index 9245b0857f..b92450efe7 100644
--- a/collectors/tc.plugin/plugin_tc.c
+++ b/collectors/tc.plugin/plugin_tc.c
@@ -81,7 +81,7 @@ struct tc_device {
RRDSET *st_tokens;
RRDSET *st_ctokens;
- avl_tree classes_index;
+ avl_tree_type classes_index;
struct tc_class *classes;
struct tc_class *last_class;
@@ -102,7 +102,7 @@ static int tc_device_compare(void* a, void* b) {
else return strcmp(((struct tc_device *)a)->id, ((struct tc_device *)b)->id);
}
-avl_tree tc_device_root_index = {
+avl_tree_type tc_device_root_index = {
NULL,
tc_device_compare
};
diff --git a/database/rrdcalc.c b/database/rrdcalc.c
index 2422de3081..a057841373 100644
--- a/database/rrdcalc.c
+++ b/database/rrdcalc.c
@@ -322,7 +322,7 @@ inline void rrdcalc_add_to_host(RRDHOST *host, RRDCALC *rc) {
if(rc->calculation) {
rc->calculation->status = &rc->status;
- rc->calculation->this = &rc->value;
+ rc->calculation->myself = &rc->value;
rc->calculation->after = &rc->db_after;
rc->calculation->before = &rc->db_before;
rc->calculation->rrdcalc = rc;
@@ -330,7 +330,7 @@ inline void rrdcalc_add_to_host(RRDHOST *host, RRDCALC *rc) {
if(rc->warning) {
rc->warning->status = &rc->status;
- rc->warning->this = &rc->value;
+ rc->warning->myself = &rc->value;
rc->warning->after = &rc->db_after;
rc->warning->before = &rc->db_before;
rc->warning->rrdcalc = rc;
@@ -338,7 +338,7 @@ inline void rrdcalc_add_to_host(RRDHOST *host, RRDCALC *rc) {
if(rc->critical) {
rc->critical->status = &rc->status;
- rc->critical->this = &rc->value;
+ rc->critical->myself = &rc->value;
rc->critical->after = &rc->db_after;
rc->critical->before = &rc->db_before;
rc->critical->rrdcalc = rc;
diff --git a/libnetdata/avl/avl.c b/libnetdata/avl/avl.c
index c44bef307c..15293740d4 100644
--- a/libnetdata/avl/avl.c
+++ b/libnetdata/avl/avl.c
@@ -17,7 +17,7 @@
/* Search |tree| for an item matching |item|, and return it if found.
Otherwise return |NULL|. */
-avl *avl_search(avl_tree *tree, avl *item) {
+avl *avl_search(avl_tree_type *tree, avl *item) {
avl *p;
// assert (tree != NULL && item != NULL);
@@ -40,7 +40,7 @@ avl *avl_search(avl_tree *tree, avl *item) {
If a duplicate item is found in the tree,
returns a pointer to the duplicate without inserting |item|.
*/
-avl *avl_insert(avl_tree *tree, avl *item) {
+avl *avl_insert(avl_tree_type *tree, avl *item) {
avl *y, *z; /* Top node to update balance factor, and parent. */
avl *p, *q; /* Iterator, and parent. */
avl *n; /* Newly inserted node. */
@@ -136,7 +136,7 @@ avl *avl_insert(avl_tree *tree, avl *item) {
/* Deletes from |tree| and returns an item matching |item|.
Returns a null pointer if no matching item found. */
-avl *avl_remove(avl_tree *tree, avl *item) {
+avl *avl_remove(avl_tree_type *tree, avl *item) {
/* Stack of nodes. */
avl *pa[AVL_MAX_HEIGHT]; /* Nodes. */
unsigned char da[AVL_MAX_HEIGHT]; /* |avl_link[]| indexes. */
@@ -306,7 +306,7 @@ int avl_walker(avl *node, int (*callback)(void * /*entry*/, void * /*data*/), vo
return total;
}
-int avl_traverse(avl_tree *tree, int (*callback)(void * /*entry*/, void * /*data*/), void *data) {
+int avl_traverse(avl_tree_type *tree, int (*callback)(void * /*entry*/, void * /*data*/), void *data) {
if(tree->root)
return avl_walker(tree->root, callback, data);
else
@@ -396,7 +396,7 @@ int avl_traverse_lock(avl_tree_lock *tree, int (*callback)(void * /*entry*/, voi
return ret;
}
-void avl_init(avl_tree *tree, int (*compar)(void * /*a*/, void * /*b*/)) {
+void avl_init(avl_tree_type *tree, int (*compar)(void * /*a*/, void * /*b*/)) {
tree->root = NULL;
tree->compar = compar;
}
diff --git a/libnetdata/avl/avl.h b/libnetdata/avl/avl.h
index 070bb3d3d6..a3e0f65667 100644
--- a/libnetdata/avl/avl.h
+++ b/libnetdata/avl/avl.h
@@ -34,13 +34,13 @@ typedef struct avl {
} avl;
/* An AVL tree */
-typedef struct avl_tree {
+typedef struct avl_tree_type {
avl *root;
int (*compar)(void *a, void *b);
-} avl_tree;
+} avl_tree_type;
typedef struct avl_tree_lock {
- avl_tree avl_tree;
+ avl_tree_type avl_tree;
#ifndef AVL_WITHOUT_PTHREADS
#ifdef AVL_LOCK_WITH_MUTEX
@@ -60,7 +60,7 @@ typedef struct avl_tree_lock {
* be properly allocated by the caller.
*/
avl *avl_insert_lock(avl_tree_lock *tree, avl *item) NEVERNULL WARNUNUSED;
-avl *avl_insert(avl_tree *tree, avl *item) NEVERNULL WARNUNUSED;
+avl *avl_insert(avl_tree_type *tree, avl *item) NEVERNULL WARNUNUSED;
/* Remove an element a from the AVL tree t
* returns a pointer to the removed element
@@ -68,22 +68,22 @@ avl *avl_insert(avl_tree *tree, avl *item) NEVERNULL WARNUNUSED;
* (equal as returned by t->compar())
*/
avl *avl_remove_lock(avl_tree_lock *tree, avl *item) WARNUNUSED;
-avl *avl_remove(avl_tree *tree, avl *item) WARNUNUSED;
+avl *avl_remove(avl_tree_type *tree, avl *item) WARNUNUSED;
/* Find the element into the tree that equal to a
* (equal as returned by t->compar())
* returns NULL is no element is equal to a
*/
avl *avl_search_lock(avl_tree_lock *tree, avl *item);
-avl *avl_search(avl_tree *tree, avl *item);
+avl *avl_search(avl_tree_type *tree, avl *item);
/* Initialize the avl_tree_lock
*/
void avl_init_lock(avl_tree_lock *tree, int (*compar)(void *a, void *b));
-void avl_init(avl_tree *tree, int (*compar)(void *a, void *b));
+void avl_init(avl_tree_type *tree, int (*compar)(void *a, void *b));
int avl_traverse_lock(avl_tree_lock *tree, int (*callback)(void *entry, void *data), void *data);
-int avl_traverse(avl_tree *tree, int (*callback)(void *entry, void *data), void *data);
+int avl_traverse(avl_tree_type *tree, int (*callback)(void *entry, void *data), void *data);
#endif /* avl.h */
diff --git a/libnetdata/config/appconfig.h b/libnetdata/config/appconfig.h
index 8c2ce09a97..df4adb41f1 100644
--- a/libnetdata/config/appconfig.h
+++ b/libnetdata/config/appconfig.h
@@ -111,7 +111,7 @@
#define CONFIG_VALUE_CHECKED 0x08 // has been checked if the value is different from the default
struct config_option {
- avl avl; // the index entry of this entry - this has to be first!
+ avl avl_node; // the index entry of this entry - this has to be first!
uint8_t flags;
uint32_t hash; // a simple hash to speed up searching
@@ -124,7 +124,7 @@ struct config_option {
};
struct section {
- avl avl; // the index entry of this section - this has to be first!
+ avl avl_node; // the index entry of this section - this has to be first!
uint32_t hash; // a simple hash to speed up searching
// we first compare hashes, and only if the hashes are equal we do string comparisons
diff --git a/libnetdata/dictionary/dictionary.h b/libnetdata/dictionary/dictionary.h
index 9be261eb22..fc24ec2ecf 100644
--- a/libnetdata/dictionary/dictionary.h
+++ b/libnetdata/dictionary/dictionary.h
@@ -13,7 +13,7 @@ struct dictionary_stats {
};
typedef struct name_value {
- avl avl; // the index - this has to be first!
+ avl avl_node; // the index - this has to be first!
uint32_t hash; // a simple hash to speed up searching
// we first compare hashes, and only if the hashes are equal we do string comparisons
@@ -23,7 +23,7 @@ typedef struct name_value {
} NAME_VALUE;
typedef struct dictionary {
- avl_tree values_index;
+ avl_tree_type values_index;
uint8_t flags;
diff --git a/libnetdata/eval/eval.c b/libnetdata/eval/eval.c
index f8af801f51..b53b070394 100644
--- a/libnetdata/eval/eval.c
+++ b/libnetdata/eval/eval.c
@@ -80,7 +80,7 @@ static inline calculated_number eval_variable(EVAL_EXPRESSION *exp, EVAL_VARIABL
}
if(unlikely(v->hash == this_hash && !strcmp(v->name, "this"))) {
- n = (exp->this)?*exp->this:NAN;
+ n = (exp->myself)?*exp->myself:NAN;
buffer_strcat(exp->error_msg, "[ $this = ");
print_parsed_as_constant(exp->error_msg, n);
buffer_strcat(exp->error_msg, " ] ");
diff --git a/libnetdata/eval/eval.h b/libnetdata/eval/eval.h
index 57dae9d0bf..fc03d7c1f1 100644
--- a/libnetdata/eval/eval.h
+++ b/libnetdata/eval/eval.h
@@ -28,7 +28,7 @@ typedef struct eval_expression {
const char *parsed_as;
RRDCALC_STATUS *status;
- calculated_number *this;
+ calculated_number *myself;
time_t *after;
time_t *before;
diff --git a/libnetdata/libnetdata.h b/libnetdata/libnetdata.h
index 9ec6049e23..decae911f1 100644
--- a/libnetdata/libnetdata.h
+++ b/libnetdata/libnetdata.h
@@ -3,6 +3,10 @@
#ifndef NETDATA_LIB_H
#define NETDATA_LIB_H 1
+# ifdef __cplusplus
+extern "C" {
+# endif
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -328,4 +332,8 @@ extern char *netdata_configured_host_prefix;
// BEWARE: Outside of the C code this also exists in alarm-notify.sh
#define DEFAULT_CLOUD_BASE_URL "https://app.netdata.cloud"
+# ifdef __cplusplus
+}
+# endif
+
#endif // NETDATA_LIB_H
diff --git a/libnetdata/log/log.h b/libnetdata/log/log.h
index 1d32cf2091..c99c151651 100644
--- a/libnetdata/log/log.h
+++ b/libnetdata/log/log.h
@@ -3,6 +3,10 @@
#ifndef NETDATA_LOG_H
#define NETDATA_LOG_H 1
+# ifdef __cplusplus
+extern "C" {
+# endif
+
#include "../libnetdata.h"
#define D_WEB_BUFFER 0x0000000000000001
@@ -98,4 +102,8 @@ extern void error_int( const char *prefix, const char *file, const char *functio
extern void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) NORETURN PRINTFLIKE(4, 5);
extern void log_access( const char *fmt, ... ) PRINTFLIKE(1, 2);
+# ifdef __cplusplus
+}
+# endif
+
#endif /* NETDATA_LOG_H */
diff --git a/registry/registry_internals.h b/registry/registry_internals.h
index c126e454bd..0eb83a436f 100644
--- a/registry/registry_internals.h
+++ b/registry/registry_internals.h
@@ -57,7 +57,7 @@ struct registry {
DICTIONARY *persons; // dictionary of REGISTRY_PERSON *, with key the REGISTRY_PERSON.guid
DICTIONARY *machines; // dictionary of REGISTRY_MACHINE *, with key the REGISTRY_MACHINE.guid
- avl_tree registry_urls_root_index;
+ avl_tree_type registry_urls_root_index;
netdata_mutex_t lock;
};
diff --git a/registry/registry_person.h b/registry/registry_person.h
index 30e9cb5139..9a4aa959b9 100644
--- a/registry/registry_person.h
+++ b/registry/registry_person.h
@@ -30,7 +30,7 @@ typedef struct registry_person_url REGISTRY_PERSON_URL;
struct registry_person {
char guid[GUID_LEN + 1]; // the person GUID
- avl_tree person_urls; // dictionary of PERSON_URLs
+ avl_tree_type person_urls; // dictionary of PERSON_URLs
uint32_t first_t; // the first time we saw this
uint32_t last_t; // the last time we saw this
diff --git a/spawn/spawn.h b/spawn/spawn.h
index aaeadb7a69..34b2632e03 100644
--- a/spawn/spawn.h
+++ b/spawn/spawn.h
@@ -58,7 +58,7 @@ struct spawn_cmd_info {
/* spawn command queue */
struct spawn_queue {
- avl_tree cmd_tree;
+ avl_tree_type cmd_tree;
/* concurrency control of command queue */
uv_mutex_t mutex;