Mercurial > hgrepos > FreeBSD > ports > net-mgmt > prometheus-client-c
annotate 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 |
| rev | line source |
|---|---|
|
6
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1 --- prom/src/prom_metric_sample.c.orig 2020-12-08 07:38:13 UTC |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2 +++ prom/src/prom_metric_sample.c |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
3 @@ -63,9 +63,9 @@ int prom_metric_sample_add(prom_metric_sample_t *self, |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
4 if (r_value < 0) { |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
5 return 1; |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
6 } |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
7 - _Atomic double old = atomic_load(&self->r_value); |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
8 + double old = atomic_load(&self->r_value); |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
9 for (;;) { |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
10 - _Atomic double new = ATOMIC_VAR_INIT(old + r_value); |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
11 + double new = old + r_value; |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
12 if (atomic_compare_exchange_weak(&self->r_value, &old, new)) { |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
13 return 0; |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
14 } |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
15 @@ -78,9 +78,9 @@ int prom_metric_sample_sub(prom_metric_sample_t *self, |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
16 PROM_LOG(PROM_METRIC_INCORRECT_TYPE); |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
17 return 1; |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
18 } |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
19 - _Atomic double old = atomic_load(&self->r_value); |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
20 + double old = atomic_load(&self->r_value); |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
21 for (;;) { |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
22 - _Atomic double new = ATOMIC_VAR_INIT(old - r_value); |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
23 + double new = old - r_value; |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
24 if (atomic_compare_exchange_weak(&self->r_value, &old, new)) { |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
25 return 0; |
|
c7761c5a5389
FIX: Patch to compile with modern C11 style atomics.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
26 } |
