mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Unaligned access support for pgm_read_word/dword (#5692)
* Unaligned access support for pgm_read_word/dword * Fix pgm_read_ptr_aligned() per #5735 * Allow users to use aligned-only via a #define Adding -DPGM_READ_UNALIGNED=0 or #define PGM_READ_UNALIGNED 0 will change the default at compile-time to only aligned (faster, but less compatible) macro implementations. Default is still to allow unaligned accesses.
This commit is contained in:
committed by
GitHub
parent
882d5ba422
commit
885276e75c
@ -31,13 +31,13 @@
|
||||
#define pgm_read_word(addr) (*reinterpret_cast<const uint16_t*>(addr))
|
||||
#define pgm_read_dword(addr) (*reinterpret_cast<const uint32_t*>(addr))
|
||||
#define pgm_read_float(addr) (*reinterpret_cast<const float>(addr))
|
||||
#define pgm_read_ptr(addr) (*reinterpret_cast<const void const *>(addr))
|
||||
#define pgm_read_ptr(addr) (*reinterpret_cast<const void* const *>(addr))
|
||||
#else
|
||||
#define pgm_read_byte(addr) (*(const uint8_t*)(addr))
|
||||
#define pgm_read_word(addr) (*(const uint16_t*)(addr))
|
||||
#define pgm_read_dword(addr) (*(const uint32_t*)(addr))
|
||||
#define pgm_read_float(addr) (*(const float)(addr))
|
||||
#define pgm_read_ptr(addr) (*(const void const *)(addr))
|
||||
#define pgm_read_ptr(addr) (*(const void* const *)(addr))
|
||||
#endif
|
||||
|
||||
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
|
||||
|
Reference in New Issue
Block a user