Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 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 */ |