|
| 1 | +#pragma once |
| 2 | + |
| 3 | + |
| 4 | +/* |
| 5 | +def d(var_raw) |
| 6 | + var = var_raw.split("_")[0] |
| 7 | + out = "#define #{var}_P(...) #{var}(__VA_ARGS__)\n" |
| 8 | + IO.popen('pbcopy', 'w') { |f| f << out } |
| 9 | + out |
| 10 | + end |
| 11 | +
|
| 12 | +text = File.open("arduino-1.8.5/hardware/tools/avr/avr/include/avr/pgmspace.h").read |
| 13 | +externs = text.split("\n").select {|l| l.start_with? "extern"} |
| 14 | +out = externs.map {|l| l.split("(")[0].split(" ")[-1].gsub("*", "") }.uniq |
| 15 | +out.each { |l| puts d(l) } |
| 16 | +*/ |
| 17 | + |
| 18 | +#include <avr/io.h> |
| 19 | + |
| 20 | +#define PROGMEM |
| 21 | + |
| 22 | +#ifndef PGM_P |
| 23 | +#define PGM_P const char * |
| 24 | +#endif |
| 25 | + |
| 26 | +#ifndef PGM_VOID_P |
| 27 | +#define PGM_VOID_P const void * |
| 28 | +#endif |
| 29 | + |
| 30 | +// everything's a no-op |
| 31 | +#define PSTR(s) ((const char *)(s)) |
| 32 | +#define pgm_read_byte_near(x) (x) |
| 33 | +#define pgm_read_word_near(x) (x) |
| 34 | +#define pgm_read_dword_near(x) (x) |
| 35 | +#define pgm_read_float_near(x) (x) |
| 36 | +#define pgm_read_ptr_near(x) (x) |
| 37 | + |
| 38 | +#define pgm_read_byte_far(x) (x) |
| 39 | +#define pgm_read_word_far(x) (x) |
| 40 | +#define pgm_read_dword_far(x) (x) |
| 41 | +#define pgm_read_float_far(x) (x) |
| 42 | +#define pgm_read_ptr_far(x) (x) |
| 43 | + |
| 44 | + |
| 45 | +#define pgm_read_byte(x) (x) |
| 46 | +#define pgm_read_word(x) (x) |
| 47 | +#define pgm_read_dword(x) (x) |
| 48 | +#define pgm_read_float(x) (x) |
| 49 | +#define pgm_read_ptr(x) (x) |
| 50 | +#define pgm_get_far_address(x) (x) |
| 51 | + |
| 52 | +#define memchr_P(...) memchr(__VA_ARGS__) |
| 53 | +#define memcmp_P(...) memcmp(__VA_ARGS__) |
| 54 | +#define memccpy_P(...) memccpy(__VA_ARGS__) |
| 55 | +#define memcpy_P(...) memcpy(__VA_ARGS__) |
| 56 | +#define memmem_P(...) memmem(__VA_ARGS__) |
| 57 | +#define memrchr_P(...) memrchr(__VA_ARGS__) |
| 58 | +#define strcat_P(...) strcat(__VA_ARGS__) |
| 59 | +#define strchr_P(...) strchr(__VA_ARGS__) |
| 60 | +#define strchrnul_P(...) strchrnul(__VA_ARGS__) |
| 61 | +#define strcmp_P(...) strcmp(__VA_ARGS__) |
| 62 | +#define strcpy_P(...) strcpy(__VA_ARGS__) |
| 63 | +#define strcasecmp_P(...) strcasecmp(__VA_ARGS__) |
| 64 | +#define strcasestr_P(...) strcasestr(__VA_ARGS__) |
| 65 | +#define strcspn_P(...) strcspn(__VA_ARGS__) |
| 66 | +#define strlcat_P(...) strlcat(__VA_ARGS__) |
| 67 | +#define strlcpy_P(...) strlcpy(__VA_ARGS__) |
| 68 | +#define strnlen_P(...) strnlen(__VA_ARGS__) |
| 69 | +#define strncmp_P(...) strncmp(__VA_ARGS__) |
| 70 | +#define strncasecmp_P(...) strncasecmp(__VA_ARGS__) |
| 71 | +#define strncat_P(...) strncat(__VA_ARGS__) |
| 72 | +#define strncpy_P(...) strncpy(__VA_ARGS__) |
| 73 | +#define strpbrk_P(...) strpbrk(__VA_ARGS__) |
| 74 | +#define strrchr_P(...) strrchr(__VA_ARGS__) |
| 75 | +#define strsep_P(...) strsep(__VA_ARGS__) |
| 76 | +#define strspn_P(...) strspn(__VA_ARGS__) |
| 77 | +#define strstr_P(...) strstr(__VA_ARGS__) |
| 78 | +#define strtok_P(...) strtok(__VA_ARGS__) |
| 79 | +#define strtok_P(...) strtok(__VA_ARGS__) |
| 80 | +#define strlen_P(...) strlen(__VA_ARGS__) |
| 81 | +#define strnlen_P(...) strnlen(__VA_ARGS__) |
| 82 | +#define memcpy_P(...) memcpy(__VA_ARGS__) |
| 83 | +#define strcpy_P(...) strcpy(__VA_ARGS__) |
| 84 | +#define strncpy_P(...) strncpy(__VA_ARGS__) |
| 85 | +#define strcat_P(...) strcat(__VA_ARGS__) |
| 86 | +#define strlcat_P(...) strlcat(__VA_ARGS__) |
| 87 | +#define strncat_P(...) strncat(__VA_ARGS__) |
| 88 | +#define strcmp_P(...) strcmp(__VA_ARGS__) |
| 89 | +#define strncmp_P(...) strncmp(__VA_ARGS__) |
| 90 | +#define strcasecmp_P(...) strcasecmp(__VA_ARGS__) |
| 91 | +#define strncasecmp_P(...) strncasecmp(__VA_ARGS__) |
| 92 | +#define strstr_P(...) strstr(__VA_ARGS__) |
| 93 | +#define strlcpy_P(...) strlcpy(__VA_ARGS__) |
| 94 | +#define memcmp_P(...) memcmp(__VA_ARGS__) |
0 commit comments