diff --git a/utils/src/bitops.c b/utils/src/bitops.c deleted file mode 100644 index 148051f4..00000000 --- a/utils/src/bitops.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include - -#include "sparse.h" -#include "util.h" -#include "bitops.h" - -#if (__SIZEOF_LONG__ == 8) -typedef __le64 lelong; -#define lelong_to_cpu le64_to_cpu - -#elif (__SIZEOF_LONG__ == 4) -typedef __le32 lelong; -#define lelong_to_cpu le32_to_cpu - -#else -#error "no sizeof long define?" -#endif - -/* - * I'd have used ffsl(), but defining _GNU_SOURCE caused build errors - * in glibc. The gcc builtin has the added bonus of returning 0 for the - * least significant bit instead of 1. - */ -#define ctzl __builtin_ctzl - -int find_next_bit_le(void *addr, long size, int start) -{ - lelong * __packed longs = addr; - unsigned long off = 0; - unsigned long masked; - - /* skip past whole longs before start */ - if (start >= BITS_PER_LONG) { - longs += start / BITS_PER_LONG; - off = start & ~(BITS_PER_LONG - 1); - start -= off; - } - - /* mask off low bits if start isn't aligned */ - if (start) { - masked = lelong_to_cpu(*longs) & ~((1 << (start)) - 1); - if (masked) - return min(ctzl(masked), size); - - off += BITS_PER_LONG; - longs++; - } - - /* then search remaining longs */ - while (off < size) { - if (*longs) - return min(off + ctzl(lelong_to_cpu(*longs)), size); - longs++; - off += BITS_PER_LONG; - } - - return size; -} diff --git a/utils/src/bitops.h b/utils/src/bitops.h deleted file mode 100644 index 7f2add29..00000000 --- a/utils/src/bitops.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef _BITOPS_H_ -#define _BITOPS_H_ - -/* - * Implement little endian bitmaps in terms of native longs. __packed - * is used to avoid unaligned accesses. - */ - -typedef unsigned long * __packed ulong_ptr; - -#define BITS_PER_LONG (sizeof(long) * 8) -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define BITOP_LE_SWIZZLE 0 -#else -#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) -#endif - -static inline ulong_ptr nr_word(int nr, ulong_ptr longs) -{ - return &longs[nr / BITS_PER_LONG]; -} - -static inline unsigned long nr_mask(int nr) -{ - return 1UL << (nr % BITS_PER_LONG); -} - -static inline int test_bit(int nr, ulong_ptr longs) -{ - return !!(*nr_word(nr, longs) & nr_mask(nr)); -} - -static inline void set_bit(int nr, ulong_ptr longs) -{ - *nr_word(nr, longs) |= nr_mask(nr); -} - -static inline void clear_bit(int nr, ulong_ptr longs) -{ - *nr_word(nr, longs) &= ~nr_mask(nr); -} - -static inline int test_bit_le(int nr, void *addr) -{ - return test_bit(nr ^ BITOP_LE_SWIZZLE, addr); -} - -static inline int test_and_set_bit_le(int nr, void *addr) -{ - int ret; - - nr ^= BITOP_LE_SWIZZLE; - ret = test_bit(nr, addr); - set_bit(nr, addr); - return ret; -} - -static inline void set_bit_le(int nr, void *addr) -{ - set_bit(nr ^ BITOP_LE_SWIZZLE, addr); -} - -static inline void clear_bit_le(int nr, void *addr) -{ - clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); -} - -static inline int test_and_clear_bit_le(int nr, void *addr) -{ - int ret; - - nr ^= BITOP_LE_SWIZZLE; - ret = test_bit(nr, addr); - clear_bit(nr, addr); - return ret; -} - -int find_next_bit_le(void *addr, long size, int start); - -#endif diff --git a/utils/src/mkfs.c b/utils/src/mkfs.c index 555e193c..e3dd1675 100644 --- a/utils/src/mkfs.c +++ b/utils/src/mkfs.c @@ -17,7 +17,6 @@ #include "crc.h" #include "rand.h" #include "dev.h" -#include "bitops.h" #include "buddy.h" #include "item.h"