ctr: Encode negative integers in normal hex notation

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-08-22 13:06:15 -04:00
parent 7d014933ce
commit ff7be3e026
2 changed files with 6 additions and 15 deletions

View file

@ -16,7 +16,8 @@
// Macro to encode an integer for use with DECL_CTR_INT()
#define _CTR_HEX(H) ((H) > 9 ? (H) - 10 + 'A' : (H) + '0')
#define _CTR_INT(V, S) _CTR_HEX(((uint32_t)(V) >> (S)) & 0x0f)
#define _CTR_SHIFT(V, S) _CTR_HEX(((uint32_t)(V) >> (S)) & 0x0f)
#define _CTR_INT(V, S) ((V) < 0 ? _CTR_SHIFT(-(V), (S)) : _CTR_SHIFT((V), (S)))
#define CTR_INT(VALUE) { \
' ', (VALUE) < 0 ? '-' : '+', '0', 'x', \
_CTR_INT((VALUE),28), _CTR_INT((VALUE),24), \