aboutsummaryrefslogtreecommitdiff
path: root/e2fslib/tst_bitops.c
diff options
context:
space:
mode:
Diffstat (limited to 'e2fslib/tst_bitops.c')
-rw-r--r--e2fslib/tst_bitops.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/e2fslib/tst_bitops.c b/e2fslib/tst_bitops.c
new file mode 100644
index 0000000..fb4d3ad
--- /dev/null
+++ b/e2fslib/tst_bitops.c
@@ -0,0 +1,44 @@
+/*
+ * This testing program makes sure the bitops functions work
+ *
+ * Copyright (C) 2001 by Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+/* #define _EXT2_USE_C_VERSIONS_ */
+
+#include <stdio.h>
+#include <string.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <fcntl.h>
+#include <time.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#include "ext2_fs.h"
+#include "ext2fs.h"
+
+unsigned char bitarray[] = {
+ 0x80, 0xF0, 0x40, 0x40, 0x0, 0x0, 0x0, 0x0, 0x10, 0x20, 0x00, 0x00
+ };
+
+main(int argc, char **argv)
+{
+ int i, size;
+
+ size = sizeof(bitarray)*8;
+ i = ext2fs_find_first_bit_set(bitarray, size);
+ while (i < size) {
+ printf("Bit set: %d\n", i);
+ i = ext2fs_find_next_bit_set(bitarray, size, i+1);
+ }
+}