1 #ifndef _ASM_IA64_UNALIGNED_H
2 #define _ASM_IA64_UNALIGNED_H
4 #include <linux/types.h>
7 * The main single-value unaligned transfer routines.
9 * Based on <asm-alpha/unaligned.h>.
11 * Copyright (C) 1998, 1999, 2003 Hewlett-Packard Co
12 * David Mosberger-Tang <davidm@hpl.hp.com>
14 #define get_unaligned(ptr) \
15 ((__typeof__(*(ptr)))ia64_get_unaligned((ptr), sizeof(*(ptr))))
17 #define put_unaligned(x,ptr) \
18 ia64_put_unaligned((unsigned long)(x), (ptr), sizeof(*(ptr)))
20 struct __una_u64 { __u64 x __attribute__((packed)); };
21 struct __una_u32 { __u32 x __attribute__((packed)); };
22 struct __una_u16 { __u16 x __attribute__((packed)); };
24 static inline unsigned long
25 __uld8 (const unsigned long * addr)
27 const struct __una_u64 *ptr = (const struct __una_u64 *) addr;
31 static inline unsigned long
32 __uld4 (const unsigned int * addr)
34 const struct __una_u32 *ptr = (const struct __una_u32 *) addr;
38 static inline unsigned long
39 __uld2 (const unsigned short * addr)
41 const struct __una_u16 *ptr = (const struct __una_u16 *) addr;
46 __ust8 (unsigned long val, unsigned long * addr)
48 struct __una_u64 *ptr = (struct __una_u64 *) addr;
53 __ust4 (unsigned long val, unsigned int * addr)
55 struct __una_u32 *ptr = (struct __una_u32 *) addr;
60 __ust2 (unsigned long val, unsigned short * addr)
62 struct __una_u16 *ptr = (struct __una_u16 *) addr;
68 * This function doesn't actually exist. The idea is that when someone uses the macros
69 * below with an unsupported size (datatype), the linker will alert us to the problem via
70 * an unresolved reference error.
72 extern unsigned long ia64_bad_unaligned_access_length (void);
74 #define ia64_get_unaligned(_ptr,size) \
76 const void *__ia64_ptr = (_ptr); \
77 unsigned long __ia64_val; \
81 __ia64_val = *(const unsigned char *) __ia64_ptr; \
84 __ia64_val = __uld2((const unsigned short *)__ia64_ptr); \
87 __ia64_val = __uld4((const unsigned int *)__ia64_ptr); \
90 __ia64_val = __uld8((const unsigned long *)__ia64_ptr); \
93 __ia64_val = ia64_bad_unaligned_access_length(); \
98 #define ia64_put_unaligned(_val,_ptr,size) \
100 const void *__ia64_ptr = (_ptr); \
101 unsigned long __ia64_val = (_val); \
105 *(unsigned char *)__ia64_ptr = (__ia64_val); \
108 __ust2(__ia64_val, (unsigned short *)__ia64_ptr); \
111 __ust4(__ia64_val, (unsigned int *)__ia64_ptr); \
114 __ust8(__ia64_val, (unsigned long *)__ia64_ptr); \
117 ia64_bad_unaligned_access_length(); \
121 #endif /* _ASM_IA64_UNALIGNED_H */