aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-10-31 18:40:39 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-10-31 18:40:39 +0300
commited87ddd2179729fd1676610d80c2dce6c53f24ea (patch)
treefae86713d94eb20fdb32fcb6e7f7d76114115354
parent55f059ee0a3affb136176feca612c3fd5d4b9652 (diff)
downloadlibmicrohttpd-ed87ddd2179729fd1676610d80c2dce6c53f24ea.tar.gz
libmicrohttpd-ed87ddd2179729fd1676610d80c2dce6c53f24ea.zip
mhd_bithelpers: unified _MHD_ROTx32() behavior
-rw-r--r--src/microhttpd/mhd_bithelpers.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/microhttpd/mhd_bithelpers.h b/src/microhttpd/mhd_bithelpers.h
index 8f7058a8..ed0c2e0c 100644
--- a/src/microhttpd/mhd_bithelpers.h
+++ b/src/microhttpd/mhd_bithelpers.h
@@ -33,7 +33,6 @@
33/* Declarations for VC & Clang/C2 built-ins */ 33/* Declarations for VC & Clang/C2 built-ins */
34#include <intrin.h> 34#include <intrin.h>
35#endif /* _MSC_FULL_VER */ 35#endif /* _MSC_FULL_VER */
36#include "mhd_assert.h"
37#include "mhd_byteorder.h" 36#include "mhd_byteorder.h"
38#if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN || _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN 37#if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN || _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN
39#include "mhd_align.h" 38#include "mhd_align.h"
@@ -293,7 +292,7 @@ _MHD_PUT_64BIT_BE_SAFE (void *dst, uint64_t value)
293_MHD_static_inline uint32_t 292_MHD_static_inline uint32_t
294_MHD_ROTR32 (uint32_t value32, int bits) 293_MHD_ROTR32 (uint32_t value32, int bits)
295{ 294{
296 mhd_assert (bits < 32); 295 bits %= 32;
297 /* Defined in form which modern compiler could optimize. */ 296 /* Defined in form which modern compiler could optimize. */
298 return (value32 >> bits) | (value32 << (32 - bits)); 297 return (value32 >> bits) | (value32 << (32 - bits));
299} 298}
@@ -321,7 +320,7 @@ _MHD_ROTR32 (uint32_t value32, int bits)
321_MHD_static_inline uint32_t 320_MHD_static_inline uint32_t
322_MHD_ROTL32 (uint32_t value32, int bits) 321_MHD_ROTL32 (uint32_t value32, int bits)
323{ 322{
324 mhd_assert (bits < 32); 323 bits %= 32;
325 /* Defined in form which modern compiler could optimize. */ 324 /* Defined in form which modern compiler could optimize. */
326 return (value32 << bits) | (value32 >> (32 - bits)); 325 return (value32 << bits) | (value32 >> (32 - bits));
327} 326}