diff options
author | Tomáš Kopal <Tomas.Kopal@altap.cz> | 2020-11-07 01:10:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-07 00:10:50 +0000 |
commit | bcb9c868275062212f20127c6b450e2770fe418c (patch) | |
tree | 8fd021439217072da0be22d18be5a931b1a16b25 /libnetdata | |
parent | b362797e98422b30d9f755888936c96221d2392f (diff) |
Make libnetdata headers compilable by C++. (#10185)
Diffstat (limited to 'libnetdata')
-rw-r--r-- | libnetdata/avl/avl.c | 10 | ||||
-rw-r--r-- | libnetdata/avl/avl.h | 16 | ||||
-rw-r--r-- | libnetdata/config/appconfig.h | 4 | ||||
-rw-r--r-- | libnetdata/dictionary/dictionary.h | 4 | ||||
-rw-r--r-- | libnetdata/eval/eval.c | 2 | ||||
-rw-r--r-- | libnetdata/eval/eval.h | 2 | ||||
-rw-r--r-- | libnetdata/libnetdata.h | 8 | ||||
-rw-r--r-- | libnetdata/log/log.h | 8 |
8 files changed, 35 insertions, 19 deletions
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 */ |