progmem.h (pgm_read_char): Define depending on __AVR_HAVE_LPMX__

* gcc.target/avr/progmem.h (pgm_read_char): Define depending on
	__AVR_HAVE_LPMX__

From-SVN: r185583
This commit is contained in:
Georg-Johann Lay 2012-03-20 17:38:29 +00:00 committed by Georg-Johann Lay
parent 1056a3604b
commit 73f46872b4
2 changed files with 16 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2012-03-20 Georg-Johann Lay <avr@gjlay.de>
* gcc.target/avr/progmem.h (pgm_read_char): Define depending on
__AVR_HAVE_LPMX__
2012-03-20 Georg-Johann Lay <avr@gjlay.de>
PR target/49868

View File

@ -5,6 +5,7 @@
static const char __c[] PROGMEM = (s); \
&__c[0];}))
#ifdef __AVR_HAVE_LPMX__
#define pgm_read_char(addr) \
(__extension__({ \
unsigned int __addr16 = (unsigned int)(addr); \
@ -12,3 +13,13 @@
__asm__ ("lpm %0, %a1" \
: "=r" (__result) : "z" (__addr16)); \
__result; }))
#else
#define pgm_read_char(addr) \
(__extension__({ \
unsigned int __addr16 = (unsigned int)(addr); \
char __result; \
__asm__ ("lpm" "\n\t" \
"mov %0, r0" \
: "=r" (__result) : "z" (__addr16)); \
__result; }))
#endif