Open SCAP Library: bitmap.h Source File

Open SCAP Library

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

bitmap.h
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Authors:
20 * "Daniel Kopecek" <dkopecek@redhat.com>
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 OSCAP_HIDDEN_START;
31
32 typedef uint32_t bitmap_cell_t;
33 typedef uint16_t bitmap_size_t;
34 typedef int32_t bitmap_bitn_t;
35
36 typedef struct {
37 #if defined(SEAP_THREAD_SAFE)
38 uint8_t locked;
39 #endif
40 bitmap_size_t size; /* bit capacity = size * BITMAP_CELLSIZE */
41 bitmap_size_t realsize;
42 bitmap_cell_t *cells;
43 bitmap_bitn_t count;
44 } bitmap_t;
45
46 #if defined(SEAP_THREAD_SAFE)
47 # define BITMAP_INITIALIZER { 0, 128, 0, NULL, 0 }
48 #else
49 # define BITMAP_INITIALIZER { 128, 0, NULL, 0 }
50 #endif
51
52 #define BITMAP_CELLSIZE (sizeof (bitmap_cell_t) * 8)
53
54 bitmap_t *bitmap_new (bitmap_size_t size);
55 int *bitmap_init (bitmap_t *bitmap, bitmap_size_t size);
56 int *bitmap_reinit (bitmap_t *bitmap, bitmap_size_t size);
57 int bitmap_set (bitmap_t *bitmap, bitmap_bitn_t bitn);
58 int bitmap_cas (bitmap_t *bitmap, bitmap_bitn_t bitn, int v);
59 int bitmap_unset (bitmap_t *bitmap, bitmap_bitn_t bitn);
60 int bitmap_clear (bitmap_t *bitmap);
61 bitmap_bitn_t bitmap_setfree (bitmap_t *bitmap);
62 bitmap_bitn_t bitmap_getfree (bitmap_t *bitmap);
63 void bitmap_free (bitmap_t *bitmap);
64
65 OSCAP_HIDDEN_END;
66
67 #endif
bitmap_t
Definition: bitmap.h:36