[PATCH 2/2] bitvec: Add comment about bit ordering

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/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Mon Dec 21 10:26:28 UTC 2015


The bitvec implementation expects an MSB first encoded bitstream,
which is not mentioned anywhere explicitly.

This commits adds a comment to the bitvec header file.

Sponsored-by: On-Waves ehf
---
 include/osmocom/core/bitvec.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h
index 445730e..89eb784 100644
--- a/include/osmocom/core/bitvec.h
+++ b/include/osmocom/core/bitvec.h
@@ -28,6 +28,14 @@
 
 /*! \file bitvec.h
  *  \brief Osmocom bit vector abstraction
+ *
+ *  These functions assume a MSB (most significant bit) first layout of the
+ *  bits, so that for instance the 5 bit number abcde (a is MSB) can be
+ *  embedded into a byte sequence like in xxxxxxab cdexxxxx. The bit count
+ *  starts with the MSB, so the bits in a byte are numbered (MSB) 01234567 (LSB).
+ *  Note that there are other incompatible encodings, like it is used
+ *  for the EGPRS RLC data block headers (there the bits are numbered from LSB
+ *  to MSB).
  */
 
 #include <stdint.h>
-- 
1.9.1




More information about the OpenBSC mailing list