Subversion Repositories shark

Rev

Rev 629 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
629 giacomo 1
#ifndef __BITOPS__
2
#define __BITOPS__
3
 
4
#include <linux/compatib.h>
1689 fabio 5
#include <arch/sys/cdefs.h>
629 giacomo 6
 
7
__BEGIN_DECLS
8
 
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
 
46
__END_DECLS
47
#endif