gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd2] 07/12: mhd_atomic_counter: fixed formatting, fixed sing


From: Admin
Subject: [libmicrohttpd2] 07/12: mhd_atomic_counter: fixed formatting, fixed single thread version build
Date: Fri, 06 Jun 2025 16:01:15 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd2.

commit 16533685d082efc6f74e0b6b24cb64bfa6a0721a
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
AuthorDate: Wed Jun 4 23:35:02 2025 +0200

    mhd_atomic_counter: fixed formatting, fixed single thread version build
---
 src/mhd2/mhd_atomic_counter.h | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/mhd2/mhd_atomic_counter.h b/src/mhd2/mhd_atomic_counter.h
index f0d4f35..9bcf0cd 100644
--- a/src/mhd2/mhd_atomic_counter.h
+++ b/src/mhd2/mhd_atomic_counter.h
@@ -109,8 +109,8 @@ struct mhd_AtomicCounter
  *          already.
  */
 #  define mhd_atomic_counter_init(pcnt,initial_value) \
-        ((pcnt)->count = (initial_value), \
-         mhd_mutex_init_short (&((pcnt)->lock)))
+          ((pcnt)->count = (initial_value),           \
+           mhd_mutex_init_short (&((pcnt)->lock)))
 
 /**
  * Deinitialise the counter.
@@ -118,15 +118,15 @@ struct mhd_AtomicCounter
  * @warning Must be called only for the counters that has been initialised.
  */
 #  define mhd_atomic_counter_deinit(pcnt) \
-        mhd_mutex_destroy_chk (&((pcnt)->lock))
+          mhd_mutex_destroy_chk (&((pcnt)->lock))
 
 /**
  * Atomically increment the value of the counter
  * @param pcnt the pointer to the counter to increment
  */
-#  define mhd_atomic_counter_inc(pcnt)  do { \
-          mhd_mutex_lock_chk (&((pcnt)->lock));     \
-          ++(pcnt->count);                       \
+#  define mhd_atomic_counter_inc(pcnt)  do {   \
+          mhd_mutex_lock_chk (&((pcnt)->lock)); \
+          ++((pcnt)->count);                     \
           mhd_mutex_unlock_chk (&((pcnt)->lock)); } while (0)
 
 /**
@@ -184,7 +184,7 @@ mhd_atomic_counter_get (struct mhd_AtomicCounter *pcnt);
  *          already.
  */
 #  define mhd_atomic_counter_init(pcnt,initial_value) \
-        ((pcnt)->count = (initial_value), (! 0))
+          ((pcnt)->count = (initial_value), (! 0))
 
 /**
  * Deinitialise the counter.
@@ -197,7 +197,7 @@ mhd_atomic_counter_get (struct mhd_AtomicCounter *pcnt);
  * Atomically increment the value of the counter
  * @param pcnt the pointer to the counter to increment
  */
-#  define mhd_atomic_counter_inc(pcnt)  do { ++(pcnt->count); } while (0)
+#  define mhd_atomic_counter_inc(pcnt)  do { ++((pcnt)->count); } while (0)
 
 /**
  * Atomically increment the value of the counter and return the result
@@ -220,6 +220,15 @@ mhd_atomic_counter_get (struct mhd_AtomicCounter *pcnt);
  */
 #  define mhd_atomic_counter_get(pcnt) ((pcnt)->count)
 
+/**
+ * Atomically increment the value of the counter and return the result.
+ * The value is allowed to overflow and get back to zero.
+ * @param pcnt the pointer to the counter to increment
+ * @return the final/resulting counter value
+ */
+#  define mhd_atomic_counter_inc_wrap_get(pcnt) \
+          mhd_atomic_counter_inc_get (pcnt)
+
 #endif /* mhd_ATOMIC_SINGLE_THREAD */
 
 #endif /* ! MHD_ATOMIC_COUNTER_H */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]