1 #ifndef __ALPHA_UNALIGNED_H
2 #define __ALPHA_UNALIGNED_H
5 * The main single-value unaligned transfer routines.
7 #define get_unaligned(ptr) \
8 ((__typeof__(*(ptr)))__get_unaligned((ptr), sizeof(*(ptr))))
9 #define put_unaligned(x,ptr) \
10 __put_unaligned((unsigned long)(x), (ptr), sizeof(*(ptr)))
13 * This is a silly but good way to make sure that
14 * the get/put functions are indeed always optimized,
15 * and that we use the correct sizes.
17 extern void bad_unaligned_access_length(void) __attribute__((noreturn
));
20 * EGCS 1.1 knows about arbitrary unaligned loads. Define some
21 * packed structures to talk about such things with.
24 struct __una_u64
{ __u64 x
__attribute__((packed
)); };
25 struct __una_u32
{ __u32 x
__attribute__((packed
)); };
26 struct __una_u16
{ __u16 x
__attribute__((packed
)); };
29 * Elemental unaligned loads
32 extern inline unsigned long __uldq(const unsigned long * r11
)
34 const struct __una_u64
*ptr
= (const struct __una_u64
*) r11
;
38 extern inline unsigned long __uldl(const unsigned int * r11
)
40 const struct __una_u32
*ptr
= (const struct __una_u32
*) r11
;
44 extern inline unsigned long __uldw(const unsigned short * r11
)
46 const struct __una_u16
*ptr
= (const struct __una_u16
*) r11
;
51 * Elemental unaligned stores
54 extern inline void __ustq(unsigned long r5
, unsigned long * r11
)
56 struct __una_u64
*ptr
= (struct __una_u64
*) r11
;
60 extern inline void __ustl(unsigned long r5
, unsigned int * r11
)
62 struct __una_u32
*ptr
= (struct __una_u32
*) r11
;
66 extern inline void __ustw(unsigned long r5
, unsigned short * r11
)
68 struct __una_u16
*ptr
= (struct __una_u16
*) r11
;
72 extern inline unsigned long __get_unaligned(const void *ptr
, size_t size
)
77 val
= *(const unsigned char *)ptr
;
80 val
= __uldw((const unsigned short *)ptr
);
83 val
= __uldl((const unsigned int *)ptr
);
86 val
= __uldq((const unsigned long *)ptr
);
89 bad_unaligned_access_length();
94 extern inline void __put_unaligned(unsigned long val
, void *ptr
, size_t size
)
98 *(unsigned char *)ptr
= (val
);
101 __ustw(val
, (unsigned short *)ptr
);
104 __ustl(val
, (unsigned int *)ptr
);
107 __ustq(val
, (unsigned long *)ptr
);
110 bad_unaligned_access_length();