mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-01 04:17:02 -05:00
Fix some potential alignment issues
In ARM platforms we need data aligned for direct access. Use special tricks to access unaligned one.
This commit is contained in:
parent
cbe9f708a4
commit
ac3714aa8a
3 changed files with 49 additions and 38 deletions
|
|
@ -502,6 +502,42 @@ static inline uint64_t util_swap64(uint64_t v)
|
|||
}
|
||||
#endif
|
||||
|
||||
static inline uint32_t util_read32(const void* ptr)
|
||||
{
|
||||
uint32_t v;
|
||||
memcpy(&v, ptr, sizeof(v));
|
||||
#if WORDS_BIGENDIAN
|
||||
v = util_swap32(v);
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline uint64_t util_read64(const void* ptr)
|
||||
{
|
||||
uint64_t v;
|
||||
memcpy(&v, ptr, sizeof(v));
|
||||
#if WORDS_BIGENDIAN
|
||||
v = util_swap64(v);
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline void util_write32(void* ptr, uint32_t v)
|
||||
{
|
||||
#if WORDS_BIGENDIAN
|
||||
v = util_swap32(v);
|
||||
#endif
|
||||
memcpy(ptr, &v, sizeof(v));
|
||||
}
|
||||
|
||||
static inline void util_write64(void* ptr, uint64_t v)
|
||||
{
|
||||
#if WORDS_BIGENDIAN
|
||||
v = util_swap64(v);
|
||||
#endif
|
||||
memcpy(ptr, &v, sizeof(v));
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* hash */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue