OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [mm0/] [include/] [lib/] [bit.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
#ifndef __LIB_BIT_H__
2
#define __LIB_BIT_H__
3
 
4
#include <l4lib/types.h>
5
 
6
unsigned int __clz(unsigned int bitvector);
7
int find_and_set_first_free_bit(u32 *word, unsigned int lastbit);
8
int find_and_set_first_free_contig_bits(u32 *word,  unsigned int limit,
9
                                        int nbits);
10
int check_and_clear_bit(u32 *word, int bit);
11
int check_and_clear_contig_bits(u32 *word, int first, int nbits);
12
 
13
int check_and_set_bit(u32 *word, int bit);
14
 
15
/* Set */
16
static inline void setbit(unsigned int *w, unsigned int flags)
17
{
18
        *w |= flags;
19
}
20
 
21
 
22
/* Clear */
23
static inline void clrbit(unsigned int *w, unsigned int flags)
24
{
25
        *w &= ~flags;
26
}
27
 
28
/* Test */
29
static inline int tstbit(unsigned int *w, unsigned int flags)
30
{
31
        return *w & flags;
32
}
33
 
34
/* Test and clear */
35
static inline int tstclr(unsigned int *w, unsigned int flags)
36
{
37
        int res = tstbit(w, flags);
38
 
39
        clrbit(w, flags);
40
 
41
        return res;
42
}
43
 
44
#endif /* __LIB_BIT_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.