@cryptotaxi247 / netdata-1 / commits / 5a815ea42

pre gcc v5 support and allow building without dbengine (#14239)

* allow spinlock to be compiled with gcc 4.9 * allow compiling without dbengine

Costa Tsaousis committed Jan 11, 2023 at 00:33 UTC 5a815ea424715fea934e7e2f37c98ecf3fb8f4ef
6 files changed +12 -8
daemon/global_statistics.c
+3
@@ -996,6 +996,8 @@ static void sqlite3_statistics_charts(void) {
996 // ----------------------------------------------------------------
997 }
998
999 +#ifdef ENABLE_DBENGINE
1000 +
1001 struct dbengine2_cache_pointers {
1002 RRDSET *st_cache_hit_ratio;
1003 RRDDIM *rd_hit_ratio_closest;
@@ -2323,6 +2325,7 @@ static void dbengine2_statistics_charts(void) {
2325 }
2326 }
2327 }
2328 +#endif // ENABLE_DBENGINE
2329
2330 static void update_strings_charts() {
2331 static RRDSET *st_ops = NULL, *st_entries = NULL, *st_mem = NULL;
database/engine/datafile.c
+3 -4
@@ -25,12 +25,11 @@ static struct rrdengine_datafile *datafile_alloc_and_init(struct rrdengine_insta
25 fatal_assert(0 == uv_rwlock_init(&datafile->extent_rwlock));
26 datafile->ctx = ctx;
27
28 - datafile->users.spinlock = NETDATA_SPINLOCK_INITIALIZER;
28 datafile->users.available = true;
29
31 - datafile->extent_exclusive_access.spinlock = NETDATA_SPINLOCK_INITIALIZER;
32 -
33 - datafile->writers.spinlock = NETDATA_SPINLOCK_INITIALIZER;
30 + netdata_spinlock_init(&datafile->users.spinlock);
31 + netdata_spinlock_init(&datafile->extent_exclusive_access.spinlock);
32 + netdata_spinlock_init(&datafile->writers.spinlock);
33
34 return datafile;
35 }
database/engine/metric.c
+1 -1
@@ -120,7 +120,7 @@ static METRIC *metric_add(MRG *mrg, MRG_ENTRY *entry, bool *ret) {
120 metric->latest_time_s_clean = entry->last_time_s;
121 metric->latest_time_s_hot = 0;
122 metric->latest_update_every_s = entry->latest_update_every_s;
123 - metric->timestamps_lock = NETDATA_SPINLOCK_INITIALIZER;
123 + netdata_spinlock_init(&metric->timestamps_lock);
124 *PValue = metric;
125
126 mrg_index_write_unlock(mrg);
libnetdata/locks/locks.c
+1 -1
@@ -279,7 +279,7 @@ int __netdata_rwlock_trywrlock(netdata_rwlock_t *rwlock) {
279 // https://www.youtube.com/watch?v=rmGJc9PXpuE&t=41s
280
281 void netdata_spinlock_init(SPINLOCK *spinlock) {
282 - *spinlock = NETDATA_SPINLOCK_INITIALIZER;
282 + memset(spinlock, 0, sizeof(SPINLOCK));
283 }
284
285 void netdata_spinlock_lock(SPINLOCK *spinlock) {
libnetdata/locks/locks.h
+3 -1
@@ -16,7 +16,9 @@ typedef struct netdata_spinlock {
16 pid_t locker_pid;
17 #endif
18 } SPINLOCK;
19 -#define NETDATA_SPINLOCK_INITIALIZER (SPINLOCK) { .locked = false }
19 +
20 +#define NETDATA_SPINLOCK_INITIALIZER \
21 + { .locked = false }
22
23 void netdata_spinlock_init(SPINLOCK *spinlock);
24 void netdata_spinlock_lock(SPINLOCK *spinlock);
libnetdata/worker_utilization/worker_utilization.c
+1 -1
@@ -83,7 +83,7 @@ void worker_register(const char *name) {
83 struct workers_workname *workname = *PValue;
84 if(!workname) {
85 workname = mallocz(sizeof(struct workers_workname));
86 - workname->spinlock = NETDATA_SPINLOCK_INITIALIZER;
86 + netdata_spinlock_init(&workname->spinlock);
87 workname->base = NULL;
88 *PValue = workname;
89 }