Mercurial > hg > octave-lyh > gnulib-hg
changeset 10396:c356b1717aa8
bitrotate: Code improvements.
author | Simon Josefsson <simon@josefsson.org> |
---|---|
date | Tue, 02 Sep 2008 16:59:57 +0200 |
parents | 532b2255aeea |
children | ebacc22075c3 |
files | ChangeLog lib/bitrotate.h tests/test-bitrotate.c |
diffstat | 3 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- a/lib/bitrotate.h +++ b/lib/bitrotate.h @@ -21,10 +21,10 @@ #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 @@ /* 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) {
--- a/tests/test-bitrotate.c +++ b/tests/test-bitrotate.c @@ -151,7 +151,7 @@ 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 @@ ASSERT (rotr64 (16045690984503098046ULL, 61) == 17685063433767474678ULL); ASSERT (rotr64 (16045690984503098046ULL, 62) == 8842531716883737339ULL); ASSERT (rotr64 (16045690984503098046ULL, 63) == 13644637895296644477ULL); -#endif +#endif /* UINT64_MAX */ return 0; }