From 6a5ef46dd018c8e66e341a531403e40de24893f2 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 24 Feb 2016 16:05:48 +0100 Subject: Add byte printing macros It's sometimes handy for debugging to be able to immediately see which bits are set in a given byte. Generalize macro used for that in bitvec tests and make it available for the rest of the library. --- tests/bitvec/bitvec_test.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'tests/bitvec') diff --git a/tests/bitvec/bitvec_test.c b/tests/bitvec/bitvec_test.c index 800a0406..76d6773e 100644 --- a/tests/bitvec/bitvec_test.c +++ b/tests/bitvec/bitvec_test.c @@ -11,17 +11,6 @@ #include #include -#define BIN_PATTERN "%d%d%d%d%d%d%d%d" -#define BIN(byte) \ - (byte & 0x80 ? 1 : 0), \ - (byte & 0x40 ? 1 : 0), \ - (byte & 0x20 ? 1 : 0), \ - (byte & 0x10 ? 1 : 0), \ - (byte & 0x08 ? 1 : 0), \ - (byte & 0x04 ? 1 : 0), \ - (byte & 0x02 ? 1 : 0), \ - (byte & 0x01 ? 1 : 0) - static char lol[1024]; // we pollute this with printed vectors static inline void test_rl(const struct bitvec *bv) { @@ -45,7 +34,7 @@ static inline void test_get(struct bitvec *bv, unsigned n) int16_t x = bitvec_get_int16_msb(bv, n); uint8_t tmp[2]; osmo_store16be(x, &tmp); - printf(" -> %d (%u bit) ["BIN_PATTERN" "BIN_PATTERN"]:\n", x, n, BIN(tmp[0]), BIN(tmp[1])); + printf(" -> %d (%u bit) ["OSMO_BIN_SPEC" "OSMO_BIN_SPEC"]:\n", x, n, OSMO_BIN_PRINT(tmp[0]), OSMO_BIN_PRINT(tmp[1])); bitvec_to_string_r(bv, lol); printf("%s [%d]\n", lol, bv->cur_bit); } -- cgit v1.2.3