4 /* Helper functions for accessing (remote) memory. These functions
5 assume that all addresses are naturally aligned (e.g., 32-bit
6 quantity is stored at a 32-bit-aligned address. */
11 fetch8 (unw_addr_space_t as, unw_accessors_t *a,
12 unw_word_t *addr, int8_t *valp, void *arg)
14 *valp = *(int8_t *) (uintptr_t) *addr;
20 fetch16 (unw_addr_space_t as, unw_accessors_t *a,
21 unw_word_t *addr, int16_t *valp, void *arg)
23 *valp = *(int16_t *) (uintptr_t) *addr;
29 fetch32 (unw_addr_space_t as, unw_accessors_t *a,
30 unw_word_t *addr, int32_t *valp, void *arg)
32 *valp = *(int32_t *) (uintptr_t) *addr;
38 fetchw (unw_addr_space_t as, unw_accessors_t *a,
39 unw_word_t *addr, unw_word_t *valp, void *arg)
41 *valp = *(unw_word_t *) (uintptr_t) *addr;
42 *addr += sizeof (unw_word_t);
46 #else /* !UNW_LOCAL_ONLY */
48 #define WSIZE (sizeof (unw_word_t))
51 fetch8 (unw_addr_space_t as, unw_accessors_t *a,
52 unw_word_t *addr, int8_t *valp, void *arg)
54 unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr;
59 ret = (*a->access_mem) (as, aligned_addr, &val, 0, arg);
61 #if __BYTE_ORDER == __LITTLE_ENDIAN
64 val >>= 8*(WSIZE - 1 - off);
71 fetch16 (unw_addr_space_t as, unw_accessors_t *a,
72 unw_word_t *addr, int16_t *valp, void *arg)
74 unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr;
82 ret = (*a->access_mem) (as, aligned_addr, &val, 0, arg);
84 #if __BYTE_ORDER == __LITTLE_ENDIAN
87 val >>= 8*(WSIZE - 2 - off);
94 fetch32 (unw_addr_space_t as, unw_accessors_t *a,
95 unw_word_t *addr, int32_t *valp, void *arg)
97 unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr;
100 if ((off & 0x3) != 0)
105 ret = (*a->access_mem) (as, aligned_addr, &val, 0, arg);
107 #if __BYTE_ORDER == __LITTLE_ENDIAN
110 val >>= 8*(WSIZE - 4 - off);
112 *valp = val & 0xffffffff;
117 fetchw (unw_addr_space_t as, unw_accessors_t *a,
118 unw_word_t *addr, unw_word_t *valp, void *arg)
122 ret = (*a->access_mem) (as, *addr, valp, 0, arg);
127 #endif /* !UNW_LOCAL_ONLY */
129 #endif /* REMOTE_H */