diff options
Diffstat (limited to 'include/asm-avr32/unaligned.h')
-rw-r--r-- | include/asm-avr32/unaligned.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/asm-avr32/unaligned.h b/include/asm-avr32/unaligned.h new file mode 100644 index 000000000000..3042723fcbfd --- /dev/null +++ b/include/asm-avr32/unaligned.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef __ASM_AVR32_UNALIGNED_H | ||
2 | #define __ASM_AVR32_UNALIGNED_H | ||
3 | |||
4 | /* | ||
5 | * AVR32 can handle some unaligned accesses, depending on the | ||
6 | * implementation. The AVR32 AP implementation can handle unaligned | ||
7 | * words, but halfwords must be halfword-aligned, and doublewords must | ||
8 | * be word-aligned. | ||
9 | * | ||
10 | * TODO: Make all this CPU-specific and optimize. | ||
11 | */ | ||
12 | |||
13 | #include <linux/string.h> | ||
14 | |||
15 | /* Use memmove here, so gcc does not insert a __builtin_memcpy. */ | ||
16 | |||
17 | #define get_unaligned(ptr) \ | ||
18 | ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) | ||
19 | |||
20 | #define put_unaligned(val, ptr) \ | ||
21 | ({ __typeof__(*(ptr)) __tmp = (val); \ | ||
22 | memmove((ptr), &__tmp, sizeof(*(ptr))); \ | ||
23 | (void)0; }) | ||
24 | |||
25 | #endif /* __ASM_AVR32_UNALIGNED_H */ | ||