aboutsummaryrefslogtreecommitdiffstats
path: root/src/bitvec.c
AgeCommit message (Collapse)AuthorFilesLines
2018-06-28Don't call abort() directly, always use osmo_panic()Harald Welte1-1/+2
A loooong time ago, we introduced osmo_panic() as a wrapper around abort(). The advantage is, that this wrapper can be overridden, and that it will also work in embedded (bare iron) targets, where the abort simply translates to an infinite loop. Change-Id: I5a70eb65952cbc329bf96eacb428b07a9da32433
2017-11-13Fix/Update copyright notices; Add SPDX annotationHarald Welte1-1/+3
Let's fix some erroneous/accidential references to wrong license, update copyright information where applicable and introduce a SPDX-License-Identifier to all files. Change-Id: I39af26c6aaaf5c926966391f6565fc5936be21af
2017-10-24Simplify bitvec_write_field()Max1-9/+7
Use existing function instead of copy-pasted loop. Change-Id: I9fe27c06125ac52e02e63dcded056a5f1cf68f41 Related: OS#1526
2017-10-24Replace bitvec_set_uint() with bitvec_set_u64()Max1-9/+26
Old bitvec_set_uint() uses "unsigned int" as input parameter which length is not guaranteed. It does not allow to specify which bit_value to set and does not check for incorrect length. Overall this makes it harder to re-use and more error-prone. Let's replace it with extended implementation which uses fixed type length parameters and extra checks. The additional parameter allows caller to explicitly indicate the need to use L/H instead of 0/1 for bit vector elements. It's necessary to properly encode some of the messages from 3GPP TS 44.018, for example ยง10.5.2.16 IA Rest Octets. The old function is left for backward compatibility as a tiny wrapper around new function and will be deprecated in follow-up patches. Change-Id: I1b670dacb55fb3063271d045f9faa10fccba10a6 Related: OS#1526
2017-06-23doxygen: unify use of \file across the boardNeels Hofmeyr1-6/+11
Considering the various styles and implications found in the sources, edit scores of files to follow the same API doc guidelines around the doxygen grouping and the \file tag. Many files now show a short description in the generated API doc that was so far only available as C comment. The guidelines and reasoning behind it is documented at https://osmocom.org/projects/cellular-infrastructure/wiki/Guidelines_for_API_documentation In some instances, remove file comments and add to the corresponding group instead, to be shared among several files (e.g. bitvec). Change-Id: Ifa70e77e90462b5eb2b0457c70fd25275910c72b
2017-06-23doxygen: enable AUTOBRIEF, drop \briefNeels Hofmeyr1-30/+30
Especially for short descriptions, it is annoying to have to type \brief for every single API doc. Drop all \brief and enable the AUTOBRIEF feature of doxygen, which always takes the first sentence of an API doc as the brief description. Change-Id: I11a8a821b065a128108641a2a63fb5a2b1916e87
2017-06-12update/extend doxygen documentationHarald Welte1-3/+2
It's a pity that even with this patch we still are fare away from having the whole API documented. However, at least we have a more solid foundation. Updates not only extend the documentation, but also make sure it is rendered properly in the doxygen HTML. Change-Id: I1344bd1a6869fb00de7c1899a8db93bba9bafce3
2017-01-06Add function to get uninterrupted bit runPravin Kumarvel1-0/+45
Function bitvec_rl_curbit added to get number of uninterrupted bits run in vector starting from the current bit till max number of bits. Test case is added to check bitvec_rl_curbit. Change-Id: Iae153d3639ea6b891c1fc10d7801a435c9492e26
2016-07-16bitvec: Force inlining of bitvec_set_bit_pos/bitvec_set_bitHolger Hans Peter Freyther1-2/+2
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-06-27Mark input parameter to bitvec_set_bits() as 'const'Harald Welte1-1/+1
The input data is accessed in a read-only manner, so it should be marked with the const qualifier. Change-Id: I0d6b86289fa647594f3da1f1c0e0168685307a37
2016-05-05Update doxygen annotations in libosmocoreHarald Welte1-11/+40
This adds and improves doxygen API descriptions all over libosmocore, reducing the 'white spots' that don't have any documentation.
2016-03-17Add function to add bits from array to bitvecMax1-0/+40
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-02-18bitvec: Untested speculative UBAN fix for the new routineHolger Hans Peter Freyther1-1/+1
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-18Expand bitvec interfaceMax1-5/+129
Add bit filling, shifting and other functions necessary for bit compression implementation. Add corresponding tests.
2016-01-30bitvec: Test and fix regression for C++->C conversionHolger Hans Peter Freyther1-9/+9
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-30Add doxygen comments to clarify function useMax1-1/+14
2016-01-27bitvec: Fix build on older gccHolger Hans Peter Freyther1-1/+3
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-26Add bitvec-related functions from Osmo-PCUMax1-0/+95
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-22bitvec: Fix interface to consistently use unsigned intMax1-7/+7
Use unsigned int for the length throughout the interface. We will never have a a negative length. Sponsored-by: On-Waves ehf
2016-01-15bitvec: Add get/set byte sequencesJacob Erlbeck1-0/+75
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
2013-02-15misc: Doxygen tweaks: fixed some typos and minor errorsKaterina Barone-Adesi1-1/+1
Doxygen generates quite a lot of warnings on libosmocore. Some of them are obvious typos - this patch aims to fix such low-hanging fruit.
2012-04-18doc: Fix the Doxygen section endingsSylvain Munaut1-1/+1
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-08-17some more doxygen work (include the notion of modules)Harald Welte1-11/+42
2011-03-28bitvec: add bitvec_find_first_bit_pos() from gsm/rxlev_stat.cPablo Neira Ayuso1-0/+14
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-23include: reorganize headers file to include/osmocom/[gsm|core]0.2.0Pablo Neira Ayuso1-1/+1
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>
2010-10-24bitvec: Fix decoding of H / L valuesAndreas.Eversberg1-1/+1
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-05-19Added some "get"-functions to bitvec of libosmocore.Andreas.Eversberg1-0/+49
- Getting Low or High value from current postion - Getting unsigned interger from current postion
2010-03-06mark some occasions of bitvec as 'const' as appropriateHarald Welte1-2/+2
2010-02-20intial checkin of the libosmocore projectHarald Welte1-0/+170