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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-generic/] [bitops.h] - Diff between revs 1765 and 1782

Only display areas with differences | Details | Blame | View Log

Rev 1765 Rev 1782
#ifndef _ASM_GENERIC_BITOPS_H_
#ifndef _ASM_GENERIC_BITOPS_H_
#define _ASM_GENERIC_BITOPS_H_
#define _ASM_GENERIC_BITOPS_H_
 
 
/*
/*
 * For the benefit of those who are trying to port Linux to another
 * For the benefit of those who are trying to port Linux to another
 * architecture, here are some C-language equivalents.  You should
 * architecture, here are some C-language equivalents.  You should
 * recode these in the native assembly language, if at all possible.
 * recode these in the native assembly language, if at all possible.
 * To guarantee atomicity, these routines call cli() and sti() to
 * To guarantee atomicity, these routines call cli() and sti() to
 * disable interrupts while they operate.  (You have to provide inline
 * disable interrupts while they operate.  (You have to provide inline
 * routines to cli() and sti().)
 * routines to cli() and sti().)
 *
 *
 * Also note, these routines assume that you have 32 bit integers.
 * Also note, these routines assume that you have 32 bit integers.
 * You will have to change this if you are trying to port Linux to the
 * You will have to change this if you are trying to port Linux to the
 * Alpha architecture or to a Cray.  :-)
 * Alpha architecture or to a Cray.  :-)
 *
 *
 * C language equivalents written by Theodore Ts'o, 9/26/92
 * C language equivalents written by Theodore Ts'o, 9/26/92
 */
 */
 
 
extern __inline__ int set_bit(int nr,int * addr)
extern __inline__ int set_bit(int nr,int * addr)
{
{
        int     mask, retval;
        int     mask, retval;
 
 
        addr += nr >> 5;
        addr += nr >> 5;
        mask = 1 << (nr & 0x1f);
        mask = 1 << (nr & 0x1f);
        cli();
        cli();
        retval = (mask & *addr) != 0;
        retval = (mask & *addr) != 0;
        *addr |= mask;
        *addr |= mask;
        sti();
        sti();
        return retval;
        return retval;
}
}
 
 
extern __inline__ int clear_bit(int nr, int * addr)
extern __inline__ int clear_bit(int nr, int * addr)
{
{
        int     mask, retval;
        int     mask, retval;
 
 
        addr += nr >> 5;
        addr += nr >> 5;
        mask = 1 << (nr & 0x1f);
        mask = 1 << (nr & 0x1f);
        cli();
        cli();
        retval = (mask & *addr) != 0;
        retval = (mask & *addr) != 0;
        *addr &= ~mask;
        *addr &= ~mask;
        sti();
        sti();
        return retval;
        return retval;
}
}
 
 
extern __inline__ int test_bit(int nr, int * addr)
extern __inline__ int test_bit(int nr, int * addr)
{
{
        int     mask;
        int     mask;
 
 
        addr += nr >> 5;
        addr += nr >> 5;
        mask = 1 << (nr & 0x1f);
        mask = 1 << (nr & 0x1f);
        return ((mask & *addr) != 0);
        return ((mask & *addr) != 0);
}
}
#endif /* _ASM_GENERIC_BITOPS_H */
#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.