pgmspace.h(3avr)
π pgmspace.h β the 3avr page, but make it a group chat π
okay so bestie, you opened pgmspace.h from the 3avr manual and honestly? iconic behavior. this whole page is AVR-LibC's love letter to program space, and we are going through every single macro and function together. no skips, no vibes lost, no "oh I'll read that part later." periodt. πβ¨
β¨ NAME β¨
pgmspace.h β that's it, that's the name. short, sweet, main character energy. π
πΈ SYNOPSIS πΈ
π Macros π
okay these are the macros, and yes there are a LOT of them. every single one is staying, bestie. copy them exactly, no cap. π₯
#define PROGMEM_FAR __attribute__((__section__('.progmemx.data')))
#define PROGMEM __attribute__((__progmem__))
#define PSTR(str)
#define PSTR_FAR(str)
#define pgm_read_byte_near(__addr)
#define pgm_read_word_near(__addr)
#define pgm_read_dword_near(__addr)
#define pgm_read_qword_near(__addr)
#define pgm_read_float_near(addr)
#define pgm_read_ptr_near(__addr)
#define pgm_read_byte_far(__addr)
#define pgm_read_word_far(__addr)
#define pgm_read_dword_far(__addr)
#define pgm_read_qword_far(__addr)
#define pgm_read_ptr_far(__addr)
#define pgm_read_byte(__addr)
#define pgm_read_word(__addr)
#define pgm_read_dword(__addr)
#define pgm_read_qword(__addr)
#define pgm_read_ptr(__addr)
#define pgm_get_far_address(var)
π¦ Functions π¦
now the functions. there are so many and they're all valid and we love them. first up, the near-pointer readers β the little squad that reads things from nearby. π
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)
and now the far versions β same energy, but they take a uint_farptr_t and they're reaching across the whole address space like it's nothing. π°οΈ
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)
then we get the _P crew β the memory and string functions that live for program space. this list is giving "I know every string function and I'm not sorry." π
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)
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)
and the _PF squad β far pointers, still doing the absolute most (affectionate). they take uint_farptr_t and they're thriving. π
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 finally the little extras β one static strlen_P, plus two templates that are honestly so cute. T? generic. uint_farptr_t? far. slay. π
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)
π Function Documentation π
π size_t strspn_P (const char * s, const char * accept) [extern] π
okay so here's the one they actually wrote docs for, and it's a baddie. the strspn_P() function calculates the length of the initial segment of s which consists entirely of characters in accept. this function is similar to strspn() except that accept is a pointer to a string in program space. π«Ά
π Returns π
the strspn_P() function returns the number of characters in the initial segment of s which consist only of characters from accept. the terminating zero is not considered as a part of string. periodt. β¨
βοΈ Author βοΈ
Generated automatically by Doxygen for AVR-LibC from the source code.
and that's the whole page, bestie. no notes. π
this was AVR-LibC, Version 2.2.1, page pgmspace.h(3avr) β so yeah, that's the version and the page in the footer, but we're saying it with our whole chest at the end. bye bestie, go read some program space. π¦ππ
π¦ where this page comes from
- ubuntu resolute: avr-libc 1:2.2.1-1build1 Β· BSD-3-Clause
- ubuntu stonking: avr-libc 1:2.2.1-1build1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms