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
;
77 assert ((off
& 0x1) == 0);
81 ret
= (*a
->access_mem
) (as
, aligned_addr
, &val
, 0, arg
);
83 #if __BYTE_ORDER == __LITTLE_ENDIAN
86 val
>>= 8*(WSIZE
- 2 - off
);
93 fetch32 (unw_addr_space_t as
, unw_accessors_t
*a
,
94 unw_word_t
*addr
, int32_t *valp
, void *arg
)
96 unw_word_t val
, aligned_addr
= *addr
& -WSIZE
, off
= *addr
- aligned_addr
;
99 assert ((off
& 0x3) == 0);
103 ret
= (*a
->access_mem
) (as
, aligned_addr
, &val
, 0, arg
);
105 #if __BYTE_ORDER == __LITTLE_ENDIAN
108 val
>>= 8*(WSIZE
- 4 - off
);
110 *valp
= val
& 0xffffffff;
115 fetchw (unw_addr_space_t as
, unw_accessors_t
*a
,
116 unw_word_t
*addr
, unw_word_t
*valp
, void *arg
)
120 ret
= (*a
->access_mem
) (as
, *addr
, valp
, 0, arg
);
125 #endif /* !UNW_LOCAL_ONLY */
127 #endif /* REMOTE_H */