Просмотр исходного кода

Make libnetdata headers compilable by C++. (#10185)

Tomáš Kopal 4 лет назад
Родитель
Сommit
bcb9c86827

+ 2 - 2
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
 };

+ 1 - 1
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 }

+ 2 - 2
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
 };

+ 3 - 3
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;

+ 5 - 5
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;
 }

+ 8 - 8
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 */

+ 2 - 2
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

+ 2 - 2
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;
 

+ 1 - 1
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, " ] ");

+ 1 - 1
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;
 

Некоторые файлы не были показаны из-за большого количества измененных файлов