Boost logo

Boost :

Subject: Re: [boost] [Endian] Performance
From: Adder (adder.thief_at_[hidden])
Date: 2011-09-08 01:25:38

On 9/6/11, Phil Endecott <spam_from_boost_dev_at_[hidden]> wrote:

> Could you post the important bits of your byte_swapper::reverse() to
> the list?

For which compiler ? (-:

16-bit un-optimized version:

    return (x >> 8) | (x << 8);

32-bit un-optimized version (edited for space):

         uint32_t (reverse16 (uint16_t (x >> 16))) |
        (uint32_t (reverse16 (uint16_t (x ))) << 16);

64-bit un-optimized version (edited for space):

         uint64_t (reverse32 (uint32_t (x >> 32))) |
        (uint64_t (reverse32 (uint32_t (x ))) << 32);

GCC 32-bit and 64-bit optimized versions use __builtin_bswap32 and
__builtin_bswap64, with a warning in the documentation pointing to the link that has
just been posted to this list.

Boost list run by bdawes at, gregod at, cpdaniel at, john at