Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
Ralf Baechle | 9cfde20 | 2007-02-14 21:16:14 +0000 | [diff] [blame] | 6 | * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | */ |
Ralf Baechle | 9cfde20 | 2007-02-14 21:16:14 +0000 | [diff] [blame] | 8 | #ifndef __ASM_GENERIC_UNALIGNED_H |
| 9 | #define __ASM_GENERIC_UNALIGNED_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
Ralf Baechle | 9cfde20 | 2007-02-14 21:16:14 +0000 | [diff] [blame] | 11 | #include <linux/compiler.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
Ralf Baechle | 9cfde20 | 2007-02-14 21:16:14 +0000 | [diff] [blame] | 13 | #define get_unaligned(ptr) \ |
| 14 | ({ \ |
| 15 | struct __packed { \ |
| 16 | typeof(*(ptr)) __v; \ |
| 17 | } *__p = (void *) (ptr); \ |
| 18 | __p->__v; \ |
| 19 | }) |
| 20 | |
| 21 | #define put_unaligned(val, ptr) \ |
| 22 | do { \ |
| 23 | struct __packed { \ |
| 24 | typeof(*(ptr)) __v; \ |
| 25 | } *__p = (void *) (ptr); \ |
| 26 | __p->__v = (val); \ |
| 27 | } while(0) |
| 28 | |
| 29 | #endif /* __ASM_GENERIC_UNALIGNED_H */ |