← Back to team overview

maria-developers team mailing list archive

Re: uint6korr optimization

 

Kristian Nielsen <knielsen@xxxxxxxxxxxxxxx> writes:

> Do it like this:

> static inline ulonglong
> mi_uint6korr(const void *p)
> {
>   uint32 a= *(uint32 *)p;
>   uint16 b= *(uint16 *)(4+(char *)p);
>   ulonglong v= ((ulonglong)a | ((ulonglong)b << 32)) << 16;
>   asm ("bswapq %0" : "=r" (v) : "0" (v));
>   return v;
> }

Note that GCC also has __builtin_bswap64() (and __builtin_bswap32()). They
also generate bswap instruction, but would also work on other platforms...

 - Kristian.


Follow ups

References