Staging
v0.8.1
https://github.com/torvalds/linux
Raw File
Tip revision: 3bf8ba38f38d3647368e4edcf7d019f9f8d9184a authored by Linus Torvalds on 24 December 2006, 04:00:32 UTC
Linux 2.6.20-rc2
Tip revision: 3bf8ba3
unaligned.h
#ifndef __ASM_AVR32_UNALIGNED_H
#define __ASM_AVR32_UNALIGNED_H

/*
 * AVR32 can handle some unaligned accesses, depending on the
 * implementation.  The AVR32 AP implementation can handle unaligned
 * words, but halfwords must be halfword-aligned, and doublewords must
 * be word-aligned.
 *
 * TODO: Make all this CPU-specific and optimize.
 */

#include <linux/string.h>

/* Use memmove here, so gcc does not insert a __builtin_memcpy. */

#define get_unaligned(ptr) \
  ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; })

#define put_unaligned(val, ptr)				\
  ({ __typeof__(*(ptr)) __tmp = (val);			\
     memmove((ptr), &__tmp, sizeof(*(ptr)));		\
     (void)0; })

#endif /* __ASM_AVR32_UNALIGNED_H */
back to top