diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-06-21 15:21:03 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-06-21 15:21:03 +0300 |
commit | 64e91ef600f5c607b10a07539f33ecb31bd86818 (patch) | |
tree | 92847be43f57f9018630da970077fb5bae4a2748 | |
parent | 441dbcfe52171c550b696eb45d1d87cb07653823 (diff) | |
download | libmicrohttpd-64e91ef600f5c607b10a07539f33ecb31bd86818.tar.gz libmicrohttpd-64e91ef600f5c607b10a07539f33ecb31bd86818.zip |
Use compiler built-ins for bits rotations if available
-rw-r--r-- | src/microhttpd/mhd_bithelpers.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/microhttpd/mhd_bithelpers.h b/src/microhttpd/mhd_bithelpers.h index 9bd2df79..eace0eb9 100644 --- a/src/microhttpd/mhd_bithelpers.h +++ b/src/microhttpd/mhd_bithelpers.h | |||
@@ -286,7 +286,10 @@ _MHD_PUT_64BIT_BE_SAFE (void *dst, uint64_t value) | |||
286 | #endif /* ! __clang__ */ | 286 | #endif /* ! __clang__ */ |
287 | #define _MHD_ROTR32(value32, bits) \ | 287 | #define _MHD_ROTR32(value32, bits) \ |
288 | ((uint32_t) _rotr ((uint32_t) (value32),(bits))) | 288 | ((uint32_t) _rotr ((uint32_t) (value32),(bits))) |
289 | #else /* ! _MSC_FULL_VER */ | 289 | #elif __has_builtin (__builtin_rotateright32) |
290 | #define _MHD_ROTR32(value32, bits) \ | ||
291 | ((uint32_t) __builtin_rotateright32 ((value32), (bits))) | ||
292 | #else /* ! __builtin_rotateright32 */ | ||
290 | _MHD_static_inline uint32_t | 293 | _MHD_static_inline uint32_t |
291 | _MHD_ROTR32 (uint32_t value32, int bits) | 294 | _MHD_ROTR32 (uint32_t value32, int bits) |
292 | { | 295 | { |
@@ -296,7 +299,7 @@ _MHD_ROTR32 (uint32_t value32, int bits) | |||
296 | } | 299 | } |
297 | 300 | ||
298 | 301 | ||
299 | #endif /* ! _MSC_FULL_VER */ | 302 | #endif /* ! __builtin_rotateright32 */ |
300 | 303 | ||
301 | 304 | ||
302 | /** | 305 | /** |
@@ -311,7 +314,10 @@ _MHD_ROTR32 (uint32_t value32, int bits) | |||
311 | #endif /* ! __clang__ */ | 314 | #endif /* ! __clang__ */ |
312 | #define _MHD_ROTL32(value32, bits) \ | 315 | #define _MHD_ROTL32(value32, bits) \ |
313 | ((uint32_t) _rotl ((uint32_t) (value32),(bits))) | 316 | ((uint32_t) _rotl ((uint32_t) (value32),(bits))) |
314 | #else /* ! _MSC_FULL_VER */ | 317 | #elif __has_builtin (__builtin_rotateleft32) |
318 | #define _MHD_ROTL32(value32, bits) \ | ||
319 | ((uint32_t) __builtin_rotateleft32 ((value32), (bits))) | ||
320 | #else /* ! __builtin_rotateleft32 */ | ||
315 | _MHD_static_inline uint32_t | 321 | _MHD_static_inline uint32_t |
316 | _MHD_ROTL32 (uint32_t value32, int bits) | 322 | _MHD_ROTL32 (uint32_t value32, int bits) |
317 | { | 323 | { |
@@ -321,7 +327,7 @@ _MHD_ROTL32 (uint32_t value32, int bits) | |||
321 | } | 327 | } |
322 | 328 | ||
323 | 329 | ||
324 | #endif /* ! _MSC_FULL_VER */ | 330 | #endif /* ! __builtin_rotateleft32 */ |
325 | 331 | ||
326 | 332 | ||
327 | #endif /* ! MHD_BITHELPERS_H */ | 333 | #endif /* ! MHD_BITHELPERS_H */ |