File: bitops.h

package info (click to toggle)
conntrack 1%3A1.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,948 kB
  • sloc: ansic: 17,370; sh: 11,494; yacc: 1,554; lex: 186; makefile: 94
file content (36 lines) | stat: -rw-r--r-- 709 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef _BITOPS_H_
#define _BITOPS_H_

#include <stdlib.h>

static inline void set_bit_u32(int nr, u_int32_t *addr)
{
	addr[nr >> 5] |= (1UL << (nr & 31));
}

static inline void unset_bit_u32(int nr, u_int32_t *addr)
{
	addr[nr >> 5] &= ~(1UL << (nr & 31));
}

static inline int test_bit_u32(int nr, const u_int32_t *addr)
{
	return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0;
}

static inline void set_bit_u16(int nr, u_int16_t *addr)
{
	addr[nr >> 4] |= (1UL << (nr & 15));
}

static inline void unset_bit_u16(int nr, u_int16_t *addr)
{
	addr[nr >> 4] &= ~(1UL << (nr & 15));
}

static inline int test_bit_u16(int nr, const u_int16_t *addr)
{
	return ((1UL << (nr & 15)) & (addr[nr >> 4])) != 0;
}

#endif