Commit bafe68034e3ef5e9f512bd0468001caf34981c41

Authored by Haavard Skinnemoen
1 parent d395991c11

avr32: Work around byteswap bug in gcc < 4.2

gcc versions earlier than 4.2 sign-extends the result of le16_to_cpu()
and friends when we implement __arch__swabX() using
__builtin_bswap_X(). Disable our arch-specific optimizations when those
gcc versions are being used.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>

Showing 1 changed file with 6 additions and 0 deletions Side-by-side Diff

include/asm-avr32/byteorder.h
... ... @@ -12,8 +12,14 @@
12 12 extern unsigned short __builtin_bswap_16(unsigned short x);
13 13 #endif
14 14  
  15 +/*
  16 + * avr32-linux-gcc versions earlier than 4.2 improperly sign-extends
  17 + * the result.
  18 + */
  19 +#if !(__GNUC__ == 4 && __GNUC_MINOR__ < 2)
15 20 #define __arch__swab32(x) __builtin_bswap_32(x)
16 21 #define __arch__swab16(x) __builtin_bswap_16(x)
  22 +#endif
17 23  
18 24 #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
19 25 # define __BYTEORDER_HAS_U64__