15 #include <sys/pgmspace.h> 34 #define IS_ALIGNED(_x) (((uint32_t)(_x)&3) == 0) 39 #define ALIGNUP4(n) (((n) + 3) & ~3) 44 #define ALIGNDOWN4(n) ((n) & ~3) 46 #define printf_P_heap(f_P, ...) \ 48 char* __localF = (char*)malloc(strlen_P(f_P) + 1); \ 49 strcpy_P(__localF, f_P); \ 50 int __result = os_printf_plus(__localF, ##__VA_ARGS__); \ 55 #define printf_P_stack(f_P, ...) \ 58 strncpy_P(__localF, f_P, sizeof(__localF)); \ 59 __localF[sizeof(__localF) - 1] = '\0'; \ 60 m_printf(__localF, ##__VA_ARGS__); \ 63 #define printf_P printf_P_stack 72 #define PSTR_COUNTED(str) \ 74 static const char __pstr__[] PROGMEM = str; \ 85 DEFINE_PSTR_LOCAL(__pstr__, str); \ 86 LOAD_PSTR(buf, __pstr__); \ 112 int memcmp_aligned(
const void* ptr1,
const void* ptr2,
unsigned len);
118 #define DEFINE_PSTR(name, str) const char name[] PROGMEM_PSTR = str; 124 #define DEFINE_PSTR_LOCAL(name, str) static DEFINE_PSTR(name, str) 130 #define DECLARE_PSTR(name) extern const char name[] PROGMEM; 148 #define LOAD_PSTR(name, flash_str) \ 149 char name[ALIGNUP4(sizeof(flash_str))] __attribute__((aligned(4))); \ 150 memcpy_aligned(name, flash_str, sizeof(flash_str)); 152 #define _FLOAD(pstr) \ 154 LOAD_PSTR(_buf, pstr); \ 176 #define PSTR_ARRAY(name, str) \ 177 DEFINE_PSTR_LOCAL(__pstr__##name, str); \ 178 LOAD_PSTR(name, __pstr__##name)
void * memcpy_aligned(void *dst, const void *src, unsigned len)
copy memory aligned to word boundaries
int memcmp_aligned(const void *ptr1, const void *ptr2, unsigned len)
compare memory aligned to word boundaries