[MERGED] libosmocore[master]: Expand bit pretty-printer

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Mon Sep 18 12:57:39 UTC 2017


Max has submitted this change and it was merged.

Change subject: Expand bit pretty-printer
......................................................................


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
---
M include/osmocom/core/bits.h
1 file changed, 11 insertions(+), 9 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/core/bits.h b/include/osmocom/core/bits.h
index 17fe1c6..c6a142f 100644
--- a/include/osmocom/core/bits.h
+++ b/include/osmocom/core/bits.h
@@ -69,15 +69,17 @@
   (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 */
 

-- 
To view, visit https://gerrit.osmocom.org/3915
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I72528bc1e376134c5a7b6e7a50c48e38c3f48b0a
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list