pgmspace.h(3avr)

πŸ“¦
version 2.2.1 Β· 3 versions
, in debian trixie, ubuntu questing

🌸 NAME 🌸

pgmspace.h β€” that's the whole name, bestie. no notes. πŸ’…

okay so real talk: this is section 3avr of the AVR-LibC manual, and it's the page for pgmspace.h. it's a synopsis page β€” macros and function prototypes, all lined up like a little lineup of icons. ✨

πŸ’« SYNOPSIS πŸ’«

so the way this page works: first you get the macros, then you get the functions. that's the whole menu. no options, no environment variables, no exit statuses β€” this one is pure declarations, and every single one of them is below, spelled exactly right, so don't @ me. 🫢

πŸŽ€ Macros πŸŽ€

here's the full macro lineup, verbatim, character for character. 🧚

#define PROGMEM_FAR   __attribute__((__section__('.progmemx.data')))
#define PROGMEM   __attribute__((__progmem__))
#define PSTR(str)   ({ static const PROGMEM char c[] = (str); &c[0]; })
#define PSTR_FAR(str)   ({ static const PROGMEM_FAR char c[] = (str);
    pgm_get_far_address(c[0]); })
#define pgm_read_byte_near(__addr)   __LPM ((uint16_t)(__addr))
#define pgm_read_word_near(__addr)   __LPM_word ((uint16_t)(__addr))
#define pgm_read_dword_near(__addr)       __LPM_dword
    ((uint16_t)(__addr))
#define pgm_read_qword_near(__addr)   __LPM_qword ((uint16_t)(__addr))
#define pgm_read_float_near(addr)   pgm_read_float (addr)
#define pgm_read_ptr_near(__addr)       ((void*) __LPM_word
    ((uint16_t)(__addr)))
#define pgm_read_byte_far(__addr)   __ELPM (__addr)
#define pgm_read_word_far(__addr)   __ELPM_word (__addr)
#define pgm_read_dword_far(__addr)   __ELPM_dword (__addr)
#define pgm_read_qword_far(__addr)   __ELPM_qword (__addr)
#define pgm_read_ptr_far(__addr)   ((void*) __ELPM_word (__addr))
#define pgm_read_byte(__addr)   pgm_read_byte_near(__addr)
#define pgm_read_word(__addr)   pgm_read_word_near(__addr)
#define pgm_read_dword(__addr)   pgm_read_dword_near(__addr)
#define pgm_read_qword(__addr)   pgm_read_qword_near(__addr)
#define pgm_read_ptr(__addr)   pgm_read_ptr_near(__addr)
#define pgm_get_far_address(var)

a lil tour, since we're here: PROGMEM_FAR and PROGMEM are attribute macros, PSTR and PSTR_FAR are the string ones (note that PSTR_FAR pulls in pgm_get_far_address(c[0])), then you've got the _near family, the _far family, and the plain no-suffix ones that just alias straight to their _near siblings. 😌

and yeah β€” pgm_get_far_address(var) is listed with no replacement text at all. that's exactly how it appears on the page. i'm not filling in the blank, i'm not being cute about it, i'm just reporting the facts. πŸ™ˆ


πŸ¦‹ Functions πŸ¦‹

okay this is the long part and i'm not skipping a single one, because every one of these is somebody's blorbo. 🌈

first up: the typed readers that take a const pointer β€” the near crew. πŸ“

static char pgm_read_char (const char *__addr)
static unsigned char pgm_read_unsigned_char (const unsigned char *__addr)
static signed char pgm_read_signed_char (const signed char *__addr)
static uint8_t pgm_read_u8 (const uint8_t *__addr)
static int8_t pgm_read_i8 (const int8_t *__addr)
static short pgm_read_short (const short *__addr)
static unsigned short pgm_read_unsigned_short (const unsigned short *__addr)
static uint16_t pgm_read_u16 (const uint16_t *__addr)
static int16_t pgm_read_i16 (const int16_t *__addr)
static int pgm_read_int (const int *__addr)
static signed pgm_read_signed (const signed *__addr)
static unsigned pgm_read_unsigned (const unsigned *__addr)
static signed int pgm_read_signed_int (const signed int *__addr)
static unsigned int pgm_read_unsigned_int (const unsigned int *__addr)
static __int24 pgm_read_i24 (const __int24 *__addr)
static __uint24 pgm_read_u24 (const __uint24 *__addr)
static uint32_t pgm_read_u32 (const uint32_t *__addr)
static int32_t pgm_read_i32 (const int32_t *__addr)
static long pgm_read_long (const long *__addr)
static unsigned long pgm_read_unsigned_long (const unsigned long *__addr)
static long long pgm_read_long_long (const long long *__addr)
static unsigned long long pgm_read_unsigned_long_long (const unsigned long long *__addr)
static uint64_t pgm_read_u64 (const uint64_t *__addr)
static int64_t pgm_read_i64 (const int64_t *__addr)
static float pgm_read_float (const float *__addr)
static double pgm_read_double (const double *__addr)
static long double pgm_read_long_double (const long double *__addr)

then the same energy but far, taking a uint_farptr_t __addr instead of a pointer. same list, _far on the end, and no i'm not tired, i'm thriving. πŸ’œ

static char pgm_read_char_far (uint_farptr_t __addr)
static unsigned char pgm_read_unsigned_char_far (uint_farptr_t __addr)
static signed char pgm_read_signed_char_far (uint_farptr_t __addr)
static uint8_t pgm_read_u8_far (uint_farptr_t __addr)
static int8_t pgm_read_i8_far (uint_farptr_t __addr)
static short pgm_read_short_far (uint_farptr_t __addr)
static unsigned short pgm_read_unsigned_short_far (uint_farptr_t __addr)
static uint16_t pgm_read_u16_far (uint_farptr_t __addr)
static int16_t pgm_read_i16_far (uint_farptr_t __addr)
static int pgm_read_int_far (uint_farptr_t __addr)
static unsigned pgm_read_unsigned_far (uint_farptr_t __addr)
static unsigned int pgm_read_unsigned_int_far (uint_farptr_t __addr)
static signed pgm_read_signed_far (uint_farptr_t __addr)
static signed int pgm_read_signed_int_far (uint_farptr_t __addr)
static long pgm_read_long_far (uint_farptr_t __addr)
static unsigned long pgm_read_unsigned_long_far (uint_farptr_t __addr)
static __int24 pgm_read_i24_far (uint_farptr_t __addr)
static __uint24 pgm_read_u24_far (uint_farptr_t __addr)
static uint32_t pgm_read_u32_far (uint_farptr_t __addr)
static int32_t pgm_read_i32_far (uint_farptr_t __addr)
static long long pgm_read_long_long_far (uint_farptr_t __addr)
static unsigned long long pgm_read_unsigned_long_long_far (uint_farptr_t __addr)
static uint64_t pgm_read_u64_far (uint_farptr_t __addr)
static int64_t pgm_read_i64_far (uint_farptr_t __addr)
static float pgm_read_float_far (uint_farptr_t __addr)
static double pgm_read_double_far (uint_farptr_t __addr)
static long double pgm_read_long_double_far (uint_farptr_t __addr)

next: the _P family. these are the memory and string functions, and yes, strtok_rP really is spelled like that, lowercase r, capital P, exactly as shown. do not "fix" it. i will know. πŸ‘€

const void * memchr_P (const void *, int __val, size_t __len)
int memcmp_P (const void *, const void *, size_t)
void * memccpy_P (void *, const void *, int __val, size_t)
void * memcpy_P (void *, const void *, size_t)
void * memmem_P (const void *, size_t, const void *, size_t)
const void * memrchr_P (const void *, int __val, size_t __len)
char * strcat_P (char *, const char *)
const char * strchr_P (const char *, int __val)
const char * strchrnul_P (const char *, int __val)
int strcmp_P (const char *, const char *)
char * strcpy_P (char *, const char *)
int strcasecmp_P (const char *, const char *)
char * strcasestr_P (const char *, const char *)
size_t strcspn_P (const char *__s, const char *__reject)
size_t strlcat_P (char *, const char *, size_t)
size_t strlcpy_P (char *, const char *, size_t)
size_t strnlen_P (const char *, size_t)
int strncmp_P (const char *, const char *, size_t)
int strncasecmp_P (const char *, const char *, size_t)
char * strncat_P (char *, const char *, size_t)
char * strncpy_P (char *, const char *, size_t)
char * strpbrk_P (const char *__s, const char *__accept)
const char * strrchr_P (const char *, int __val)
char * strsep_P (char **__sp, const char *__delim)
size_t strspn_P (const char *__s, const char *__accept)
char * strstr_P (const char *, const char *)
char * strtok_P (char *__s, const char *__delim)
char * strtok_rP (char *__s, const char *__delim, char **__last)

then the _PF family, where the flash side comes in as a uint_farptr_t:

size_t strlen_PF (uint_farptr_t src)
size_t strnlen_PF (uint_farptr_t src, size_t len)
void * memcpy_PF (void *dest, uint_farptr_t src, size_t len)
char * strcpy_PF (char *dest, uint_farptr_t src)
char * strncpy_PF (char *dest, uint_farptr_t src, size_t len)
char * strcat_PF (char *dest, uint_farptr_t src)
size_t strlcat_PF (char *dst, uint_farptr_t src, size_t siz)
char * strncat_PF (char *dest, uint_farptr_t src, size_t len)
int strcmp_PF (const char *s1, uint_farptr_t s2)
int strncmp_PF (const char *s1, uint_farptr_t s2, size_t n)
int strcasecmp_PF (const char *s1, uint_farptr_t s2)
int strncasecmp_PF (const char *s1, uint_farptr_t s2, size_t n)
uint_farptr_t strchr_PF (uint_farptr_t, int __val)
char * strstr_PF (const char *s1, uint_farptr_t s2)
size_t strlcpy_PF (char *dst, uint_farptr_t src, size_t siz)
int memcmp_PF (const void *, uint_farptr_t, size_t)

and the last three, which are their own little moment: strlen_P, plus the two C++ templates pgm_read<T> and pgm_read_far<T>. πŸŽ€

static size_t strlen_P (const char *s)
template<typename T > T pgm_read< T > (const T *addr)
template<typename T > T pgm_read_far< T > (uint_farptr_t addr)

πŸ’… Author πŸ’…

Generated automatically by Doxygen for AVR-LibC from the source code.

so yeah β€” nobody hand-wrote this one, Doxygen did the typing and honestly it ate. πŸ€–βœ¨


and that's the page, bestie. it's AVR-LibC, Version 2.2.1, and this was pgmspace.h(3avr). go read something out of flash for me. πŸ’–πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from