Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / minix / bitmap.h @ 13

History | View | Annotate | Download (1.09 KB)

1 13 up20180614
#ifndef _BITMAP_H
2
#define _BITMAP_H
3
4
/* Bit map operations to manipulate bits of a simple mask variable. */
5
#define bit_set(mask, n)        ((mask) |= (1 << (n)))
6
#define bit_unset(mask, n)        ((mask) &= ~(1 << (n)))
7
#define bit_isset(mask, n)        ((mask) & (1 << (n)))
8
#define bit_empty(mask)                ((mask) = 0)
9
#define bit_fill(mask)                ((mask) = ~0)
10
11
/* Definitions previously in kernel/const.h */
12
#define BITCHUNK_BITS   (sizeof(bitchunk_t) * CHAR_BIT)
13
#define BITMAP_CHUNKS(nr_bits) (((nr_bits)+BITCHUNK_BITS-1)/BITCHUNK_BITS)
14
#define MAP_CHUNK(map,bit) (map)[((bit)/BITCHUNK_BITS)]
15
#define CHUNK_OFFSET(bit) ((bit)%BITCHUNK_BITS)
16
#define GET_BIT(map,bit) ( MAP_CHUNK(map,bit) & (1 << CHUNK_OFFSET(bit) ))
17
#define SET_BIT(map,bit) ( MAP_CHUNK(map,bit) |= (1 << CHUNK_OFFSET(bit) ))
18
#define UNSET_BIT(map,bit) ( MAP_CHUNK(map,bit) &= ~(1 << CHUNK_OFFSET(bit) ))
19
20
#if defined(CONFIG_SMP) && defined(__GNUC__)
21
#ifndef __ASSEMBLY__
22
static inline void bits_fill(bitchunk_t * chunks, unsigned bits)
23
{
24
        unsigned c, cnt;
25
26
        cnt = BITMAP_CHUNKS(bits);
27
        for (c = 0; c < cnt; c++)
28
                bit_fill(chunks[c]);
29
}
30
#endif
31
#endif
32
33
34
#endif        /* _BITMAP_H */