mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Support: Add {read,write}{16,32,64}{le,be} functions.
Add convenient functions for endian-aware reads/writes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231002 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7f9bc0986b
commit
955419ebf0
@ -195,7 +195,23 @@ typedef detail::packed_endian_specific_integral
|
||||
<int32_t, native, unaligned> unaligned_int32_t;
|
||||
typedef detail::packed_endian_specific_integral
|
||||
<int64_t, native, unaligned> unaligned_int64_t;
|
||||
} // end namespace llvm
|
||||
|
||||
namespace endian {
|
||||
inline uint16_t read16le(const void *p) { return *(ulittle16_t *)p; }
|
||||
inline uint32_t read32le(const void *p) { return *(ulittle32_t *)p; }
|
||||
inline uint64_t read64le(const void *p) { return *(ulittle64_t *)p; }
|
||||
inline uint16_t read16be(const void *p) { return *(ubig16_t *)p; }
|
||||
inline uint32_t read32be(const void *p) { return *(ubig32_t *)p; }
|
||||
inline uint64_t read64be(const void *p) { return *(ubig64_t *)p; }
|
||||
|
||||
inline void write16le(void *p, uint16_t v) { *(ulittle16_t *)p = v; }
|
||||
inline void write32le(void *p, uint32_t v) { *(ulittle32_t *)p = v; }
|
||||
inline void write64le(void *p, uint64_t v) { *(ulittle64_t *)p = v; }
|
||||
inline void write16be(void *p, uint16_t v) { *(ubig16_t *)p = v; }
|
||||
inline void write32be(void *p, uint32_t v) { *(ubig32_t *)p = v; }
|
||||
inline void write64be(void *p, uint64_t v) { *(ubig64_t *)p = v; }
|
||||
} // end namespace endian
|
||||
} // end namespace support
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user