summaryrefslogtreecommitdiff
path: root/pfinet.old/glue-include/asm/bitops.h
blob: 8c5a835d2a88777a8eed179748163d825a15a51f (plain)
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
37
#ifndef _HACK_ASM_BITOPS_H
#define _HACK_ASM_BITOPS_H

/* We don't need atomicity in the Linux code because we serialize all
   entries to it.  */

#include <stdint.h>

#define BITOPS_WORD(nr, addr)	(((uint32_t *) (addr))[(nr) / 32])
#define BITOPS_MASK(nr)		(1 << ((nr) & 31))

static __inline__ void set_bit (int nr, void *addr)
{ BITOPS_WORD (nr, addr) |= BITOPS_MASK (nr); }

static __inline__ void clear_bit (int nr, void *addr)
{ BITOPS_WORD (nr, addr) &= ~BITOPS_MASK (nr); }

static __inline__ void change_bit (int nr, void *addr)
{ BITOPS_WORD (nr, addr) ^= BITOPS_MASK (nr); }

static __inline__ int test_bit (int nr, void *addr)
{ return BITOPS_WORD (nr, addr) & BITOPS_MASK (nr); }

static __inline__ int test_and_set_bit (int nr, void *addr)
{
  int res = BITOPS_WORD (nr, addr) & BITOPS_MASK (nr);
  BITOPS_WORD (nr, addr) |= BITOPS_MASK (nr);
  return res;
}

#define find_first_zero_bit #error loser
#define find_next_zero_bit #error loser

#define ffz(word)	(ffs (~(unsigned int) (word)) - 1)


#endif