blob: 3249049e93aafcc8eeb345b07a6d220f29a7398e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Baechle9cfde202007-02-14 21:16:14 +00006 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 */
Ralf Baechle9cfde202007-02-14 21:16:14 +00008#ifndef __ASM_GENERIC_UNALIGNED_H
9#define __ASM_GENERIC_UNALIGNED_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
Ralf Baechle9cfde202007-02-14 21:16:14 +000011#include <linux/compiler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Ralf Baechle9cfde202007-02-14 21:16:14 +000013#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) \
22do { \
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 */