From b729ee98921bac8c8687a4d1a941aa0567f8196e Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Tue, 2 Sep 2008 16:59:57 +0200 Subject: [PATCH] bitrotate: Code improvements. --- ChangeLog | 3 ++- lib/bitrotate.h | 6 +++--- tests/test-bitrotate.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 58c6e5b2a..b69ee9c41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,8 @@ * lib/bitrotate.h (rotl64, rotr64): Add. Suggested by Bruce Korb with ideas from Ben Pfaff - and Bruno Haible . + , Bruno Haible and Eric + Blake . * tests/test-bitrotate.c: Add more test vectors. diff --git a/lib/bitrotate.h b/lib/bitrotate.h index b8528b4ca..65bf682f9 100644 --- a/lib/bitrotate.h +++ b/lib/bitrotate.h @@ -21,10 +21,10 @@ #include -#if defined UINT64_MAX && defined UINT64_C +#ifdef UINT64_MAX /* Given an unsigned 64-bit argument X, return the value corresponding to rotating the bits N steps to the left. N must be between 1 and - 31 inclusive. */ + 63 inclusive. */ static inline uint64_t rotl64 (uint64_t x, int n) { @@ -33,7 +33,7 @@ rotl64 (uint64_t x, int n) /* Given an unsigned 64-bit argument X, return the value corresponding to rotating the bits N steps to the right. N must be between 1 to - 31 inclusive.*/ + 63 inclusive.*/ static inline uint64_t rotr64 (uint64_t x, int n) { diff --git a/tests/test-bitrotate.c b/tests/test-bitrotate.c index 41f4d2651..5b7d171e3 100644 --- a/tests/test-bitrotate.c +++ b/tests/test-bitrotate.c @@ -151,7 +151,7 @@ main (void) ASSERT (rotr32 (2309737967U, 30) == 649017278lU); ASSERT (rotr32 (2309737967U, 31) == 324508639lU); -#if defined(UINT64_MAX) && defined(UINT64_C) +#ifdef UINT64_MAX ASSERT (rotl64 (16045690984503098046ULL, 1) == 13644637895296644477ULL); ASSERT (rotl64 (16045690984503098046ULL, 2) == 8842531716883737339ULL); ASSERT (rotl64 (16045690984503098046ULL, 3) == 17685063433767474678ULL); @@ -280,7 +280,7 @@ main (void) ASSERT (rotr64 (16045690984503098046ULL, 61) == 17685063433767474678ULL); ASSERT (rotr64 (16045690984503098046ULL, 62) == 8842531716883737339ULL); ASSERT (rotr64 (16045690984503098046ULL, 63) == 13644637895296644477ULL); -#endif +#endif /* UINT64_MAX */ return 0; } -- 2.11.0