[ARM] 3849/1: fix get_unaligned() for gcc >= 4.1
gcc 4.1's __typeof__ propagates 'const', which breaks get_unaligned(). Rewrite get_unaligned() not to use __typeof__. Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
parent
3b7a86c2f0
commit
17b602b1c1
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
extern int __bug_unaligned_x(void *ptr);
|
extern int __bug_unaligned_x(const void *ptr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* What is the most efficient way of loading/storing an unaligned value?
|
* What is the most efficient way of loading/storing an unaligned value?
|
||||||
|
@ -51,44 +51,32 @@ extern int __bug_unaligned_x(void *ptr);
|
||||||
#define __get_unaligned_4_be(__p) \
|
#define __get_unaligned_4_be(__p) \
|
||||||
(__p[0] << 24 | __p[1] << 16 | __p[2] << 8 | __p[3])
|
(__p[0] << 24 | __p[1] << 16 | __p[2] << 8 | __p[3])
|
||||||
|
|
||||||
#define __get_unaligned_le(ptr) \
|
#define __get_unaligned_8_le(__p) \
|
||||||
({ \
|
((unsigned long long)__get_unaligned_4_le((__p+4)) << 32 | \
|
||||||
__typeof__(*(ptr)) __v; \
|
__get_unaligned_4_le(__p))
|
||||||
__u8 *__p = (__u8 *)(ptr); \
|
|
||||||
switch (sizeof(*(ptr))) { \
|
#define __get_unaligned_8_be(__p) \
|
||||||
case 1: __v = *(ptr); break; \
|
((unsigned long long)__get_unaligned_4_be(__p) << 32 | \
|
||||||
case 2: __v = __get_unaligned_2_le(__p); break; \
|
__get_unaligned_4_be((__p+4)))
|
||||||
case 4: __v = __get_unaligned_4_le(__p); break; \
|
|
||||||
case 8: { \
|
#define __get_unaligned_le(ptr) \
|
||||||
unsigned int __v1, __v2; \
|
({ \
|
||||||
__v2 = __get_unaligned_4_le((__p+4)); \
|
const __u8 *__p = (const __u8 *)(ptr); \
|
||||||
__v1 = __get_unaligned_4_le(__p); \
|
__builtin_choose_expr(sizeof(*(ptr)) == 1, *__p, \
|
||||||
__v = ((unsigned long long)__v2 << 32 | __v1); \
|
__builtin_choose_expr(sizeof(*(ptr)) == 2, __get_unaligned_2_le(__p), \
|
||||||
} \
|
__builtin_choose_expr(sizeof(*(ptr)) == 4, __get_unaligned_4_le(__p), \
|
||||||
break; \
|
__builtin_choose_expr(sizeof(*(ptr)) == 8, __get_unaligned_8_le(__p), \
|
||||||
default: __v = __bug_unaligned_x(__p); break; \
|
(void)__bug_unaligned_x(__p))))); \
|
||||||
} \
|
|
||||||
__v; \
|
|
||||||
})
|
})
|
||||||
|
|
||||||
#define __get_unaligned_be(ptr) \
|
#define __get_unaligned_be(ptr) \
|
||||||
({ \
|
({ \
|
||||||
__typeof__(*(ptr)) __v; \
|
const __u8 *__p = (const __u8 *)(ptr); \
|
||||||
__u8 *__p = (__u8 *)(ptr); \
|
__builtin_choose_expr(sizeof(*(ptr)) == 1, *__p, \
|
||||||
switch (sizeof(*(ptr))) { \
|
__builtin_choose_expr(sizeof(*(ptr)) == 2, __get_unaligned_2_be(__p), \
|
||||||
case 1: __v = *(ptr); break; \
|
__builtin_choose_expr(sizeof(*(ptr)) == 4, __get_unaligned_4_be(__p), \
|
||||||
case 2: __v = __get_unaligned_2_be(__p); break; \
|
__builtin_choose_expr(sizeof(*(ptr)) == 8, __get_unaligned_8_be(__p), \
|
||||||
case 4: __v = __get_unaligned_4_be(__p); break; \
|
(void)__bug_unaligned_x(__p))))); \
|
||||||
case 8: { \
|
|
||||||
unsigned int __v1, __v2; \
|
|
||||||
__v2 = __get_unaligned_4_be(__p); \
|
|
||||||
__v1 = __get_unaligned_4_be((__p+4)); \
|
|
||||||
__v = ((unsigned long long)__v2 << 32 | __v1); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
default: __v = __bug_unaligned_x(__p); break; \
|
|
||||||
} \
|
|
||||||
__v; \
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue