Go to the documentation of this file.
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; \
88 DEFINE_PSTR_LOCAL(__pstr__, str); \
89 LOAD_PSTR(buf, __pstr__); \
117 int memcmp_aligned(
const void* ptr1,
const void* ptr2,
unsigned len);
123 #define DEFINE_PSTR(name, str) const char name[] PROGMEM_PSTR = str;
129 #define DEFINE_PSTR_LOCAL(name, str) static DEFINE_PSTR(name, str)
135 #define DECLARE_PSTR(name) extern const char name[] PROGMEM;
153 #define LOAD_PSTR(name, flash_str) \
154 char name[ALIGNUP4(sizeof(flash_str))] __attribute__((aligned(4))); \
155 memcpy_aligned(name, flash_str, sizeof(flash_str));
157 #define _FLOAD(pstr) \
159 LOAD_PSTR(_buf, pstr); \
181 #define PSTR_ARRAY(name, str) \
182 DEFINE_PSTR_LOCAL(__pstr__##name, str); \
183 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