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 #if (!defined(__i386__) && !defined(__i486__) && !defined(__i586__))
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.
24 * To guarantee atomicity, these routines call cli() and sti() to
25 * disable interrupts while they operate. (You have to provide inline
26 * routines to cli() and sti().)
28 * Also note, these routines assume that you have 32 bit integers.
29 * You will have to change this if you are trying to port Linux to the
30 * Alpha architecture or to a Cray. :-)
32 * C language equivalents written by Theodore Ts'o, 9/26/92
35 int set_bit(int nr,void * addr)
38 int *ADDR = (int *) addr;
41 mask = 1 << (nr & 0x1f);
43 retval = (mask & *ADDR) != 0;
49 int clear_bit(int nr, void * addr)
52 int *ADDR = (int *) addr;
55 mask = 1 << (nr & 0x1f);
57 retval = (mask & *ADDR) != 0;
63 int test_bit(int nr, const void * addr)
66 const int *ADDR = (const int *) addr;
69 mask = 1 << (nr & 0x1f);
70 return ((mask & *ADDR) != 0);
75 * These are routines print warning messages; they are called by
78 const char *ext2fs_block_string = "block";
79 const char *ext2fs_inode_string = "inode";
80 const char *ext2fs_mark_string = "mark";
81 const char *ext2fs_unmark_string = "unmark";
82 const char *ext2fs_test_string = "test";
84 void ext2fs_warn_bitmap(ext2_filsys fs, const char *op, const char *type,
89 sprintf(func, "ext2fs_%s_%s_bitmap", op, type);
90 com_err(func, 0, "INTERNAL ERROR: illegal %s #%d for %s",
91 type, arg, fs->device_name);