small optimization for pool_addfileprovides
[platform/upstream/libsolv.git] / src / bitmap.h
index 5a73d24..5784e6c 100644 (file)
@@ -1,27 +1,70 @@
 /*
+ * Copyright (c) 2007-2011, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+/*
  * bitmap.h
- * 
+ *
  */
 
-#ifndef BITMAP_H
-#define BITMAP_H
+#ifndef LIBSOLV_BITMAP_H
+#define LIBSOLV_BITMAP_H
+
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 typedef struct _Map {
   unsigned char *map;
   int size;
 } Map;
 
-#if 0
-#define MAPINIT(m, n) ((m)->size = ((n) + 7) >> 3, (m)->map = calloc((m)->size, 1))
-#endif
-
 #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 */
 #define MAPCLR(m, n) ((m)->map[(n) >> 3] &= ~(1 << ((n) & 7)))
+/* test bit */
 #define MAPTST(m, n) ((m)->map[(n) >> 3] & (1 << ((n) & 7)))
 
-extern void mapinit(Map *m, int n);
-extern void mapfree(Map *m);
-extern void clonemap(Map *t, Map *s);
+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);
+extern void map_or(Map *t, Map *s);
+extern void map_subtract(Map *t, Map *s);
+
+static inline void map_empty(Map *m)
+{
+  MAPZERO(m);
+}
+static inline void map_set(Map *m, int n)
+{
+  MAPSET(m, n);
+}
+static inline void map_setall(Map *m)
+{
+  MAPSETALL(m);
+}
+static inline void map_clr(Map *m, int n)
+{
+  MAPCLR(m, n);
+}
+static inline int map_tst(Map *m, int n)
+{
+  return MAPTST(m, n);
+}
+
+#ifdef __cplusplus
+}
+#endif
 
-#endif /* BITMAP_H */
+#endif /* LIBSOLV_BITMAP_H */