]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4util/include/alloc.h
update
[l4.git] / l4 / pkg / l4util / include / alloc.h
1 /*!
2  * \file
3  * \brief  Allocator using a bit-array
4  *
5  * \date   09/14/2004
6  * \author Jork Loeser <jork.loeser@inf.tu-dresden.de>
7  *
8  */
9 /*
10  * (c) 2004-2009 Author(s)
11  *     economic rights: Technische Universität Dresden (Germany)
12  * This file is part of TUD:OS and distributed under the terms of the
13  * GNU Lesser General Public License 2.1.
14  * Please see the COPYING-LGPL-2.1 file for details.
15  */
16 #ifndef __UTIL_INCLUDE_ALLOC_H_
17 #define __UTIL_INCLUDE_ALLOC_H_
18 #include <l4/sys/l4int.h>
19 #include <l4/util/bitops.h>
20 #include <l4/sys/compiler.h>
21
22 EXTERN_C_BEGIN
23
24 typedef struct {
25     int base, count, next_elem;
26     l4_umword_t *bits;
27 } l4util_alloc_t;
28
29 #define L4UTIL_ALLOC_BITS_SIZE (8 * sizeof(l4_umword_t))
30
31 L4_CV l4util_alloc_t *l4util_alloc_init(int count, int base);
32 L4_CV int l4util_alloc_avail(l4util_alloc_t *alloc, int elem);
33 L4_CV int l4util_alloc_occupy(l4util_alloc_t *alloc, int elem);
34 L4_CV int l4util_alloc_alloc(l4util_alloc_t *alloc);
35 L4_CV int l4util_alloc_free(l4util_alloc_t *alloc, int elem);
36
37 EXTERN_C_END
38 #endif