libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

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

mhd_atomic_counter: fixed formatting, fixed single thread version build

Diffstat:
Msrc/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 @@ -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 */