2 * bitops.c --- Bitmap frobbing code. See bitops.h for the inlined
5 * Copyright (C) 1993, 1994 Theodore Ts'o. This file may be
6 * redistributed under the terms of the GNU Public License.
8 * Taken from <asm/bitops.h>, Copyright 1992, Linus Torvalds.
12 #include <sys/types.h>
14 #include <linux/ext2_fs.h>
18 #ifndef _EXT2_HAVE_ASM_BITOPS_
21 * For the benefit of those who are trying to port Linux to another
22 * architecture, here are some C-language equivalents. You should
23 * recode these in the native assmebly language, if at all possible.
25 * C language equivalents written by Theodore Ts'o, 9/26/92.
26 * Modified by Pete A. Zaitcev 7/14/95 to be portable to big endian
27 * systems, as well as non-32 bit systems.
30 int set_bit(int nr,void * addr)
33 unsigned char *ADDR = (unsigned char *) addr;
36 mask = 1 << (nr & 0x07);
37 retval = (mask & *ADDR) != 0;
42 int clear_bit(int nr, void * addr)
45 unsigned char *ADDR = (unsigned char *) addr;
48 mask = 1 << (nr & 0x07);
49 retval = (mask & *ADDR) != 0;
54 int test_bit(int nr, const void * addr)
57 const unsigned char *ADDR = (const unsigned char *) addr;
60 mask = 1 << (nr & 0x07);
61 return ((mask & *ADDR) != 0);
64 #endif /* !_EXT2_HAVE_ASM_BITOPS_ */
66 void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
67 const char *description)
70 com_err(0, errcode, "#%u for %s", arg, description);
72 com_err(0, errcode, "#%u", arg);