* lib/bitrotate.h (rotl64, rotr64): Add. Suggested by Bruce Korb
<bruce.korb@gmail.com> with ideas from Ben Pfaff
- <blp@cs.stanford.edu> and Bruno Haible <bruno@clisp.org>.
+ <blp@cs.stanford.edu>, Bruno Haible <bruno@clisp.org> and Eric
+ Blake <ebb9@byu.net>.
* tests/test-bitrotate.c: Add more test vectors.
#include <stdint.h>
-#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)
{
/* 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)
{
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);
ASSERT (rotr64 (16045690984503098046ULL, 61) == 17685063433767474678ULL);
ASSERT (rotr64 (16045690984503098046ULL, 62) == 8842531716883737339ULL);
ASSERT (rotr64 (16045690984503098046ULL, 63) == 13644637895296644477ULL);
-#endif
+#endif /* UINT64_MAX */
return 0;
}