aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ext2fs/bitops.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ext2fs/bitops.c')
-rw-r--r--lib/ext2fs/bitops.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c
index c037199e..0dc89677 100644
--- a/lib/ext2fs/bitops.c
+++ b/lib/ext2fs/bitops.c
@@ -21,54 +21,46 @@
* 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 assmebly 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 integers.
- * 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
+ * C language equivalents written by Theodore Ts'o, 9/26/92.
+ * Modified by Pete A. Zaitcev 7/14/95 to be portable to big endian
+ * systems, as well as non-32 bit systems.
*/
int set_bit(int nr,void * addr)
{
- int mask, retval;
- int *ADDR = (int *) addr;
+ int mask, retval;
+ unsigned char *ADDR = (unsigned char *) addr;
- ADDR += nr >> 5;
- mask = 1 << (nr & 0x1f);
- cli();
+ ADDR += nr >> 3;
+ mask = 1 << (nr & 0x07);
retval = (mask & *ADDR) != 0;
*ADDR |= mask;
- sti();
return retval;
}
int clear_bit(int nr, void * addr)
{
- int mask, retval;
- int *ADDR = (int *) addr;
+ int mask, retval;
+ unsigned char *ADDR = (unsigned char *) addr;
- ADDR += nr >> 5;
- mask = 1 << (nr & 0x1f);
- cli();
+ ADDR += nr >> 3;
+ mask = 1 << (nr & 0x07);
retval = (mask & *ADDR) != 0;
*ADDR &= ~mask;
- sti();
return retval;
}
int test_bit(int nr, const void * addr)
{
- int mask;
- const int *ADDR = (const int *) addr;
+ int mask;
+ const unsigned char *ADDR = (const unsigned char *) addr;
- ADDR += nr >> 5;
- mask = 1 << (nr & 0x1f);
+ ADDR += nr >> 3;
+ mask = 1 << (nr & 0x07);
return ((mask & *ADDR) != 0);
}
+
#endif /* !_EXT2_HAVE_ASM_BITOPS_ */
void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,