Paul Eggert <[EMAIL PROTECTED]> writes:
> That change looks good. Some minor points:
>
>> +/* Given an unsigned 16-bit argument X, return the value corresponding
>> + to rotating the bits N steps to the left. N must be between 1 to
>> + 15 inclusive. */
>> +static inline uint16_t
>> +rotl16
Paul Eggert <[EMAIL PROTECTED]> writes:
> One other thing: if memory serves, the C standard does not require the
> existence of uint32_t and uint16_t (this is for portability to 36-bit
> hosts, I expect); this can easily be worked around by using #ifdef
> UINT32_MAX and #ifdef UINT16_MAX.
For wha
That change looks good. Some minor points:
> +/* Given an unsigned 16-bit argument X, return the value corresponding
> + to rotating the bits N steps to the left. N must be between 1 to
> + 15 inclusive. */
> +static inline uint16_t
> +rotl16 (uint16_t x, int n)
On all targets of interest f
Eric Blake <[EMAIL PROTECTED]> writes:
> Simon Josefsson josefsson.org> writes:
>
>>
>> Thanks for ideas. I have pushed this.
>>
>>
>> +#if defined UINT64_MAX && defined UINT64_C
>
> Bruno's point was that UINT64_C is not usable in C++ programs. Checking
> UINT64_MAX is sufficient, so lose
Simon Josefsson josefsson.org> writes:
>
> Thanks for ideas. I have pushed this.
>
>
> +#if defined UINT64_MAX && defined UINT64_C
Bruno's point was that UINT64_C is not usable in C++ programs. Checking
UINT64_MAX is sufficient, so lose the &&.
> +/* Given an unsigned 64-bit argument X, r
Thanks for ideas. I have pushed this.
/Simon
>From 4316d00d707d97f660fd0432035780fc0d3f23eb Mon Sep 17 00:00:00 2001
From: Simon Josefsson <[EMAIL PROTECTED]>
Date: Tue, 2 Sep 2008 15:53:09 +0200
Subject: [PATCH] bitrotate: Add 64-bit rotates.
Suggested by Bruce Korb <[EMAIL PROTECTED]> with id
Ben Pfaff wrote:
> > There was a suggestion to support 64-bit rotates as well. That would
> > use uint64_t. Does stdint.m4 define some symbol that may be useful
> > here?
>
> I believe that UINT64_C (for writing an unsigned 64-bit integer
> literal) is defined if and only if uint64_t is availabl
Simon Josefsson <[EMAIL PROTECTED]> writes:
> There was a suggestion to support 64-bit rotates as well. That would
> use uint64_t. Does stdint.m4 define some symbol that may be useful
> here?
I believe that UINT64_C (for writing an unsigned 64-bit integer
literal) is defined if and only if uint
Paolo Bonzini <[EMAIL PROTECTED]> writes:
>> I suspect the rotation part is the sarl+sall and or. Either we could
>> experiment with changing the code, or we could try to make gcc detect
>> that this code actually is a rotate... Possibly gcc already does that
>> right thing, with today's CPU arc
There was a suggestion to support 64-bit rotates as well. That would
use uint64_t. Does stdint.m4 define some symbol that may be useful
here? The code is rather complex so I'm trying to save time asking here
first. I guess stdint.h cannot always define a uint64_t type, for
example if the platfo
Bruno Haible <[EMAIL PROTECTED]> writes:
> Simon Josefsson wrote:
>> --- a/modules/bitrotate
>> +++ b/modules/bitrotate
>> @@ -1,5 +1,5 @@
>> Description:
>> -Rotate bits in 16 and 32 bit integers.
>> +Rotate bits in 16 and 32 bit integers using stdint.h.
>>
>> Files:
>> lib/bitrotate.h
>
> W
Simon Josefsson wrote:
> --- a/modules/bitrotate
> +++ b/modules/bitrotate
> @@ -1,5 +1,5 @@
> Description:
> -Rotate bits in 16 and 32 bit integers.
> +Rotate bits in 16 and 32 bit integers using stdint.h.
>
> Files:
> lib/bitrotate.h
Well, that's not what I meant. I meant to add a format de
> I suspect the rotation part is the sarl+sall and or. Either we could
> experiment with changing the code, or we could try to make gcc detect
> that this code actually is a rotate... Possibly gcc already does that
> right thing, with today's CPU architectures it can be difficult to know
> which
Paolo Bonzini <[EMAIL PROTECTED]> writes:
>> +/* Given an unsigned 16-bit argument X, return the value corresponding
>> + to rotating the bits N steps to the left. N must be between 1 to
>> + 15 inclusive. */
>> +static inline uint16_t
>> +rotl16 (uint16_t x, int n)
>> +{
>> + return ((x <<
Simon Josefsson wrote:
> +
> +#include
> +
The module description needs to list the dependency to the 'stdint' module.
Bruno
Ben Pfaff wrote:
> Since you're using the inline keyword, you should add a
> dependency on the inline module.
He's only using 'static inline'; therefore an AC_REQUIRE([AC_C_INLINE])
is all that he needs.
> > +/* Given an unsigned 32-bit argument X, return the value corresponding
> > + to rotati
Simon Josefsson <[EMAIL PROTECTED]> writes:
> I have pushed the patch below, but i still appreciate further review of
> the code.
Since you're using the inline keyword, you should add a
dependency on the inline module.
> +/* Given an unsigned 32-bit argument X, return the value corresponding
> +
> +/* Given an unsigned 16-bit argument X, return the value corresponding
> + to rotating the bits N steps to the left. N must be between 1 to
> + 15 inclusive. */
> +static inline uint16_t
> +rotl16 (uint16_t x, int n)
> +{
> + return ((x << n) | (x >> (16 - n))) & 0x;
> +}
& 0xFFF
Paul Eggert <[EMAIL PROTECTED]> writes:
> Simon Josefsson <[EMAIL PROTECTED]> writes:
>
>> +#define rotl32(x,n) \
>> + x) << ((uint16_t)(n))) | ((x) >> (32 - (uint16_t)(n & 0x)
>
> I suggest using inline functions rather than macros, to avoid hassles
> with double-evaluating argum
Simon Josefsson <[EMAIL PROTECTED]> writes:
> +#define rotl32(x,n) \
> + x) << ((uint16_t)(n))) | ((x) >> (32 - (uint16_t)(n & 0x)
I suggest using inline functions rather than macros, to avoid hassles
with double-evaluating arguments. That way, you won't need any casts.
The cast
> +#define rotl32(x,n) \
> + x) << ((uint16_t)(n))) | ((x) >> (32 - (uint16_t)(n & 0x)
> +#define rotr32(x,n) \
> + x) >> ((uint16_t)(n))) | ((x) << (32 - (uint16_t)(n & 0x)
> +#define rotl16(x,n) \
> + x) << ((uint16_t)(n))) | ((x) >> (16 - (uint16_t)(n &
21 matches
Mail list logo