changeset 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 56e544de90da
children 19458de35e56
files Makefile files/patch-prom_src_prom__metric__sample.c files/patch-prom_src_prom__metric__sample__t.h
diffstat 3 files changed, 37 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Tue Mar 18 17:58:55 2025 +0100
+++ b/Makefile	Tue Mar 18 19:49:55 2025 +0100
@@ -17,7 +17,6 @@
 GH_TAGNAME=	v${DISTVERSION}
 
 # Currently compilation errors on incompatible types with clang
-USE_GCC=	yes
 USE_LDCONFIG=	yes
 
 CMAKE_SOURCE_PATH=	${WRKSRC}/prom
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/files/patch-prom_src_prom__metric__sample.c	Tue Mar 18 19:49:55 2025 +0100
@@ -0,0 +1,26 @@
+--- 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;
+     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/files/patch-prom_src_prom__metric__sample__t.h	Tue Mar 18 19:49:55 2025 +0100
@@ -0,0 +1,11 @@
+--- prom/src/prom_metric_sample_t.h.orig	2020-12-08 07:38:13 UTC
++++ prom/src/prom_metric_sample_t.h
+@@ -23,7 +23,7 @@ struct prom_metric_sample {
+ struct prom_metric_sample {
+   prom_metric_type_t type; /**< type is the metric type for the sample */
+   char *l_value;           /**< l_value is the full metric name and label set represeted as a string */
+-  _Atomic double r_value;  /**< r_value is the value of the metric sample */
++  _Atomic(double) r_value;  /**< r_value is the value of the metric sample */
+ };
+ 
+ #endif  // PROM_METRIC_SAMPLE_T_H