81#define __PGMSPACE_H_ 1
92#define __ATTR_CONST__ __attribute__((__const__))
95#ifndef __ATTR_PROGMEM__
96#define __ATTR_PROGMEM__ __attribute__((__progmem__))
100#define __ATTR_PURE__ __attribute__((__pure__))
103#ifndef __ATTR_ALWAYS_INLINE__
104#define __ATTR_ALWAYS_INLINE__ __inline__ __attribute__((__always_inline__))
107#define PROGMEM __ATTR_PROGMEM__
125#define PROGMEM_FAR __attribute__((__section__(".progmemx.data")))
135#define PROGMEM __attribute__((__progmem__))
301#if defined(__AVR_TINY__)
306#define __LPM__1(res, addr) res = *addr
307#define __LPM__2(res, addr) res = *addr
308#define __LPM__3(res, addr) res = *addr
309#define __LPM__4(res, addr) res = *addr
310#define __LPM__8(res, addr) res = *addr
312#elif defined(__AVR_HAVE_LPMX__)
313#define __LPM__1(res, addr) \
314 __asm __volatile__ ("lpm %0,%a1" \
315 : "=r" (res) : "z" (addr))
317#define __LPM__2(res, addr) \
318 __asm __volatile__ ("lpm %A0,%a1+" "\n\t" \
320 : "=r" (res), "+z" (addr))
322#define __LPM__3(res, addr) \
323 __asm __volatile__ ("lpm %A0,%a1+" "\n\t" \
324 "lpm %B0,%a1+" "\n\t" \
326 : "=r" (res), "+z" (addr))
328#define __LPM__4(res, addr) \
329 __asm __volatile__ ("lpm %A0,%a1+" "\n\t" \
330 "lpm %B0,%a1+" "\n\t" \
331 "lpm %C0,%a1+" "\n\t" \
333 : "=r" (res), "+z" (addr))
335#define __LPM__8(res, addr) \
336 __asm __volatile__ ("lpm %r0+0,%a1+" "\n\t" \
337 "lpm %r0+1,%a1+" "\n\t" \
338 "lpm %r0+2,%a1+" "\n\t" \
339 "lpm %r0+3,%a1+" "\n\t" \
340 "lpm %r0+4,%a1+" "\n\t" \
341 "lpm %r0+5,%a1+" "\n\t" \
342 "lpm %r0+6,%a1+" "\n\t" \
344 : "=r" (res), "+z" (addr))
346#define __LPM__1(res, addr) \
347 __asm __volatile__ ("lpm $ mov %A0,r0" \
348 : "=r" (res) : "z" (addr) : "r0")
350#define __LPM__2(res, addr) \
351 __asm __volatile__ ("lpm $ mov %A0,r0 $ adiw %1,1" "\n\t" \
353 : "=r" (res), "+z" (addr) :: "r0")
355#define __LPM__3(res, addr) \
356 __asm __volatile__ ("lpm $ mov %A0,r0 $ adiw %1,1" "\n\t" \
357 "lpm $ mov %B0,r0 $ adiw %1,1" "\n\t" \
359 : "=r" (res), "+z" (addr) :: "r0")
361#define __LPM__4(res, addr) \
362 __asm __volatile__ ("lpm $ mov %A0,r0 $ adiw %1,1" "\n\t" \
363 "lpm $ mov %B0,r0 $ adiw %1,1" "\n\t" \
364 "lpm $ mov %C0,r0 $ adiw %1,1" "\n\t" \
366 : "=r" (res), "+z" (addr) :: "r0")
368#define __LPM__8(res, addr) \
369 __asm __volatile__ ("lpm $ mov %r0+0,r0 $ adiw %1,1" "\n\t" \
370 "lpm $ mov %r0+1,r0 $ adiw %1,1" "\n\t" \
371 "lpm $ mov %r0+2,r0 $ adiw %1,1" "\n\t" \
372 "lpm $ mov %r0+3,r0 $ adiw %1,1" "\n\t" \
373 "lpm $ mov %r0+4,r0 $ adiw %1,1" "\n\t" \
374 "lpm $ mov %r0+5,r0 $ adiw %1,1" "\n\t" \
375 "lpm $ mov %r0+6,r0 $ adiw %1,1" "\n\t" \
376 "lpm $ mov %r0+7,r0" \
377 : "=r" (res), "+z" (addr) :: "r0")
380#define _Avrlibc_Def_Pgm_1(Name, Typ) \
381 static __ATTR_ALWAYS_INLINE__ \
382 Typ pgm_read_##Name (const Typ *__addr) \
385 __LPM__1 (__res, __addr); \
389#define _Avrlibc_Def_Pgm_2(Name, Typ) \
390 static __ATTR_ALWAYS_INLINE__ \
391 Typ pgm_read_##Name (const Typ *__addr) \
394 __LPM__2 (__res, __addr); \
398#define _Avrlibc_Def_Pgm_3(Name, Typ) \
399 static __ATTR_ALWAYS_INLINE__ \
400 Typ pgm_read_##Name (const Typ *__addr) \
403 __LPM__3 (__res, __addr); \
407#define _Avrlibc_Def_Pgm_4(Name, Typ) \
408 static __ATTR_ALWAYS_INLINE__ \
409 Typ pgm_read_##Name (const Typ *__addr) \
412 __LPM__4 (__res, __addr); \
416#define _Avrlibc_Def_Pgm_8(Name, Typ) \
417 static __ATTR_ALWAYS_INLINE__ \
418 Typ pgm_read_##Name (const Typ *__addr) \
421 __LPM__8 (__res, __addr); \
425_Avrlibc_Def_Pgm_1 (
char,
char)
426_Avrlibc_Def_Pgm_1 (unsigned_char,
unsigned char)
427_Avrlibc_Def_Pgm_1 (signed_char,
signed char)
428_Avrlibc_Def_Pgm_1 (u8,
uint8_t)
429_Avrlibc_Def_Pgm_1 (i8,
int8_t)
430#if __SIZEOF_INT__ == 1
431_Avrlibc_Def_Pgm_1 (
int,
int)
432_Avrlibc_Def_Pgm_1 (
signed,
signed)
433_Avrlibc_Def_Pgm_1 (
unsigned,
unsigned)
434_Avrlibc_Def_Pgm_1 (signed_int,
signed int)
435_Avrlibc_Def_Pgm_1 (unsigned_int,
unsigned int)
437#if __SIZEOF_SHORT__ == 1
438_Avrlibc_Def_Pgm_1 (
short,
short)
439_Avrlibc_Def_Pgm_1 (unsigned_short,
unsigned short)
443_Avrlibc_Def_Pgm_2 (i16,
int16_t)
444#if __SIZEOF_INT__ == 2
445_Avrlibc_Def_Pgm_2 (
int,
int)
446_Avrlibc_Def_Pgm_2 (
signed,
signed)
447_Avrlibc_Def_Pgm_2 (
unsigned,
unsigned)
448_Avrlibc_Def_Pgm_2 (signed_int,
signed int)
449_Avrlibc_Def_Pgm_2 (unsigned_int,
unsigned int)
451#if __SIZEOF_SHORT__ == 2
452_Avrlibc_Def_Pgm_2 (
short,
short)
453_Avrlibc_Def_Pgm_2 (unsigned_short,
unsigned short)
455#if __SIZEOF_LONG__ == 2
456_Avrlibc_Def_Pgm_2 (
long,
long)
457_Avrlibc_Def_Pgm_2 (unsigned_long,
unsigned long)
460#if defined(__INT24_MAX__)
461_Avrlibc_Def_Pgm_3 (i24, __int24)
462_Avrlibc_Def_Pgm_3 (u24, __uint24)
466_Avrlibc_Def_Pgm_4 (i32,
int32_t)
467_Avrlibc_Def_Pgm_4 (
float,
float)
468#if __SIZEOF_LONG__ == 4
469_Avrlibc_Def_Pgm_4 (
long,
long)
470_Avrlibc_Def_Pgm_4 (unsigned_long,
unsigned long)
472#if __SIZEOF_LONG_LONG__ == 4
473_Avrlibc_Def_Pgm_4 (long_long,
long long)
474_Avrlibc_Def_Pgm_4 (unsigned_long_long,
unsigned long long)
476#if __SIZEOF_DOUBLE__ == 4
477_Avrlibc_Def_Pgm_4 (
double,
double)
479#if __SIZEOF_LONG_DOUBLE__ == 4
480_Avrlibc_Def_Pgm_4 (long_double,
long double)
483#if __SIZEOF_LONG_LONG__ == 8
485_Avrlibc_Def_Pgm_8 (i64,
int64_t)
486_Avrlibc_Def_Pgm_8 (long_long,
long long)
487_Avrlibc_Def_Pgm_8 (unsigned_long_long,
unsigned long long)
489#if __SIZEOF_DOUBLE__ == 8
490_Avrlibc_Def_Pgm_8 (
double,
double)
492#if __SIZEOF_LONG_DOUBLE__ == 8
493_Avrlibc_Def_Pgm_8 (long_double,
long double)
664#if defined(__AVR_HAVE_ELPMX__)
666#ifdef __AVR_HAVE_RAMPD__
668#define __pgm_clr_RAMPZ_ "\n\t" "out %i2,__zero_reg__"
671#define __pgm_clr_RAMPZ_
674#define __ELPM__1(res, addr, T) \
675 __asm __volatile__ ("movw r30,%1" "\n\t" \
676 "out %i2,%C1" "\n\t" \
680 : "r" (addr), "n" (& RAMPZ) \
683#define __ELPM__2(res, addr, T) \
684 __asm __volatile__ ("movw r30,%1" "\n\t" \
685 "out %i2,%C1" "\n\t" \
686 "elpm %A0,Z+" "\n\t" \
690 : "r" (addr), "n" (& RAMPZ) \
693#define __ELPM__3(res, addr, T) \
694 __asm __volatile__ ("movw r30,%1" "\n\t" \
695 "out %i2,%C1" "\n\t" \
696 "elpm %A0,Z+" "\n\t" \
697 "elpm %B0,Z+" "\n\t" \
701 : "r" (addr), "n" (& RAMPZ) \
704#define __ELPM__4(res, addr, T) \
705 __asm __volatile__ ("movw r30,%1" "\n\t" \
706 "out %i2,%C1" "\n\t" \
707 "elpm %A0,Z+" "\n\t" \
708 "elpm %B0,Z+" "\n\t" \
709 "elpm %C0,Z+" "\n\t" \
713 : "r" (addr), "n" (& RAMPZ) \
716#define __ELPM__8(res, addr, T) \
717 __asm __volatile__ ("movw r30,%1" "\n\t" \
718 "out %i2,%C1" "\n\t" \
719 "elpm %r0+0,Z+" "\n\t" \
720 "elpm %r0+1,Z+" "\n\t" \
721 "elpm %r0+2,Z+" "\n\t" \
722 "elpm %r0+3,Z+" "\n\t" \
723 "elpm %r0+4,Z+" "\n\t" \
724 "elpm %r0+5,Z+" "\n\t" \
725 "elpm %r0+6,Z+" "\n\t" \
729 : "r" (addr), "n" (& RAMPZ) \
739#elif defined(__AVR_HAVE_ELPM__) \
740 && !defined(__AVR_AT43USB320__)
742#define __ELPM__1(res, addr, T) \
743 __asm __volatile__ ("mov r30,%A1" "\n\t" \
744 "mov r31,%B1" "\n\t" \
745 "out %i2,%C1 $ elpm $ mov %A0,r0" \
747 : "r" (addr), "n" (& RAMPZ) \
748 : "r30", "r31", "r0")
750#define __ELPM__2(res, addr, T) \
752 ("mov r30,%A1" "\n\t" \
753 "mov r31,%B1" "\n\t" \
754 "mov %B0,%C1" "\n\t" \
755 "out %i2,%B0 $ elpm $ mov %A0,r0 $ adiw r30,1 $ adc %B0,r1" "\n\t" \
756 "out %i2,%B0 $ elpm $ mov %B0,r0" \
758 : "r" (addr), "n" (& RAMPZ) \
759 : "r30", "r31", "r0")
761#define __ELPM__3(res, addr, T) \
763 ("mov r30,%A1" "\n\t" \
764 "mov r31,%B1" "\n\t" \
765 "mov %C0,%C1" "\n\t" \
766 "out %i2,%C0 $ elpm $ mov %A0,r0 $ adiw r30,1 $ adc %C0,r1" "\n\t" \
767 "out %i2,%C0 $ elpm $ mov %B0,r0 $ adiw r30,1 $ adc %C0,r1" "\n\t" \
768 "out %i2,%C0 $ elpm $ mov %C0,r0" \
770 : "r" (addr), "n" (& RAMPZ) \
771 : "r30", "r31", "r0")
773#define __ELPM__4(res, addr, T) \
775 ("mov r30,%A1" "\n\t" \
776 "mov r31,%B1" "\n\t" \
777 "mov %D0,%C1" "\n\t" \
778 "out %i2,%D0 $ elpm $ mov %A0,r0 $ adiw r30,1 $ adc %D0,r1" "\n\t" \
779 "out %i2,%D0 $ elpm $ mov %B0,r0 $ adiw r30,1 $ adc %D0,r1" "\n\t" \
780 "out %i2,%D0 $ elpm $ mov %C0,r0 $ adiw r30,1 $ adc %D0,r1" "\n\t" \
781 "out %i2,%D0 $ elpm $ mov %D0,r0" \
783 : "r" (addr), "n" (& RAMPZ) \
784 : "r30", "r31", "r0")
786#define __ELPM__8(res, addr, T) \
788 ("mov r30,%A1" "\n\t" \
789 "mov r31,%B1" "\n\t" \
790 "mov %r0+7,%C1" "\n\t" \
791 "out %i2,%r0+7 $ elpm $ mov %r0+0,r0 $ adiw r30,1 $ adc %r0+7,r1" "\n\t" \
792 "out %i2,%r0+7 $ elpm $ mov %r0+1,r0 $ adiw r30,1 $ adc %r0+7,r1" "\n\t" \
793 "out %i2,%r0+7 $ elpm $ mov %r0+2,r0 $ adiw r30,1 $ adc %r0+7,r1" "\n\t" \
794 "out %i2,%r0+7 $ elpm $ mov %r0+3,r0 $ adiw r30,1 $ adc %r0+7,r1" "\n\t" \
795 "out %i2,%r0+7 $ elpm $ mov %r0+4,r0 $ adiw r30,1 $ adc %r0+7,r1" "\n\t" \
796 "out %i2,%r0+7 $ elpm $ mov %r0+5,r0 $ adiw r30,1 $ adc %r0+7,r1" "\n\t" \
797 "out %i2,%r0+7 $ elpm $ mov %r0+6,r0 $ adiw r30,1 $ adc %r0+7,r1" "\n\t" \
798 "out %i2,%r0+7 $ elpm $ mov %r0+7,r0" \
800 : "r" (addr), "n" (& RAMPZ) \
801 : "r30", "r31", "r0")
804#define __ELPM__1(r,a,T) const T *__a = (const T*)(uint16_t) a; __LPM__1(r,__a)
805#define __ELPM__2(r,a,T) const T *__a = (const T*)(uint16_t) a; __LPM__2(r,__a)
806#define __ELPM__3(r,a,T) const T *__a = (const T*)(uint16_t) a; __LPM__3(r,__a)
807#define __ELPM__4(r,a,T) const T *__a = (const T*)(uint16_t) a; __LPM__4(r,__a)
808#define __ELPM__8(r,a,T) const T *__a = (const T*)(uint16_t) a; __LPM__8(r,__a)
811#define _Avrlibc_Def_Pgm_Far_1(Name, Typ) \
812 static __ATTR_ALWAYS_INLINE__ \
813 Typ pgm_read_##Name##_far (uint_farptr_t __addr) \
816 __ELPM__1 (__res, __addr, Typ); \
820#define _Avrlibc_Def_Pgm_Far_2(Name, Typ) \
821 static __ATTR_ALWAYS_INLINE__ \
822 Typ pgm_read_##Name##_far (uint_farptr_t __addr) \
825 __ELPM__2 (__res, __addr, Typ); \
829#define _Avrlibc_Def_Pgm_Far_3(Name, Typ) \
830 static __ATTR_ALWAYS_INLINE__ \
831 Typ pgm_read_##Name##_far (uint_farptr_t __addr) \
834 __ELPM__3 (__res, __addr, Typ); \
838#define _Avrlibc_Def_Pgm_Far_4(Name, Typ) \
839 static __ATTR_ALWAYS_INLINE__ \
840 Typ pgm_read_##Name##_far (uint_farptr_t __addr) \
843 __ELPM__4 (__res, __addr, Typ); \
847#define _Avrlibc_Def_Pgm_Far_8(Name, Typ) \
848 static __ATTR_ALWAYS_INLINE__ \
849 Typ pgm_read_##Name##_far (uint_farptr_t __addr) \
852 __ELPM__8 (__res, __addr, Typ); \
856_Avrlibc_Def_Pgm_Far_1 (
char,
char)
857_Avrlibc_Def_Pgm_Far_1 (unsigned_char,
unsigned char)
858_Avrlibc_Def_Pgm_Far_1 (signed_char,
signed char)
859_Avrlibc_Def_Pgm_Far_1 (u8,
uint8_t)
860_Avrlibc_Def_Pgm_Far_1 (i8,
int8_t)
861#if __SIZEOF_INT__ == 1
862_Avrlibc_Def_Pgm_Far_1 (
int,
int)
863_Avrlibc_Def_Pgm_Far_1 (
unsigned,
unsigned)
864_Avrlibc_Def_Pgm_Far_1 (unsigned_int,
unsigned int)
865_Avrlibc_Def_Pgm_Far_1 (
signed,
signed)
866_Avrlibc_Def_Pgm_Far_1 (signed_int,
signed int)
868#if __SIZEOF_SHORT__ == 1
869_Avrlibc_Def_Pgm_Far_1 (
short,
short)
870_Avrlibc_Def_Pgm_Far_1 (unsigned_short,
unsigned short)
873_Avrlibc_Def_Pgm_Far_2 (u16,
uint16_t)
874_Avrlibc_Def_Pgm_Far_2 (i16,
int16_t)
875#if __SIZEOF_INT__ == 2
876_Avrlibc_Def_Pgm_Far_2 (
int,
int)
877_Avrlibc_Def_Pgm_Far_2 (
unsigned,
unsigned)
878_Avrlibc_Def_Pgm_Far_2 (unsigned_int,
unsigned int)
879_Avrlibc_Def_Pgm_Far_2 (
signed,
signed)
880_Avrlibc_Def_Pgm_Far_2 (signed_int,
signed int)
882#if __SIZEOF_SHORT__ == 2
883_Avrlibc_Def_Pgm_Far_2 (
short,
short)
884_Avrlibc_Def_Pgm_Far_2 (unsigned_short,
unsigned short)
886#if __SIZEOF_LONG__ == 2
887_Avrlibc_Def_Pgm_Far_2 (
long,
long)
888_Avrlibc_Def_Pgm_Far_2 (unsigned_long,
unsigned long)
891#if defined(__INT24_MAX__)
892_Avrlibc_Def_Pgm_Far_3 (i24, __int24)
893_Avrlibc_Def_Pgm_Far_3 (u24, __uint24)
896_Avrlibc_Def_Pgm_Far_4 (u32,
uint32_t)
897_Avrlibc_Def_Pgm_Far_4 (i32,
int32_t)
898_Avrlibc_Def_Pgm_Far_4 (
float,
float)
899#if __SIZEOF_LONG__ == 4
900_Avrlibc_Def_Pgm_Far_4 (
long,
long)
901_Avrlibc_Def_Pgm_Far_4 (unsigned_long,
unsigned long)
903#if __SIZEOF_LONG_LONG__ == 4
904_Avrlibc_Def_Pgm_Far_4 (long_long,
long long)
905_Avrlibc_Def_Pgm_Far_4 (unsigned_long_long,
unsigned long long)
907#if __SIZEOF_DOUBLE__ == 4
908_Avrlibc_Def_Pgm_Far_4 (
double,
double)
910#if __SIZEOF_LONG_DOUBLE__ == 4
911_Avrlibc_Def_Pgm_Far_4 (long_double,
long double)
914#if __SIZEOF_LONG_LONG__ == 8
915_Avrlibc_Def_Pgm_Far_8 (u64,
uint64_t)
916_Avrlibc_Def_Pgm_Far_8 (i64,
int64_t)
917_Avrlibc_Def_Pgm_Far_8 (long_long,
long long)
918_Avrlibc_Def_Pgm_Far_8 (unsigned_long_long,
unsigned long long)
920#if __SIZEOF_DOUBLE__ == 8
921_Avrlibc_Def_Pgm_Far_8 (
double,
double)
923#if __SIZEOF_LONG_DOUBLE__ == 8
924_Avrlibc_Def_Pgm_Far_8 (long_double,
long double)
933#if defined(__DOXYGEN__)
935#elif defined(__PROG_TYPES_COMPAT__)
937typedef void prog_void __attribute__((__progmem__,__deprecated__(
"prog_void type is deprecated.")));
938typedef char prog_char __attribute__((__progmem__,__deprecated__(
"prog_char type is deprecated.")));
939typedef unsigned char prog_uchar __attribute__((__progmem__,__deprecated__(
"prog_uchar type is deprecated.")));
940typedef int8_t prog_int8_t __attribute__((__progmem__,__deprecated__(
"prog_int8_t type is deprecated.")));
941typedef uint8_t prog_uint8_t __attribute__((__progmem__,__deprecated__(
"prog_uint8_t type is deprecated.")));
942typedef int16_t prog_int16_t __attribute__((__progmem__,__deprecated__(
"prog_int16_t type is deprecated.")));
943typedef uint16_t prog_uint16_t __attribute__((__progmem__,__deprecated__(
"prog_uint16_t type is deprecated.")));
944typedef int32_t prog_int32_t __attribute__((__progmem__,__deprecated__(
"prog_int32_t type is deprecated.")));
945typedef uint32_t prog_uint32_t __attribute__((__progmem__,__deprecated__(
"prog_uint32_t type is deprecated.")));
947typedef int64_t prog_int64_t __attribute__((__progmem__,__deprecated__(
"prog_int64_t type is deprecated.")));
948typedef uint64_t prog_uint64_t __attribute__((__progmem__,__deprecated__(
"prog_uint64_t type is deprecated.")));
952#define PGM_P const prog_char *
956#define PGM_VOID_P const prog_void *
962#define PGM_P const char *
966#define PGM_VOID_P const void *
980#if defined(__DOXYGEN__)
989# define PSTR(str) ({ static const PROGMEM char c[] = (str); &c[0]; })
992# define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];}))
995#if defined(__DOXYGEN__)
1001# define PSTR_FAR(str) ({ static const PROGMEM_FAR char c[] = (str); pgm_get_far_address(c[0]); })
1004# define PSTR_FAR(s) (__extension__({static const char __c[] PROGMEM_FAR = (s); pgm_get_far_address(__c[0]);}))
1011#if defined (__AVR_TINY__)
1018#define __LPM(addr) (* (const uint8_t*)(addr))
1019#define __LPM_word(addr) (* (const uint16_t*)(addr))
1020#define __LPM_dword(addr) (* (const uint32_t*)(addr))
1021# if __SIZEOF_LONG_LONG__ == 8
1022# define __LPM_qword(addr) (* (const uint64_t*)(addr))
1025#define __LPM(addr) \
1027 uint16_t __addr16 = (uint16_t) (addr); \
1029 __LPM__1 (__result, __addr16); \
1033#define __LPM_word(addr) \
1035 uint16_t __addr16 = (uint16_t) (addr); \
1036 uint16_t __result; \
1037 __LPM__2 (__result, __addr16); \
1041#define __LPM_dword(addr) \
1043 uint16_t __addr16 = (uint16_t) (addr); \
1044 uint32_t __result; \
1045 __LPM__4 (__result, __addr16); \
1049#if __SIZEOF_LONG_LONG__ == 8
1050#define __LPM_qword(addr) \
1052 uint16_t __addr16 = (uint16_t) (addr); \
1053 uint64_t __result; \
1054 __LPM__8 (__result, __addr16); \
1061#define __ELPM(addr) \
1063 uint_farptr_t __addr32 = (addr); \
1065 __ELPM__1 (__result, __addr32, uint8_t); \
1069#define __ELPM_word(addr) \
1071 uint_farptr_t __addr32 = (addr); \
1072 uint16_t __result; \
1073 __ELPM__2 (__result, __addr32, uint16_t); \
1077#define __ELPM_dword(addr) \
1079 uint_farptr_t __addr32 = (addr); \
1080 uint32_t __result; \
1081 __ELPM__4 (__result, __addr32, uint32_t); \
1085#if __SIZEOF_LONG_LONG__ == 8
1086#define __ELPM_qword(addr) \
1088 uint_farptr_t __addr32 = (addr); \
1089 uint64_t __result; \
1090 __ELPM__8 (__result, __addr32, uint64_t); \
1101#define pgm_read_byte_near(__addr) __LPM ((uint16_t)(__addr))
1107#define pgm_read_word_near(__addr) __LPM_word ((uint16_t)(__addr))
1114#define pgm_read_dword_near(__addr) \
1115 __LPM_dword ((uint16_t)(__addr))
1122#define pgm_read_qword_near(__addr) __LPM_qword ((uint16_t)(__addr))
1128#define pgm_read_float_near(addr) pgm_read_float (addr)
1134#define pgm_read_ptr_near(__addr) \
1135 ((void*) __LPM_word ((uint16_t)(__addr)))
1141#define pgm_read_byte_far(__addr) __ELPM (__addr)
1147#define pgm_read_word_far(__addr) __ELPM_word (__addr)
1154#define pgm_read_dword_far(__addr) __ELPM_dword (__addr)
1161#define pgm_read_qword_far(__addr) __ELPM_qword (__addr)
1167#define pgm_read_ptr_far(__addr) ((void*) __ELPM_word (__addr))
1173#define pgm_read_byte(__addr) pgm_read_byte_near(__addr)
1179#define pgm_read_word(__addr) pgm_read_word_near(__addr)
1186#define pgm_read_dword(__addr) pgm_read_dword_near(__addr)
1193#define pgm_read_qword(__addr) pgm_read_qword_near(__addr)
1199#define pgm_read_ptr(__addr) pgm_read_ptr_near(__addr)
1243#define pgm_get_far_address(var) \
1245 uint_farptr_t __tmp; \
1247 __asm__ __volatile__ ( \
1248 "ldi %A0, lo8(%1)" "\n\t" \
1249 "ldi %B0, hi8(%1)" "\n\t" \
1250 "ldi %C0, hh8(%1)" "\n\t" \
1272extern const void *
memchr_P(
const void *,
int __val,
size_t __len) __ATTR_CONST__;
1286extern int memcmp_P(
const void *,
const void *,
size_t) __ATTR_PURE__;
1293extern void *
memccpy_P(
void *,
const void *,
int __val,
size_t);
1309extern void *
memmem_P(
const void *,
size_t,
const void *,
size_t) __ATTR_PURE__;
1321extern const void *
memrchr_P(
const void *,
int __val,
size_t __len) __ATTR_CONST__;
1347extern const char *
strchr_P(
const char *,
int __val) __ATTR_CONST__;
1359extern const char *
strchrnul_P(
const char *,
int __val) __ATTR_CONST__;
1372extern int strcmp_P(
const char *,
const char *) __ATTR_PURE__;
1419extern size_t strcspn_P(
const char *__s,
const char * __reject) __ATTR_PURE__;
1460extern size_t strnlen_P(
const char *,
size_t) __ATTR_CONST__;
1471extern int strncmp_P(
const char *,
const char *,
size_t) __ATTR_PURE__;
1530extern char *
strpbrk_P(
const char *__s,
const char * __accept) __ATTR_PURE__;
1541extern const char *
strrchr_P(
const char *,
int __val) __ATTR_CONST__;
1561extern char *
strsep_P(
char **__sp,
const char * __delim);
1574extern size_t strspn_P(
const char *__s,
const char * __accept) __ATTR_PURE__;
1588extern char *
strstr_P(
const char *,
const char *) __ATTR_PURE__;
1630extern char *
strtok_rP(
char *__s,
const char * __delim,
char **__last);
1912#define __strlen_P strlen
1913extern size_t strlen (
const char*);
1915extern size_t __strlen_P(
const char *) __ATTR_CONST__;
1918static __ATTR_ALWAYS_INLINE__
size_t strlen_P(
const char * s);
1921 return __builtin_constant_p(__builtin_strlen(s))
1922 ? __builtin_strlen(s) : __strlen_P(s);
1930#if defined(__cplusplus) && defined(__pgm_read_template__)
1939template<
typename __T,
size_t>
1940struct __pgm_read_impl
1946 __T operator() (
const __T *__addr)
const
1949 memcpy_P (&__res, __addr,
sizeof(__T));
1954template<
typename __T>
1955struct __pgm_read_impl<__T, 1>
1957 __T operator() (
const __T *__addr)
const
1959 __T __res; __LPM__1 (__res, __addr);
return __res;
1963template<
typename __T>
1964struct __pgm_read_impl<__T, 2>
1966 __T operator() (
const __T *__addr)
const
1968 __T __res; __LPM__2 (__res, __addr);
return __res;
1972template<
typename __T>
1973struct __pgm_read_impl<__T, 3>
1975 __T operator() (
const __T *__addr)
const
1977 __T __res; __LPM__3 (__res, __addr);
return __res;
1981template<
typename __T>
1982struct __pgm_read_impl<__T, 4>
1984 __T operator() (
const __T *__addr)
const
1986 __T __res; __LPM__4 (__res, __addr);
return __res;
1990template<
typename __T>
1991struct __pgm_read_impl<__T, 8>
1993 __T operator() (
const __T *__addr)
const
1995 __T __res; __LPM__8 (__res, __addr);
return __res;
1999template<
typename __T>
2000__T pgm_read (
const __T *__addr)
2002 return __pgm_read_impl<__T, sizeof(__T)>() (__addr);
2007template<
typename __T,
size_t>
2008struct __pgm_read_far_impl
2014 __T operator() (
const __T *__addr)
const
2017 memcpy_PF (&__res, __addr,
sizeof(__T));
2022template<
typename __T>
2023struct __pgm_read_far_impl<__T, 1>
2027 __T __res; __ELPM__1 (__res, __addr, __T);
return __res;
2031template<
typename __T>
2032struct __pgm_read_far_impl<__T, 2>
2036 __T __res; __ELPM__2 (__res, __addr, __T);
return __res;
2040template<
typename __T>
2041struct __pgm_read_far_impl<__T, 3>
2045 __T __res; __ELPM__3 (__res, __addr, __T);
return __res;
2049template<
typename __T>
2050struct __pgm_read_far_impl<__T, 4>
2054 __T __res; __ELPM__4 (__res, __addr, __T);
return __res;
2058template<
typename __T>
2059struct __pgm_read_far_impl<__T, 8>
2063 __T __res; __ELPM__8 (__res, __addr, __T);
return __res;
2067template<
typename __T>
2070 return __pgm_read_far_impl<__T, sizeof(__T)>() (__addr);
uint32_t uint_farptr_t
Definition: inttypes.h:83
static long double pgm_read_long_double(const long double *__addr)
static uint16_t pgm_read_u16(const uint16_t *__addr)
static unsigned pgm_read_unsigned_far(uint_farptr_t __addr)
char * strstr_PF(const char *s1, uint_farptr_t s2)
Locate a substring.
static uint16_t pgm_read_u16_far(uint_farptr_t __addr)
const char * strchrnul_P(const char *, int __val)
static signed int pgm_read_signed_int_far(uint_farptr_t __addr)
static signed pgm_read_signed_far(uint_farptr_t __addr)
const char * strchr_P(const char *, int __val)
Locate character in program space string.
int strcmp_PF(const char *s1, uint_farptr_t s2)
Compares two strings.
void * memcpy_PF(void *dest, uint_farptr_t src, size_t len)
Copy a memory block from flash to SRAM.
char * strsep_P(char **__sp, const char *__delim)
Parse a string into tokens.
static uint32_t pgm_read_u32_far(uint_farptr_t __addr)
int strcmp_P(const char *, const char *)
char * strcasestr_P(const char *, const char *)
static unsigned char pgm_read_unsigned_char_far(uint_farptr_t __addr)
static int32_t pgm_read_i32(const int32_t *__addr)
char * strncpy_P(char *, const char *, size_t)
static int64_t pgm_read_i64(const int64_t *__addr)
static __int24 pgm_read_i24(const __int24 *__addr)
static signed int pgm_read_signed_int(const signed int *__addr)
static signed char pgm_read_signed_char(const signed char *__addr)
static int8_t pgm_read_i8_far(uint_farptr_t __addr)
static long long pgm_read_long_long_far(uint_farptr_t __addr)
static __uint24 pgm_read_u24_far(uint_farptr_t __addr)
int strcasecmp_P(const char *, const char *)
Compare two strings ignoring case.
size_t strcspn_P(const char *__s, const char *__reject)
static int pgm_read_int(const int *__addr)
static unsigned short pgm_read_unsigned_short(const unsigned short *__addr)
char * strpbrk_P(const char *__s, const char *__accept)
static float pgm_read_float_far(uint_farptr_t __addr)
static unsigned long long pgm_read_unsigned_long_long(const unsigned long long *__addr)
const void * memchr_P(const void *, int __val, size_t __len)
Scan flash memory for a character.
void * memccpy_P(void *, const void *, int __val, size_t)
static uint8_t pgm_read_u8(const uint8_t *__addr)
char * strtok_rP(char *__s, const char *__delim, char **__last)
Parses string into tokens.
char * strncpy_PF(char *dest, uint_farptr_t src, size_t len)
Duplicate a string until a limited length.
T pgm_read< T >(const T *addr)
void * memmem_P(const void *, size_t, const void *, size_t)
size_t strlen_PF(uint_farptr_t src)
Obtain the length of a string.
static int16_t pgm_read_i16(const int16_t *__addr)
static float pgm_read_float(const float *__addr)
size_t strnlen_P(const char *, size_t)
Determine the length of a fixed-size string.
char * strcpy_P(char *, const char *)
static uint8_t pgm_read_u8_far(uint_farptr_t __addr)
static char pgm_read_char(const char *__addr)
char * strcat_P(char *, const char *)
int strncasecmp_P(const char *, const char *, size_t)
Compare two strings ignoring case.
size_t strspn_P(const char *__s, const char *__accept)
size_t strlcpy_PF(char *dst, uint_farptr_t src, size_t siz)
Copy a string from progmem to RAM.
static uint64_t pgm_read_u64_far(uint_farptr_t __addr)
int memcmp_PF(const void *, uint_farptr_t, size_t)
Compare memory areas.
const char * strrchr_P(const char *, int __val)
Locate character in string.
static double pgm_read_double_far(uint_farptr_t __addr)
static uint64_t pgm_read_u64(const uint64_t *__addr)
static double pgm_read_double(const double *__addr)
static char pgm_read_char_far(uint_farptr_t __addr)
int strcasecmp_PF(const char *s1, uint_farptr_t s2)
Compare two strings ignoring case.
size_t strnlen_PF(uint_farptr_t src, size_t len)
Determine the length of a fixed-size string.
static unsigned long pgm_read_unsigned_long_far(uint_farptr_t __addr)
static long pgm_read_long(const long *__addr)
static int32_t pgm_read_i32_far(uint_farptr_t __addr)
size_t strlcat_P(char *, const char *, size_t)
Concatenate two strings.
static unsigned short pgm_read_unsigned_short_far(uint_farptr_t __addr)
char * strncat_P(char *, const char *, size_t)
Concatenate two strings.
static int8_t pgm_read_i8(const int8_t *__addr)
const void * memrchr_P(const void *, int __val, size_t __len)
static int pgm_read_int_far(uint_farptr_t __addr)
char * strncat_PF(char *dest, uint_farptr_t src, size_t len)
Concatenate two strings.
char * strcat_PF(char *dest, uint_farptr_t src)
Concatenates two strings.
T pgm_read_far< T >(uint_farptr_t addr)
static short pgm_read_short(const short *__addr)
static int64_t pgm_read_i64_far(uint_farptr_t __addr)
char * strtok_P(char *__s, const char *__delim)
Parses the string into tokens.
static int16_t pgm_read_i16_far(uint_farptr_t __addr)
static unsigned long long pgm_read_unsigned_long_long_far(uint_farptr_t __addr)
int strncmp_P(const char *, const char *, size_t)
static unsigned pgm_read_unsigned(const unsigned *__addr)
static long long pgm_read_long_long(const long long *__addr)
char * strstr_P(const char *, const char *)
Locate a substring.
int memcmp_P(const void *, const void *, size_t)
Compare memory areas.
static signed char pgm_read_signed_char_far(uint_farptr_t __addr)
static unsigned long pgm_read_unsigned_long(const unsigned long *__addr)
size_t strlcpy_P(char *, const char *, size_t)
Copy a string from progmem to RAM.
int strncasecmp_PF(const char *s1, uint_farptr_t s2, size_t n)
Compare two strings ignoring case.
char * strcpy_PF(char *dest, uint_farptr_t src)
Duplicate a string.
int strncmp_PF(const char *s1, uint_farptr_t s2, size_t n)
Compare two strings with limited length.
static short pgm_read_short_far(uint_farptr_t __addr)
void * memcpy_P(void *, const void *, size_t)
static unsigned int pgm_read_unsigned_int_far(uint_farptr_t __addr)
static unsigned char pgm_read_unsigned_char(const unsigned char *__addr)
static size_t strlen_P(const char *s)
static long pgm_read_long_far(uint_farptr_t __addr)
static __int24 pgm_read_i24_far(uint_farptr_t __addr)
uint_farptr_t strchr_PF(uint_farptr_t, int __val)
Locate character in far program space string.
static signed pgm_read_signed(const signed *__addr)
static uint32_t pgm_read_u32(const uint32_t *__addr)
static __uint24 pgm_read_u24(const __uint24 *__addr)
static long double pgm_read_long_double_far(uint_farptr_t __addr)
size_t strlcat_PF(char *dst, uint_farptr_t src, size_t siz)
Concatenate two strings.
static unsigned int pgm_read_unsigned_int(const unsigned int *__addr)
unsigned int uint16_t
Definition: stdint.h:93
unsigned long int uint32_t
Definition: stdint.h:103
signed long long int int64_t
Definition: stdint.h:110
signed int int16_t
Definition: stdint.h:88
unsigned char uint8_t
Definition: stdint.h:83
unsigned long long int uint64_t
Definition: stdint.h:117
signed long int int32_t
Definition: stdint.h:98
signed char int8_t
Definition: stdint.h:78
size_t strlen(const char *)
Calculate the length of a string.