OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-generic/] [bitops.h] - Blame information for rev 1633

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef _ASM_GENERIC_BITOPS_H_
2
#define _ASM_GENERIC_BITOPS_H_
3
 
4
/*
5
 * For the benefit of those who are trying to port Linux to another
6
 * architecture, here are some C-language equivalents.  You should
7
 * recode these in the native assembly language, if at all possible.
8
 * To guarantee atomicity, these routines call cli() and sti() to
9
 * disable interrupts while they operate.  (You have to provide inline
10
 * routines to cli() and sti().)
11
 *
12
 * Also note, these routines assume that you have 32 bit integers.
13
 * You will have to change this if you are trying to port Linux to the
14
 * Alpha architecture or to a Cray.  :-)
15
 *
16
 * C language equivalents written by Theodore Ts'o, 9/26/92
17
 */
18
 
19
extern __inline__ int set_bit(int nr,int * addr)
20
{
21
        int     mask, retval;
22
 
23
        addr += nr >> 5;
24
        mask = 1 << (nr & 0x1f);
25
        cli();
26
        retval = (mask & *addr) != 0;
27
        *addr |= mask;
28
        sti();
29
        return retval;
30
}
31
 
32
extern __inline__ int clear_bit(int nr, int * addr)
33
{
34
        int     mask, retval;
35
 
36
        addr += nr >> 5;
37
        mask = 1 << (nr & 0x1f);
38
        cli();
39
        retval = (mask & *addr) != 0;
40
        *addr &= ~mask;
41
        sti();
42
        return retval;
43
}
44
 
45
extern __inline__ int test_bit(int nr, int * addr)
46
{
47
        int     mask;
48
 
49
        addr += nr >> 5;
50
        mask = 1 << (nr & 0x1f);
51
        return ((mask & *addr) != 0);
52
}
53
#endif /* _ASM_GENERIC_BITOPS_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.