diff options
author | Olivier Houchard <cognet@FreeBSD.org> | 2007-09-09 11:58:38 +0000 |
---|---|---|
committer | Olivier Houchard <cognet@FreeBSD.org> | 2007-09-09 11:58:38 +0000 |
commit | 4168e66b1f26a390f6908cb50bae5e0b83a9c9dd (patch) | |
tree | d8428929a8f5dc0e2296d04f901c61f45d3decb8 /sys/arm/include/endian.h | |
parent | a3a60860c82b854af51d9f97e1a7fd53b4e28f1e (diff) |
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)
Notes
Notes:
svn path=/head/; revision=172104
Diffstat (limited to 'sys/arm/include/endian.h')
-rw-r--r-- | sys/arm/include/endian.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/arm/include/endian.h b/sys/arm/include/endian.h index c99eaf72ff55..715a94569fcb 100644 --- a/sys/arm/include/endian.h +++ b/sys/arm/include/endian.h @@ -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__ |