Mercurial > hgrepos > FreeBSD > ports > net-mgmt > prometheus-client-c
comparison files/patch-prom_src_prom__metric__sample.c @ 6:c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Does not need gcc any more for old GCC-stype atomic syntax.
Not compiles with clang/cc on FreeBSD.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 18 Mar 2025 19:49:55 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 5:56e544de90da | 6:c7761c5a5389 |
|---|---|
| 1 --- prom/src/prom_metric_sample.c.orig 2020-12-08 07:38:13 UTC | |
| 2 +++ prom/src/prom_metric_sample.c | |
| 3 @@ -63,9 +63,9 @@ int prom_metric_sample_add(prom_metric_sample_t *self, | |
| 4 if (r_value < 0) { | |
| 5 return 1; | |
| 6 } | |
| 7 - _Atomic double old = atomic_load(&self->r_value); | |
| 8 + double old = atomic_load(&self->r_value); | |
| 9 for (;;) { | |
| 10 - _Atomic double new = ATOMIC_VAR_INIT(old + r_value); | |
| 11 + double new = old + r_value; | |
| 12 if (atomic_compare_exchange_weak(&self->r_value, &old, new)) { | |
| 13 return 0; | |
| 14 } | |
| 15 @@ -78,9 +78,9 @@ int prom_metric_sample_sub(prom_metric_sample_t *self, | |
| 16 PROM_LOG(PROM_METRIC_INCORRECT_TYPE); | |
| 17 return 1; | |
| 18 } | |
| 19 - _Atomic double old = atomic_load(&self->r_value); | |
| 20 + double old = atomic_load(&self->r_value); | |
| 21 for (;;) { | |
| 22 - _Atomic double new = ATOMIC_VAR_INIT(old - r_value); | |
| 23 + double new = old - r_value; | |
| 24 if (atomic_compare_exchange_weak(&self->r_value, &old, new)) { | |
| 25 return 0; | |
| 26 } |
