mirror of
https://github.com/alsa-project/alsa-tools.git
synced 2025-11-03 09:01:51 -05:00
51 lines
1.2 KiB
C
51 lines
1.2 KiB
C
|
|
#ifndef _PZ_GENERIC_BITOPS_H_
|
||
|
|
#define _PZ_GENERIC_BITOPS_H_
|
||
|
|
/* this is from linux kernel header */
|
||
|
|
/*
|
||
|
|
* For the benefit of those who are trying to port Linux to another
|
||
|
|
* architecture, here are some C-language equivalents. You should
|
||
|
|
* recode these in the native assembly language, if at all possible.
|
||
|
|
* To guarantee atomicity, these routines call cli() and sti() to
|
||
|
|
* disable interrupts while they operate. (You have to provide inline
|
||
|
|
* routines to cli() and sti().)
|
||
|
|
*
|
||
|
|
* Also note, these routines assume that you have 32 bit longs.
|
||
|
|
* You will have to change this if you are trying to port Linux to the
|
||
|
|
* Alpha architecture or to a Cray. :-)
|
||
|
|
*
|
||
|
|
* C language equivalents written by Theodore Ts'o, 9/26/92
|
||
|
|
*/
|
||
|
|
|
||
|
|
__inline__ int set_bit(int nr, unsigned long * addr)
|
||
|
|
{
|
||
|
|
int mask, retval;
|
||
|
|
|
||
|
|
addr += nr >> 5;
|
||
|
|
mask = 1 << (nr & 0x1f);
|
||
|
|
retval = (mask & *addr) != 0;
|
||
|
|
*addr |= mask;
|
||
|
|
return retval;
|
||
|
|
}
|
||
|
|
|
||
|
|
__inline__ int clear_bit(int nr, unsigned long * addr)
|
||
|
|
{
|
||
|
|
int mask, retval;
|
||
|
|
|
||
|
|
addr += nr >> 5;
|
||
|
|
mask = 1 << (nr & 0x1f);
|
||
|
|
retval = (mask & *addr) != 0;
|
||
|
|
*addr &= ~mask;
|
||
|
|
return retval;
|
||
|
|
}
|
||
|
|
|
||
|
|
__inline__ int test_bit(int nr, unsigned long * addr)
|
||
|
|
{
|
||
|
|
int mask;
|
||
|
|
|
||
|
|
addr += nr >> 5;
|
||
|
|
mask = 1 << (nr & 0x1f);
|
||
|
|
return ((mask & *addr) != 0);
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif /* _PZ_GENERIC_BITOPS_H */
|