In __bswap16_var(), make sure the 16 upper bits are cleared; while

optimizing, gcc4 doesn't always do so.

Reported by:	Nathan Whitehorn
Approved by:	re (blanket)
This commit is contained in:
Olivier Houchard 2007-09-09 11:58:38 +00:00
parent a3a60860c8
commit 4168e66b1f

View File

@ -99,13 +99,15 @@ __bswap32_var(__uint32_t v)
static __inline __uint16_t
__bswap16_var(__uint16_t v)
{
__uint32_t ret = v & 0xffff;
__asm __volatile(
"mov %0, %0, ror #8\n"
"orr %0, %0, %0, lsr #16\n"
"bic %0, %0, %0, lsl #16"
: "+r" (v));
: "+r" (ret));
return (v);
return ((__uint16_t)ret);
}
#ifdef __OPTIMIZE__