Commit Graph

21 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther 511b448fe3 bitvec: Force inlining of bitvec_set_bit_pos/bitvec_set_bit
The PCU is using bitvec_write_field a lot but on the
arm-poky-linux-gnueabi-gcc v4.8.1 the calls to set_bit and
set_bit_pos are not inlined. The inlined variant has been
a more quick for the PCU compressed bitmap decompression
testcase.

Used objdump -d to look at the bitvec_write_field before and
after the change. The branch to bitvec_set_bit is gone and a
inlined version has been used.

Change-Id: I0b6b90610f4c17f02e4efa064c3bf1ac2dccb22a
2016-07-16 21:02:41 +00:00
Harald Welte 14bf28a43d Mark input parameter to bitvec_set_bits() as 'const'
The input data is accessed in a read-only manner, so it should be marked
with the const qualifier.

Change-Id: I0d6b86289fa647594f3da1f1c0e0168685307a37
2016-06-27 15:19:10 +02:00
Harald Welte 2d2e2cca0d Update doxygen annotations in libosmocore
This adds and improves doxygen API descriptions all over libosmocore,
reducing the 'white spots' that don't have any documentation.
2016-05-05 18:49:27 +02:00
Max d4793212b5 Add function to add bits from array to bitvec
Add function which adds specified number of bits from each element of
array to the bit vector prefixing each addition with one and finishing
entire sequence with adding 0. This is very common patter for various
repetitive data structures described with CSN.1 in 3GPP standards.

Corresponding test vectors and doxygen headers are added too.
2016-03-17 14:07:19 +01:00
Holger Hans Peter Freyther ab0eb96dd9 bitvec: Untested speculative UBAN fix for the new routine
int << 31 does not seem to be defined, let's try to make it an
unsigned variable and see if that is pleasing the system.

Fixes:
bitvec.c:219:15: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
2016-02-18 20:28:25 +01:00
Max 0a59e9899f Expand bitvec interface
Add bit filling, shifting and other functions necessary for bit
compression implementation. Add corresponding tests.
2016-02-18 19:45:40 +01:00
Holger Hans Peter Freyther a9301a1a1f bitvec: Test and fix regression for C++->C conversion
bitvec_read_field/bitvec_write_field in the PCU used a C++ reference
and when porting to C it was decided to pass the parameter by value
and this lost the "back propagation" of the new index. Change the
parameter to be an in/out parameter and this way do not have a silent
semantic break in the osmo-pcu (where we copy the reference in csn.1
by value) and have a true compile failure.

Add Max's simple test for bitvec_unhex function leaving the checking
of bitvec_read_field and the side effect in the datastructure about
the number of bits still open.
2016-01-30 10:54:43 +01:00
Max 912bc6ff50 Add doxygen comments to clarify function use 2016-01-30 10:18:38 +01:00
Holger Hans Peter Freyther 2745b48940 bitvec: Fix build on older gcc
bitvec.c: In function 'bitvec_unhex':
bitvec.c:389: error: 'for' loop initial declarations are only allowed in C99 mode
bitvec.c:389: note: use option -std=c99 or -std=gnu99 to compile your code
2016-01-27 17:08:02 +01:00
Max a15f05f1b4 Add bitvec-related functions from Osmo-PCU
Allocation, pack/unpack, field access and helper routines used
extensively by Osmo-PCU. Whenever memory allocation happens, alocator
context is passed explicitly by caller.
2016-01-26 11:01:23 +01:00
Max e49af08f5b bitvec: Fix interface to consistently use unsigned int
Use unsigned int for the length throughout the interface. We will
never have a a negative length.

Sponsored-by: On-Waves ehf
2016-01-22 23:22:48 +01:00
Jacob Erlbeck 5f349be820 bitvec: Add get/set byte sequences
The new functions bitvec_get_bytes and bitvec_set_bytes copy
byte sequences from bitvecs to uint8_t arrays and vice versa.
While the bytes in the bitvecs do not need to be aligned, the uint8_t
arrays always are. In case the bytes in the bitvec are aligned, the
implementation uses memcpy.

Note that the implementation like the other existing functions assume
MSB first encoding.

[hfreyther: Squash the comment fix into this commit as well]

Sponsored-by: On-Waves ehf
2016-01-15 14:51:32 +01:00
Katerina Barone-Adesi c28c6a02d2 misc: Doxygen tweaks: fixed some typos and minor errors
Doxygen generates quite a lot of warnings on libosmocore. Some of them
are obvious typos - this patch aims to fix such low-hanging fruit.
2013-02-15 13:27:59 +01:00
Sylvain Munaut dca7d2caaa doc: Fix the Doxygen section endings
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2012-04-18 21:53:23 +02:00
Harald Welte ba6988bd89 some more doxygen work (include the notion of modules) 2011-08-17 17:14:11 +02:00
Pablo Neira Ayuso 36bdf2cb73 bitvec: add bitvec_find_first_bit_pos() from gsm/rxlev_stat.c
This patch adds bitvec_find_bit_pos() to bitvec.c where it really
belongs to. Before this patch used to be part of gsm/rxlev_stat.c
2011-03-28 20:00:45 +02:00
Pablo Neira Ayuso 8341934844 include: reorganize headers file to include/osmocom/[gsm|core]
This patch moves all GSM-specific definitions to include/osmocom/gsm.
Moreover, the headers in include/osmocore/ have been moved to
include/osmocom/core.

This has been proposed by Harald Welte and Sylvain Munaunt.

Tested with `make distcheck'.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-03-23 18:09:28 +01:00
Andreas.Eversberg dc0ebdfbdf bitvec: Fix decoding of H / L values
it returns if a given bit in the vector is "high" or "low".
the bitval that represents "high" depends on the bit position.
bitval2mask returns that. so we must check if the bit in the vector
equals the returned bitval.
2010-10-24 11:59:33 +02:00
Andreas.Eversberg 0ebd688746 Added some "get"-functions to bitvec of libosmocore.
- Getting Low or High value from current postion
- Getting unsigned interger from current postion
2010-05-19 18:14:01 +02:00
Harald Welte d9abf01436 mark some occasions of bitvec as 'const' as appropriate 2010-03-06 11:28:49 +01:00
Harald Welte ec8b4501c7 intial checkin of the libosmocore project 2010-02-20 20:34:29 +01:00