Mercurial > hgrepos > FreeBSD > ports > net-mgmt > prometheus-client-c
view 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 |
line wrap: on
line source
--- prom/src/prom_metric_sample.c.orig 2020-12-08 07:38:13 UTC +++ prom/src/prom_metric_sample.c @@ -63,9 +63,9 @@ int prom_metric_sample_add(prom_metric_sample_t *self, if (r_value < 0) { return 1; } - _Atomic double old = atomic_load(&self->r_value); + double old = atomic_load(&self->r_value); for (;;) { - _Atomic double new = ATOMIC_VAR_INIT(old + r_value); + double new = old + r_value; if (atomic_compare_exchange_weak(&self->r_value, &old, new)) { return 0; } @@ -78,9 +78,9 @@ int prom_metric_sample_sub(prom_metric_sample_t *self, PROM_LOG(PROM_METRIC_INCORRECT_TYPE); return 1; } - _Atomic double old = atomic_load(&self->r_value); + double old = atomic_load(&self->r_value); for (;;) { - _Atomic double new = ATOMIC_VAR_INIT(old - r_value); + double new = old - r_value; if (atomic_compare_exchange_weak(&self->r_value, &old, new)) { return 0; }
