Ver código fonte

Workaround for strict aliasing warnings with -O2

main
PaulStoffregen 8 anos atrás
pai
commit
8a02ea67f5
1 arquivos alterados com 16 adições e 0 exclusões
  1. +16
    -0
      teensy3/avr/pgmspace.h

+ 16
- 0
teensy3/avr/pgmspace.h Ver arquivo

@@ -77,9 +77,25 @@ typedef uint64_t prog_uint64_t;
#define fprintf_P(fp, ...) fprintf((fp), __VA_ARGS__)

#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#if 0
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))
#else
#define pgm_read_word(addr) ({ \
typeof(addr) _addr = (addr); \
*(const unsigned short *)(_addr); \
})
#define pgm_read_dword(addr) ({ \
typeof(addr) _addr = (addr); \
*(const unsigned long *)(_addr); \
})
#define pgm_read_float(addr) ({ \
typeof(addr) _addr = (addr); \
*(const float *)(_addr); \
})
#endif


#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)

Carregando…
Cancelar
Salvar