bitrotate: Code improvements.
authorSimon Josefsson <simon@josefsson.org>
Tue, 2 Sep 2008 14:59:57 +0000 (16:59 +0200)
committerSimon Josefsson <simon@josefsson.org>
Tue, 2 Sep 2008 14:59:57 +0000 (16:59 +0200)
ChangeLog
lib/bitrotate.h
tests/test-bitrotate.c

index 58c6e5b..b69ee9c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,8 @@
 
        * 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.
 
index b8528b4..65bf682 100644 (file)
 
 #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)
 {
@@ -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)
 {
index 41f4d26..5b7d171 100644 (file)
@@ -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;
 }