diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-03-04 23:24:43 -0500 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2019-03-17 19:38:18 -0400 |
commit | 7d73a35805a61a40f49d0840741434ab9548d638 (patch) | |
tree | be0fa334caf5ffa96a272c44a38de5f560041a47 /src/ctr.h | |
parent | b28e95ca1aa2860c0869041c29a3ba27054e5967 (diff) | |
download | kutter-7d73a35805a61a40f49d0840741434ab9548d638.tar.gz kutter-7d73a35805a61a40f49d0840741434ab9548d638.tar.xz kutter-7d73a35805a61a40f49d0840741434ab9548d638.zip |
command: Support evaluating C expressions in DECL_CONSTANT()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/ctr.h')
-rw-r--r-- | src/ctr.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -14,4 +14,17 @@ static char __PASTE(_DECLS_, __LINE__)[] __attribute__((used)) \ __section(".compile_time_request") = (REQUEST) +#define CTR_INT(V, S) ((((uint32_t)(V) >> S) & 0x3f) + 48) + +// Declare a compile time request with an integer expression +#define DECL_CTR_INT(REQUEST, VALUE) \ + static struct { char _r[sizeof(REQUEST)]; char _v[8]; } \ + __PASTE(_DECLI_, __LINE__) __attribute__((used)) \ + __section(".compile_time_request") = { \ + REQUEST " ", { \ + (VALUE) < 0 ? '-' : '+', \ + CTR_INT((VALUE),0), CTR_INT((VALUE),6), \ + CTR_INT((VALUE),12), CTR_INT((VALUE),18), \ + CTR_INT((VALUE),24), CTR_INT((VALUE),30), 0 } } + #endif // ctr.h |