Changes to update Tomato RAF.
[tomato.git] / release / src / router / busybox / e2fsprogs / old_e2fsprogs / ext2fs / bitops.c
blobb4ec51ed7cc223b4716ebcd806c3ee7b2346888d
1 /* vi: set sw=4 ts=4: */
2 /*
3 * bitops.c --- Bitmap frobbing code. See bitops.h for the inlined
4 * routines.
6 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
8 * %Begin-Header%
9 * This file may be redistributed under the terms of the GNU Public
10 * License.
11 * %End-Header%
14 #include <stdio.h>
15 #if HAVE_SYS_TYPES_H
16 #include <sys/types.h>
17 #endif
19 #include "ext2_fs.h"
20 #include "ext2fs.h"
22 #ifndef _EXT2_HAVE_ASM_BITOPS_
25 * For the benefit of those who are trying to port Linux to another
26 * architecture, here are some C-language equivalents. You should
27 * recode these in the native assmebly language, if at all possible.
29 * C language equivalents written by Theodore Ts'o, 9/26/92.
30 * Modified by Pete A. Zaitcev 7/14/95 to be portable to big endian
31 * systems, as well as non-32 bit systems.
34 int ext2fs_set_bit(unsigned int nr,void * addr)
36 int mask, retval;
37 unsigned char *ADDR = (unsigned char *) addr;
39 ADDR += nr >> 3;
40 mask = 1 << (nr & 0x07);
41 retval = mask & *ADDR;
42 *ADDR |= mask;
43 return retval;
46 int ext2fs_clear_bit(unsigned int nr, void * addr)
48 int mask, retval;
49 unsigned char *ADDR = (unsigned char *) addr;
51 ADDR += nr >> 3;
52 mask = 1 << (nr & 0x07);
53 retval = mask & *ADDR;
54 *ADDR &= ~mask;
55 return retval;
58 int ext2fs_test_bit(unsigned int nr, const void * addr)
60 int mask;
61 const unsigned char *ADDR = (const unsigned char *) addr;
63 ADDR += nr >> 3;
64 mask = 1 << (nr & 0x07);
65 return (mask & *ADDR);
68 #endif /* !_EXT2_HAVE_ASM_BITOPS_ */
70 void ext2fs_warn_bitmap(errcode_t errcode EXT2FS_ATTR((unused)),
71 unsigned long arg,
72 const char *description)
74 #ifndef OMIT_COM_ERR
75 if (description)
76 bb_error_msg("#%lu for %s", arg, description);
77 else
78 bb_error_msg("#%lu", arg);
79 #endif
82 void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
83 int code EXT2FS_ATTR((unused)), unsigned long arg)
85 #ifndef OMIT_COM_ERR
86 if (bitmap->description)
87 bb_error_msg("#%lu for %s", arg, bitmap->description);
88 else
89 bb_error_msg("#%lu", arg);
90 #endif