unaligned.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * OpenRISC Linux
  3. *
  4. * Linux architectural port borrowing liberally from similar works of
  5. * others. All original copyrights apply as per the original source
  6. * declaration.
  7. *
  8. * OpenRISC implementation:
  9. * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
  10. * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
  11. * et al.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. */
  18. #ifndef __ASM_OPENRISC_UNALIGNED_H
  19. #define __ASM_OPENRISC_UNALIGNED_H
  20. /*
  21. * This is copied from the generic implementation and the C-struct
  22. * variant replaced with the memmove variant. The GCC compiler
  23. * for the OR32 arch optimizes too aggressively for the C-struct
  24. * variant to work, so use the memmove variant instead.
  25. *
  26. * It may be worth considering implementing the unaligned access
  27. * exception handler and allowing unaligned accesses (access_ok.h)...
  28. * not sure if it would be much of a performance win without further
  29. * investigation.
  30. */
  31. #include <asm/byteorder.h>
  32. #if defined(__LITTLE_ENDIAN)
  33. # include <linux/unaligned/le_memmove.h>
  34. # include <linux/unaligned/be_byteshift.h>
  35. # include <linux/unaligned/generic.h>
  36. # define get_unaligned __get_unaligned_le
  37. # define put_unaligned __put_unaligned_le
  38. #elif defined(__BIG_ENDIAN)
  39. # include <linux/unaligned/be_memmove.h>
  40. # include <linux/unaligned/le_byteshift.h>
  41. # include <linux/unaligned/generic.h>
  42. # define get_unaligned __get_unaligned_be
  43. # define put_unaligned __put_unaligned_be
  44. #else
  45. # error need to define endianess
  46. #endif
  47. #endif /* __ASM_OPENRISC_UNALIGNED_H */