aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-09-12 15:34:35 +0200
committerMax <msuraev@sysmocom.de>2017-09-18 09:14:28 +0000
commita52d839343aea9b81c2463f52c3c3358778698f3 (patch)
tree2e50d1c77f8789eb4718f9de0fffb046ccf39acd /include
parent98f6482ec7eb603b17e5a99fb92d28c17fcf61e9 (diff)
Expand bit pretty-printer
Add OSMO_BIT_PRINT_EX() which is like OSMO_BIT_PRINT() but allows to specify character to be printed for set bits. It's useful to print bytes used as mask where set bit has particular semantics - for example TS mask in OsmoPCU. Change-Id: I72528bc1e376134c5a7b6e7a50c48e38c3f48b0a Related: OS#2282
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/core/bits.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/include/osmocom/core/bits.h b/include/osmocom/core/bits.h
index 17fe1c6a..c6a142f8 100644
--- a/include/osmocom/core/bits.h
+++ b/include/osmocom/core/bits.h
@@ -69,15 +69,17 @@ int osmo_pbit2ubit_ext(ubit_t *out, unsigned int out_ofs,
(byte & 0x01 ? 1 : 0)
#define OSMO_BIT_SPEC "%c%c%c%c%c%c%c%c"
-#define OSMO_BIT_PRINT(byte) \
- (byte & 0x80 ? '1' : '.'), \
- (byte & 0x40 ? '1' : '.'), \
- (byte & 0x20 ? '1' : '.'), \
- (byte & 0x10 ? '1' : '.'), \
- (byte & 0x08 ? '1' : '.'), \
- (byte & 0x04 ? '1' : '.'), \
- (byte & 0x02 ? '1' : '.'), \
- (byte & 0x01 ? '1' : '.')
+#define OSMO_BIT_PRINT_EX(byte, ch) \
+ (byte & 0x80 ? ch : '.'), \
+ (byte & 0x40 ? ch : '.'), \
+ (byte & 0x20 ? ch : '.'), \
+ (byte & 0x10 ? ch : '.'), \
+ (byte & 0x08 ? ch : '.'), \
+ (byte & 0x04 ? ch : '.'), \
+ (byte & 0x02 ? ch : '.'), \
+ (byte & 0x01 ? ch : '.')
+
+#define OSMO_BIT_PRINT(byte) OSMO_BIT_PRINT_EX(byte, '1')
/* BIT REVERSAL */