Subversion Repositories shark

Rev

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