23 Jan
2014
23 Jan
'14
4:51 p.m.
Kristian Nielsen <knielsen@knielsen-hq.org> 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.