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>
21 #ifndef _EXT2_HAVE_ASM_BITOPS_
24 * For the benefit of those who are trying to port Linux to another
25 * architecture, here are some C-language equivalents. You should
26 * recode these in the native assmebly language, if at all possible.
28 * C language equivalents written by Theodore Ts'o, 9/26/92.
29 * Modified by Pete A. Zaitcev 7/14/95 to be portable to big endian
30 * systems, as well as non-32 bit systems.
33 int ext2fs_set_bit(unsigned int nr,void * addr)
36 unsigned char *ADDR = (unsigned char *) addr;
39 mask = 1 << (nr & 0x07);
40 retval = mask & *ADDR;
45 int ext2fs_clear_bit(unsigned int nr, void * addr)
48 unsigned char *ADDR = (unsigned char *) addr;
51 mask = 1 << (nr & 0x07);
52 retval = mask & *ADDR;
57 int ext2fs_test_bit(unsigned int nr, const void * addr)
60 const unsigned char *ADDR = (const unsigned char *) addr;
63 mask = 1 << (nr & 0x07);
64 return (mask & *ADDR);
67 #endif /* !_EXT2_HAVE_ASM_BITOPS_ */
69 void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
70 const char *description)
74 com_err(0, errcode, "#%lu for %s", arg, description);
76 com_err(0, errcode, "#%lu", arg);
80 void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
81 int code, unsigned long arg)
84 if (bitmap->description)
85 com_err(0, bitmap->base_error_code+code,
86 "#%lu for %s", arg, bitmap->description);
88 com_err(0, bitmap->base_error_code + code, "#%lu", arg);