Debian Codegraph @

src/OVAL/probes/SEAP/generic/bitmap.h

raw symbols SCIP
1 /*
2 * Copyright 2009 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * "Daniel Kopecek" <[email protected]>
21 */
22
23 #pragma once
24 #ifndef BITMAP_H
25 #define BITMAP_H
26
27 #include <stdint.h>
28 #include "../../../../common/util.h"
29
30
31 typedef uint32_t bitmap_cell_t;
32 typedef uint16_t bitmap_size_t;
33 typedef int32_t bitmap_bitn_t;
34
35 typedef struct {
36 #if defined(SEAP_THREAD_SAFE)
37 uint8_t locked;
38 #endif
39 bitmap_size_t size; /* bit capacity = size * BITMAP_CELLSIZE */
40 bitmap_size_t realsize;
41 bitmap_cell_t *cells;
42 bitmap_bitn_t count;
43 } bitmap_t;
44
45 #if defined(SEAP_THREAD_SAFE)
46 # define BITMAP_INITIALIZER { 0, 128, 0, NULL, 0 }
47 #else
48 # define BITMAP_INITIALIZER { 128, 0, NULL, 0 }
49 #endif
50
51 #define BITMAP_CELLSIZE (sizeof (bitmap_cell_t) * 8)
52
53 bitmap_t *bitmap_new (bitmap_size_t size);
54 int *bitmap_init (bitmap_t *bitmap, bitmap_size_t size);
55 int *bitmap_reinit (bitmap_t *bitmap, bitmap_size_t size);
56 int bitmap_set (bitmap_t *bitmap, bitmap_bitn_t bitn);
57 int bitmap_cas (bitmap_t *bitmap, bitmap_bitn_t bitn, int v);
58 int bitmap_unset (bitmap_t *bitmap, bitmap_bitn_t bitn);
59 int bitmap_clear (bitmap_t *bitmap);
60 bitmap_bitn_t bitmap_setfree (bitmap_t *bitmap);
61 bitmap_bitn_t bitmap_getfree (bitmap_t *bitmap);
62 void bitmap_free (bitmap_t *bitmap);
63
64
65 #endif