-
Notifications
You must be signed in to change notification settings - Fork 13.3k
pgm_read_*: cast address to const void* #4619
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
Changes from all commits
53a576b
a055e4a
e3ff5ea
9c9e74c
259b63c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "../pgmspace.h" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,8 @@ extern "C" { | |
|
||
#define _SFR_BYTE(n) (n) | ||
|
||
#ifdef __PROG_TYPES_COMPAT__ | ||
|
||
typedef void prog_void; | ||
typedef char prog_char; | ||
typedef unsigned char prog_uchar; | ||
|
@@ -39,6 +41,8 @@ typedef uint16_t prog_uint16_t; | |
typedef int32_t prog_int32_t; | ||
typedef uint32_t prog_uint32_t; | ||
|
||
#endif // defined(__PROG_TYPES_COMPAT__) | ||
|
||
#define SIZE_IRRELEVANT 0x7fffffff | ||
|
||
// memchr_P and memrchr_P are not implemented due to danger in its use, and | ||
|
@@ -112,8 +116,13 @@ static inline uint16_t pgm_read_word_inlined(const void* addr) { | |
} | ||
|
||
// Make sure, that libraries checking existence of this macro are not failing | ||
#ifdef __PROG_TYPES_COMPAT__ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (deleted an earlier comment after seeing the reference to Looking at https://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the esp8266 pgmspace.h always creates all the deprecated AVR pgmspace types that this define enables in the AVR version, this name seems ok for this usage to me. i.e. from a user perspective setting this define ensures you get the deprecated progmem types as well as the old behavior that was present when those types existed. I guess technically to be fully compatible with the AVR version the deprecated AVR pgmspace types should also be removed in the esp8266 version if the define is not set but currently the deprecated types always exist in the esp8266 version - which is a difference but is likely to be pretty harmless. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bperrybap I guess you made it through, merge is coming. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've been following along. Everything seems reasonable for very close compatibility.
On my test/development system I have 80 Arduino libraries installed.
This one may be a bit more tricky since I've seen that a few library authors have already gone in and modified their code with ifdefs for the different location on esp8266. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, you already have included in the merged PR :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops. I see that now. Sorry I missed that. I only saw the diffs in the header file itself. |
||
#define pgm_read_byte(addr) pgm_read_byte_inlined((const void*)(addr)) | ||
#define pgm_read_word(addr) pgm_read_word_inlined((const void*)(addr)) | ||
#else | ||
#define pgm_read_byte(addr) pgm_read_byte_inlined(addr) | ||
#define pgm_read_word(addr) pgm_read_word_inlined(addr) | ||
#endif | ||
|
||
#else //__ets__ | ||
#define pgm_read_byte(addr) (*reinterpret_cast<const uint8_t*>(addr)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@igrr now that the should-have-been-deprecated typedefs are using this avr macro, is it OK to keep it for pgm_read_* type cast too ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, should be okay.