From: Ales Kozumplik Date: Fri, 20 Jan 2012 09:51:05 +0000 (+0100) Subject: bitmap: implement map_and and MAPSETALL X-Git-Tag: BASE-SuSE-Code-12_2-Branch~112^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9%2Fhead;p=thirdparty%2Flibsolv.git bitmap: implement map_and and MAPSETALL --- diff --git a/src/bitmap.c b/src/bitmap.c index d57971d0..94a88ca0 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -59,4 +59,16 @@ map_grow(Map *m, int n) } } +/* bitwise-ands same-sized maps t and s, stores the result in t. */ +void +map_and(Map *t, Map *s) +{ + unsigned char *ti, *si, *end; + ti = t->map; + si = s->map; + end = ti + t->size; + while (ti < end) + *ti++ &= *si++; +} + /* EOF */ diff --git a/src/bitmap.h b/src/bitmap.h index b931d7eb..3bad3c39 100644 --- a/src/bitmap.h +++ b/src/bitmap.h @@ -21,6 +21,8 @@ typedef struct _Map { } Map; #define MAPZERO(m) (memset((m)->map, 0, (m)->size)) +/* set all bits */ +#define MAPSETALL(m) (memset((m)->map, 0xff, (m)->size)) /* set bit */ #define MAPSET(m, n) ((m)->map[(n) >> 3] |= 1 << ((n) & 7)) /* clear bit */ @@ -32,6 +34,7 @@ extern void map_init(Map *m, int n); extern void map_init_clone(Map *t, Map *s); extern void map_grow(Map *m, int n); extern void map_free(Map *m); +extern void map_and(Map *t, Map *s); static inline void map_empty(Map *m) { diff --git a/src/libsolv.ver b/src/libsolv.ver index fcb95b32..5204e29c 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -26,6 +26,7 @@ SOLV_1.0 { dirpool_free; dirpool_init; dirpool_make_dirtraverse; + map_and; map_free; map_grow; map_init;