Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
#ifndef __BITOPS__
2
#define __BITOPS__
3
 
4
#include <linux/compatib.h>
5
 
6
#define LOCK_PREFIX ""
7
#define SMPVOL
8
 
9
/*
10
 * Some hacks to defeat gcc over-optimizations..
11
 */
12
struct __dummy { unsigned long a[100]; };
13
#define ADDR (*(struct __dummy *) addr)
14
#define CONST_ADDR (*(const struct __dummy *) addr)
15
 
16
extern __inline__ int set_bit(int nr, SMPVOL void * addr)
17
{
18
        int oldbit;
19
 
20
        __asm__ __volatile__(LOCK_PREFIX
21
                "btsl %2,%1\n\tsbbl %0,%0"
22
                :"=r" (oldbit),"=m" (ADDR)
23
                :"ir" (nr));
24
        return oldbit;
25
}
26
 
27
extern __inline__ int clear_bit(int nr, SMPVOL void * addr)
28
{
29
        int oldbit;
30
 
31
        __asm__ __volatile__(LOCK_PREFIX
32
                "btrl %2,%1\n\tsbbl %0,%0"
33
                :"=r" (oldbit),"=m" (ADDR)
34
                :"ir" (nr));
35
        return oldbit;
36
}
37
 
38
extern __inline__ int test_bit(int nr, const SMPVOL void * addr)
39
{
40
        return ((1UL << (nr & 31)) & (((const unsigned int *) addr)[nr >> 5])) != 0;
41
}
42
 
43
#endif