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__); \
65 #define printf_P(fmt, ...) printf_P_stack(fmt, ##__VA_ARGS__)
68 #define printf_P(fmt, ...) m_printf(fmt, ##__VA_ARGS__)
78 #define PSTR_COUNTED(str) \
80 static const char __pstr__[] PROGMEM = str; \
92 DEFINE_PSTR_LOCAL(__pstr__, str); \
93 LOAD_PSTR(buf, __pstr__); \
128 #define DEFINE_PSTR(name, str) const char name[] PROGMEM_PSTR = str;
134 #define DEFINE_PSTR_LOCAL(name, str) static DEFINE_PSTR(name, str)
140 #define DECLARE_PSTR(name) extern const char name[];
158 #define LOAD_PSTR(name, flash_str) \
159 char name[ALIGNUP4(sizeof(flash_str))] __attribute__((aligned(4))); \
160 memcpy_aligned(name, flash_str, sizeof(flash_str));
162 #define _FLOAD(pstr) \
164 LOAD_PSTR(_buf, pstr); \
186 #define PSTR_ARRAY(name, str) \
187 DEFINE_PSTR_LOCAL(__pstr__##name, str); \
188 LOAD_PSTR(name, __pstr__##name)
int memcmp_aligned(const void *ptr1, const void *ptr2, unsigned len)
compare memory aligned to word boundaries
void * memcpy_aligned(void *dst, const void *src, unsigned len)
copy memory aligned to word boundaries