Commit 3106dbcd authored by Al Viro's avatar Al Viro Committed by Linus Torvalds

[PATCH] __get_unaligned() turned into macro

Turns __get_unaligned() and __put_unaligned into macros.  That is
definitely safe; leaving them as inlines breaks on e.g.  alpha [try to
build ncpfs there and you'll get unresolved symbols since we end up
getting __get_unaligned() not inlined]. 
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b5a48dad
...@@ -76,46 +76,47 @@ static inline void __ustw(__u16 val, __u16 *addr) ...@@ -76,46 +76,47 @@ static inline void __ustw(__u16 val, __u16 *addr)
ptr->x = val; ptr->x = val;
} }
static inline unsigned long __get_unaligned(const void *ptr, size_t size) #define __get_unaligned(ptr, size) ({ \
{ const void *__gu_p = ptr; \
unsigned long val; unsigned long val; \
switch (size) { switch (size) { \
case 1: case 1: \
val = *(const __u8 *)ptr; val = *(const __u8 *)__gu_p; \
break; break; \
case 2: case 2: \
val = __uldw((const __u16 *)ptr); val = __uldw(__gu_p); \
break; break; \
case 4: case 4: \
val = __uldl((const __u32 *)ptr); val = __uldl(__gu_p); \
break; break; \
case 8: case 8: \
val = __uldq((const __u64 *)ptr); val = __uldq(__gu_p); \
break; break; \
default: default: \
bad_unaligned_access_length(); bad_unaligned_access_length(); \
}; }; \
return val; val; \
} })
static inline void __put_unaligned(unsigned long val, void *ptr, size_t size) #define __put_unaligned(val, ptr, size) \
{ do { \
switch (size) { void *__gu_p = ptr; \
case 1: switch (size) { \
*(__u8 *)ptr = val; case 1: \
break; *(__u8 *)__gu_p = val; \
case 2: break; \
__ustw(val, (__u16 *)ptr); case 2: \
break; __ustw(val, __gu_p); \
case 4: break; \
__ustl(val, (__u32 *)ptr); case 4: \
break; __ustl(val, __gu_p); \
case 8: break; \
__ustq(val, (__u64 *)ptr); case 8: \
break; __ustq(val, __gu_p); \
default: break; \
bad_unaligned_access_length(); default: \
}; bad_unaligned_access_length(); \
} }; \
} while(0)
#endif /* _ASM_GENERIC_UNALIGNED_H */ #endif /* _ASM_GENERIC_UNALIGNED_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment