From f23e05578a84eac60a64b1ccfde4df661b40f1ad Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 15 Sep 2009 20:51:30 +0200 Subject: [PATCH] libblkid: move filter macros to header file * move blkid_bmp_* macros to blkidP.h * add blkid_bmp_nbytes() -- returns size of bitmap in bytes * add blkid_bmp_nwords() -- returns size of bitmap in words (rename from blkid_bmp_size()) Signed-off-by: Karel Zak --- shlibs/blkid/src/blkidP.h | 21 +++++++++++++++++++++ shlibs/blkid/src/probe.c | 20 +------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/shlibs/blkid/src/blkidP.h b/shlibs/blkid/src/blkidP.h index 4ad76bd1..9c6578cf 100644 --- a/shlibs/blkid/src/blkidP.h +++ b/shlibs/blkid/src/blkidP.h @@ -340,6 +340,27 @@ extern int blkid_probe_set_uuid_as(blkid_probe pr, unsigned char *uuid, const ch extern void blkid_unparse_uuid(const unsigned char *uuid, char *str, size_t len); +/* filter bitmap macros */ +#define blkid_bmp_wordsize (8 * sizeof(unsigned long)) +#define blkid_bmp_idx_bit(item) (1UL << ((item) % blkid_bmp_wordsize)) +#define blkid_bmp_idx_byte(item) ((item) / blkid_bmp_wordsize) + +#define blkid_bmp_set_item(bmp, item) \ + ((bmp)[ blkid_bmp_idx_byte(item) ] |= blkid_bmp_idx_bit(item)) + +#define blkid_bmp_unset_item(bmp, item) \ + ((bmp)[ bmp_idx_byte(item) ] &= ~bmp_idx_bit(item)) + +#define blkid_bmp_get_item(bmp, item) \ + ((bmp)[ blkid_bmp_idx_byte(item) ] & blkid_bmp_idx_bit(item)) + +#define blkid_bmp_nwords(max_items) \ + (((max_items) + blkid_bmp_wordsize) / blkid_bmp_wordsize) + +#define blkid_bmp_nbytes(max_items) \ + (blkid_bmp_nwords(max_items) * sizeof(unsigned long)) + +/* encode.c */ extern size_t blkid_encode_to_utf8(int enc, unsigned char *dest, size_t len, const unsigned char *src, size_t count); diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c index b9d67add..a578366b 100644 --- a/shlibs/blkid/src/probe.c +++ b/shlibs/blkid/src/probe.c @@ -100,26 +100,8 @@ static const struct blkid_idinfo *idinfos[] = # define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #endif -/* filter bitmap macros */ -#define blkid_bmp_wordsize (8 * sizeof(unsigned long)) -#define blkid_bmp_idx_bit(item) (1UL << ((item) % blkid_bmp_wordsize)) -#define blkid_bmp_idx_byte(item) ((item) / blkid_bmp_wordsize) - -#define blkid_bmp_set_item(bmp, item) \ - ((bmp)[ blkid_bmp_idx_byte(item) ] |= blkid_bmp_idx_bit(item)) - -#define blkid_bmp_unset_item(bmp, item) \ - ((bmp)[ bmp_idx_byte(item) ] &= ~bmp_idx_bit(item)) - -#define blkid_bmp_get_item(bmp, item) \ - ((bmp)[ blkid_bmp_idx_byte(item) ] & blkid_bmp_idx_bit(item)) - -#define blkid_bmp_size(max_items) \ - (((max_items) + blkid_bmp_wordsize) / blkid_bmp_wordsize) - #define BLKID_FLTR_ITEMS ARRAY_SIZE(idinfos) -#define BLKID_FLTR_SIZE blkid_bmp_size(BLKID_FLTR_ITEMS) - +#define BLKID_FLTR_SIZE blkid_bmp_nwords(BLKID_FLTR_ITEMS) static int blkid_probe_set_usage(blkid_probe pr, int usage); -- 2.39.5