libmicrohttpd2

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

commit 65c588282823d3865957bbe1a0d7625dab771f4b
parent 749fab2bf7b765dee5ed15a10530ebe115c77413
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Fri, 25 Apr 2025 14:39:44 +0200

mhd_bithelpers: simplified inline functions

Diffstat:
Msrc/mhd2/mhd_bithelpers.h | 14+++++---------
1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/mhd2/mhd_bithelpers.h b/src/mhd2/mhd_bithelpers.h @@ -31,6 +31,8 @@ #include "sys_base_types.h" +#include "mhd_assert.h" + #if defined(_MSC_FULL_VER) && (! defined(__clang__) || (defined(__c2__) && \ defined(__OPTIMIZE__))) /* Declarations for VC & Clang/C2 built-ins */ @@ -349,9 +351,7 @@ mhd_PUT_64BIT_BE_UNALIGN (void *dst, uint64_t value) MHD_static_inline_ uint32_t mhd_ROTR32 (uint32_t value32, int bits) { - bits %= 32; - if (0 == bits) - return value32; + mhd_assert (32 > bits); /* Defined in form which modern compiler could optimize. */ return (value32 >> bits) | (value32 << (32 - bits)); } @@ -379,9 +379,7 @@ mhd_ROTR32 (uint32_t value32, int bits) MHD_static_inline_ uint32_t mhd_ROTL32 (uint32_t value32, int bits) { - bits %= 32; - if (0 == bits) - return value32; + mhd_assert (32 > bits); /* Defined in form which modern compiler could optimize. */ return (value32 << bits) | (value32 >> (32 - bits)); } @@ -409,9 +407,7 @@ mhd_ROTL32 (uint32_t value32, int bits) MHD_static_inline_ uint64_t mhd_ROTR64 (uint64_t value64, int bits) { - bits %= 64; - if (0 == bits) - return value64; + mhd_assert (64 > bits); /* Defined in form which modern compiler could optimise. */ return (value64 >> bits) | (value64 << (64 - bits)); }