File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed
api/deprecated-avr-comp/avr Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -110,11 +110,23 @@ typedef const void* uint_farptr_t;
110110#define pgm_read_ptr (addr ) (*(void *const *)(addr))
111111#else
112112// Supports misaligned addresses
113- #define pgm_read_byte (addr ) (*(const unsigned char *)(addr))
114- #define pgm_read_word (addr ) ((unsigned short)(pgm_read_byte((intptr_t)addr) | (pgm_read_byte((intptr_t)addr + 1) << 8)))
115- #define pgm_read_dword (addr ) ((unsigned long)(pgm_read_byte((intptr_t)addr) | (pgm_read_byte((intptr_t)addr + 1) << 8)) | \
116- (pgm_read_byte((intptr_t)addr + 2) << 16) | (pgm_read_byte((intptr_t)addr + 3) << 24))
117- #define pgm_read_ptr (addr ) ((void *)pgm_read_dword(addr))
113+ #ifdef __cplusplus
114+ extern "C" {
115+ #endif
116+ static inline unsigned char pgm_read_byte (const void * addr ) {
117+ return * (const unsigned char * )(addr );
118+ }
119+ static inline unsigned short pgm_read_word (const void * addr ) {
120+ const unsigned char * a = (const unsigned char * )addr ;
121+ return pgm_read_byte (a ) | ( pgm_read_byte (a + 1 ) << 8 );
122+ }
123+ static inline unsigned long pgm_read_dword (const void * addr ) {
124+ const unsigned char * a = (const unsigned char * )addr ;
125+ return pgm_read_byte (a ) | ( pgm_read_byte (a + 1 ) << 8 ) | ( pgm_read_byte (a + 2 ) << 16 ) | ( pgm_read_byte (a + 3 ) << 24 );
126+ }
127+ static inline void * pgm_read_ptr (const void * addr ) {
128+ return (void * ) pgm_read_dword (addr );
129+ }
118130static inline float pgm_read_float (const void * addr ) {
119131 union {
120132 void * p ;
@@ -123,6 +135,10 @@ static inline float pgm_read_float(const void *addr) {
123135 x .p = pgm_read_ptr (addr );
124136 return x .f ;
125137}
138+ #ifdef __cplusplus
139+ }
140+ #endif
141+
126142#endif
127143
128144#define pgm_read_byte_near (addr ) pgm_read_byte(addr)
You can’t perform that action at this time.
0 commit comments