On Fri, Mar 11, 2011 at 04:50:08PM +0100, Mike Belopuhov wrote:
> recent commit to pirofti made me wonder why don't we take an advantage
> of the 64 bit bswap instruction on amd64?

Bah, you beat me to it!

bswap r64 is the way to do it, but I'm not sure what the second line is
supposed to do.

> 
> Index: arch/amd64/include/endian.h
> ===================================================================
> RCS file: /home/cvs/src/sys/arch/amd64/include/endian.h,v
> retrieving revision 1.3
> diff -u -p -r1.3 endian.h
> --- arch/amd64/include/endian.h       13 Dec 2005 00:35:22 -0000      1.3
> +++ arch/amd64/include/endian.h       11 Mar 2011 15:47:40 -0000
> @@ -36,12 +36,11 @@
>       __swap32md_x;                                                   \
>  })
>  
> -/* XXX - I'm sure there is a better way on this cpu. */
>  #define      __swap64md(x) ({                                                
> \
>       u_int64_t __swap64md_x = (x);                                   \
>                                                                       \
> -     (u_int64_t)__swap32md(__swap64md_x >> 32) |                     \
> -         (u_int64_t)__swap32md(__swap64md_x & 0xffffffff) << 32;     \
> +     __asm ("bswapq %1" : "+r" (__swap64md_x));                      \
> +     __swap64md_x;                                                   \
>  })
>  
>  #define      __swap16md(x) ({                                                
> \

Reply via email to