libosmocore
0.6.3
Osmocom core library
Main Page
Modules
Data Structures
Files
File List
Globals
bitvec.h
Go to the documentation of this file.
1
#ifndef _BITVEC_H
2
#define _BITVEC_H
3
4
/* bit vector utility routines */
5
6
/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
7
*
8
* All Rights Reserved
9
*
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the GNU General Public License along
21
* with this program; if not, write to the Free Software Foundation, Inc.,
22
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
*
24
*/
25
34
#include <stdint.h>
35
40
enum
bit_value
{
41
ZERO
= 0,
42
ONE
= 1,
43
L
= 2,
44
H
= 3,
45
};
46
48
struct
bitvec
{
49
unsigned
int
cur_bit
;
50
unsigned
int
data_len
;
51
uint8_t *
data
;
52
};
53
54
enum
bit_value
bitvec_get_bit_pos
(
const
struct
bitvec
*bv,
unsigned
int
bitnr);
55
enum
bit_value
bitvec_get_bit_pos_high
(
const
struct
bitvec
*bv,
56
unsigned
int
bitnr);
57
unsigned
int
bitvec_get_nth_set_bit
(
const
struct
bitvec
*bv,
unsigned
int
n);
58
int
bitvec_set_bit_pos
(
struct
bitvec
*bv,
unsigned
int
bitnum,
59
enum
bit_value
bit);
60
int
bitvec_set_bit
(
struct
bitvec
*bv,
enum
bit_value
bit);
61
int
bitvec_get_bit_high
(
struct
bitvec
*bv);
62
int
bitvec_set_bits
(
struct
bitvec
*bv,
enum
bit_value
*bits,
int
count);
63
int
bitvec_set_uint
(
struct
bitvec
*bv,
unsigned
int
in,
int
count);
64
int
bitvec_get_uint
(
struct
bitvec
*bv,
int
num_bits);
65
int
bitvec_find_bit_pos
(
const
struct
bitvec
*bv,
unsigned
int
n,
enum
bit_value
val);
66
int
bitvec_spare_padding
(
struct
bitvec
*bv,
unsigned
int
up_to_bit);
67
70
#endif
/* _BITVEC_H */
include
osmocom
core
bitvec.h
Generated on Fri Aug 23 2013 20:51:42 for libosmocore by
1.8.1.2