2 * bitops.c --- Bitmap frobbing code. See bitops.h for the inlined
5 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
8 * This file may be redistributed under the terms of the GNU Public
15 #include <sys/types.h>
18 #if EXT2_FLAT_INCLUDES
21 #include <linux/ext2_fs.h>
26 #ifndef _EXT2_HAVE_ASM_BITOPS_
29 * For the benefit of those who are trying to port Linux to another
30 * architecture, here are some C-language equivalents. You should
31 * recode these in the native assmebly language, if at all possible.
33 * C language equivalents written by Theodore Ts'o, 9/26/92.
34 * Modified by Pete A. Zaitcev 7/14/95 to be portable to big endian
35 * systems, as well as non-32 bit systems.
38 int ext2fs_set_bit(int nr,void * addr)
41 unsigned char *ADDR = (unsigned char *) addr;
44 mask = 1 << (nr & 0x07);
45 retval = (mask & *ADDR) != 0;
50 int ext2fs_clear_bit(int nr, void * addr)
53 unsigned char *ADDR = (unsigned char *) addr;
56 mask = 1 << (nr & 0x07);
57 retval = (mask & *ADDR) != 0;
62 int ext2fs_test_bit(int nr, const void * addr)
65 const unsigned char *ADDR = (const unsigned char *) addr;
68 mask = 1 << (nr & 0x07);
69 return ((mask & *ADDR) != 0);
72 #endif /* !_EXT2_HAVE_ASM_BITOPS_ */
74 void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
75 const char *description)
79 com_err(0, errcode, "#%u for %s", arg, description);
81 com_err(0, errcode, "#%u", arg);
85 void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
86 int code, unsigned long arg)
89 if (bitmap->description)
90 com_err(0, bitmap->base_error_code+code,
91 "#%u for %s", arg, bitmap->description);
93 com_err(0, bitmap->base_error_code + code, "#%u", arg);