Open SCAP Library
Loading...
Searching...
No Matches
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
31typedef uint32_t bitmap_cell_t;
32typedef uint16_t bitmap_size_t;
33typedef int32_t bitmap_bitn_t;
34
35typedef 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
53bitmap_t *bitmap_new (bitmap_size_t size);
54int *bitmap_init (bitmap_t *bitmap, bitmap_size_t size);
55int *bitmap_reinit (bitmap_t *bitmap, bitmap_size_t size);
56int bitmap_set (bitmap_t *bitmap, bitmap_bitn_t bitn);
57int bitmap_cas (bitmap_t *bitmap, bitmap_bitn_t bitn, int v);
58int bitmap_unset (bitmap_t *bitmap, bitmap_bitn_t bitn);
59int bitmap_clear (bitmap_t *bitmap);
60bitmap_bitn_t bitmap_setfree (bitmap_t *bitmap);
61bitmap_bitn_t bitmap_getfree (bitmap_t *bitmap);
62void bitmap_free (bitmap_t *bitmap);
63
64
65#endif
Definition bitmap.h:35