mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
import use of __PROG_TYPES_COMPAT__ define for compatibility with old arduino code (#4619)
restrict usage of deprecated typedefs "prog_*", and cast "pgm_read_*"'s address parameters to "const void*" only when __PROG_TYPES_COMPAT__ is defined. also add <avr/pgmspace.h> compatibility
This commit is contained in:
parent
1ca5838bed
commit
2315ac20bc
1
cores/esp8266/avr/pgmspace.h
Normal file
1
cores/esp8266/avr/pgmspace.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "../pgmspace.h"
|
@ -29,6 +29,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define _SFR_BYTE(n) (n)
|
#define _SFR_BYTE(n) (n)
|
||||||
|
|
||||||
|
#ifdef __PROG_TYPES_COMPAT__
|
||||||
|
|
||||||
typedef void prog_void;
|
typedef void prog_void;
|
||||||
typedef char prog_char;
|
typedef char prog_char;
|
||||||
typedef unsigned char prog_uchar;
|
typedef unsigned char prog_uchar;
|
||||||
@ -39,6 +41,8 @@ typedef uint16_t prog_uint16_t;
|
|||||||
typedef int32_t prog_int32_t;
|
typedef int32_t prog_int32_t;
|
||||||
typedef uint32_t prog_uint32_t;
|
typedef uint32_t prog_uint32_t;
|
||||||
|
|
||||||
|
#endif // defined(__PROG_TYPES_COMPAT__)
|
||||||
|
|
||||||
#define SIZE_IRRELEVANT 0x7fffffff
|
#define SIZE_IRRELEVANT 0x7fffffff
|
||||||
|
|
||||||
// memchr_P and memrchr_P are not implemented due to danger in its use, and
|
// 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
|
// Make sure, that libraries checking existence of this macro are not failing
|
||||||
|
#ifdef __PROG_TYPES_COMPAT__
|
||||||
|
#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_byte(addr) pgm_read_byte_inlined(addr)
|
||||||
#define pgm_read_word(addr) pgm_read_word_inlined(addr)
|
#define pgm_read_word(addr) pgm_read_word_inlined(addr)
|
||||||
|
#endif
|
||||||
|
|
||||||
#else //__ets__
|
#else //__ets__
|
||||||
#define pgm_read_byte(addr) (*reinterpret_cast<const uint8_t*>(addr))
|
#define pgm_read_byte(addr) (*reinterpret_cast<const uint8_t*>(addr))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user