e2fsprogs/lib/ext2fs/tst_bitops.c

45 lines
850 B
C

/*
* 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);
}
}