From b8a87223bb70fccc47ba0f9c96b3f58de6e1e5bd Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Mon, 26 May 2025 22:38:04 +0200 Subject: Add compile-time configuration for build settings --- asl/base/bit.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'asl/base/bit.hpp') diff --git a/asl/base/bit.hpp b/asl/base/bit.hpp index 5056383..824005c 100644 --- a/asl/base/bit.hpp +++ b/asl/base/bit.hpp @@ -114,7 +114,7 @@ constexpr T rotl(T v, int s) // NOLINT(*-no-recursion) { static constexpr int N = sizeof(decltype(v)) * 8; s = s % N; - return (s >= 0) ? (v << s) | (v >> (N - s)) : rotr(v, -s); + return (s >= 0) ? (v << s) | (v >> ((N - s) % N)) : rotr(v, -s); } template @@ -122,7 +122,7 @@ constexpr T rotr(T v, int s) // NOLINT(*-no-recursion) { static constexpr int N = sizeof(decltype(v)) * 8; s = s % N; - return (s >= 0) ? (v >> s) | (v << (N - s)) : rotl(v, -s); + return (s >= 0) ? (v >> s) | (v << ((N - s) % N)) : rotl(v, -s); } constexpr uint16_t byteswap(uint16_t v) -- cgit