Skip to content

Fix Progmem read over optimization #3164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cores/esp8266/pgmspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ int vsnprintf_P(char *str, size_t strSize, PGM_P formatP, va_list ap) __attribut
PGM_P __local = (PGM_P)(addr); /* isolate varible for macro expansion */ \
ptrdiff_t __offset = ((uint32_t)__local & 0x00000003); /* byte aligned mask */ \
const uint32_t* __addr32 = (const uint32_t*)((const uint8_t*)(__local)-__offset); \
uint8_t __result = ((*__addr32) >> (__offset * 8)); \
uint32_t volatile __data32 = *__addr32; /* stop compiler from optimizing 32bit aligned addresses */ \
uint8_t __result = (__data32 >> (__offset * 8)); \
__result; \
}))

Expand All @@ -101,7 +102,8 @@ int vsnprintf_P(char *str, size_t strSize, PGM_P formatP, va_list ap) __attribut
PGM_P __local = (PGM_P)(addr); /* isolate varible for macro expansion */ \
ptrdiff_t __offset = ((uint32_t)__local & 0x00000002); /* word aligned mask */ \
const uint32_t* __addr32 = (const uint32_t*)((const uint8_t*)(__local) - __offset); \
uint16_t __result = ((*__addr32) >> (__offset * 8)); \
uint32_t volatile __data32 = *__addr32; /* stop compiler from optimizing 32bit aligned addresses */ \
uint16_t __result = (__data32 >> (__offset * 8)); \
__result; \
}))
#else //__ets__
Expand Down