Whamcloud - gitweb
b=15599 hsm infrastructure
[fs/lustre-release.git] / libcfs / include / libcfs / bitmap.h
index 58fd9a3..694a477 100644 (file)
@@ -16,8 +16,8 @@
  * in the LICENSE file that accompanied this code).
  *
  * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see [sun.com URL with a
- * copy of GPLv2].
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  * CA 95054 USA or visit www.sun.com if you need additional information or
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
 typedef struct {
         int             size;
         unsigned long   data[0];
-} bitmap_t;
+} cfs_bitmap_t;
 
 #define CFS_BITMAP_SIZE(nbits) \
-     (((nbits/BITS_PER_LONG)+1)*sizeof(long)+sizeof(bitmap_t))
+     (((nbits/BITS_PER_LONG)+1)*sizeof(long)+sizeof(cfs_bitmap_t))
 
 static inline
-bitmap_t *ALLOCATE_BITMAP(int size)
+cfs_bitmap_t *CFS_ALLOCATE_BITMAP(int size)
 {
-        bitmap_t *ptr;
+        cfs_bitmap_t *ptr;
 
         OBD_ALLOC(ptr, CFS_BITMAP_SIZE(size));
         if (ptr == NULL)
@@ -59,36 +59,42 @@ bitmap_t *ALLOCATE_BITMAP(int size)
         RETURN (ptr);
 }
 
-#define FREE_BITMAP(ptr)        OBD_FREE(ptr, CFS_BITMAP_SIZE(ptr->size))
+#define CFS_FREE_BITMAP(ptr)        OBD_FREE(ptr, CFS_BITMAP_SIZE(ptr->size))
 
 static inline
-void cfs_bitmap_set(bitmap_t *bitmap, int nbit)
+void cfs_bitmap_set(cfs_bitmap_t *bitmap, int nbit)
 {
-       set_bit(nbit, bitmap->data);
+        cfs_set_bit(nbit, bitmap->data);
 }
 
 static inline
-void cfs_bitmap_clear(bitmap_t *bitmap, int nbit)
+void cfs_bitmap_clear(cfs_bitmap_t *bitmap, int nbit)
 {
-        clear_bit(nbit, bitmap->data);
+        cfs_test_and_clear_bit(nbit, bitmap->data);
 }
 
 static inline
-int cfs_bitmap_check(bitmap_t *bitmap, int nbit)
+int cfs_bitmap_check(cfs_bitmap_t *bitmap, int nbit)
 {
-       return test_bit(nbit, bitmap->data);
+        return cfs_test_bit(nbit, bitmap->data);
+}
+
+static inline
+int cfs_bitmap_test_and_clear(cfs_bitmap_t *bitmap, int nbit)
+{
+        return cfs_test_and_clear_bit(nbit, bitmap->data);
 }
 
 /* return 0 is bitmap has none set bits */
 static inline
-int cfs_bitmap_check_empty(bitmap_t *bitmap)
+int cfs_bitmap_check_empty(cfs_bitmap_t *bitmap)
 {
-        return find_first_bit(bitmap->data, bitmap->size) == bitmap->size;
+        return cfs_find_first_bit(bitmap->data, bitmap->size) == bitmap->size;
 }
 
 #define cfs_foreach_bit(bitmap, pos) \
-       for((pos)=find_first_bit((bitmap)->data, bitmap->size);   \
+       for((pos)=cfs_find_first_bit((bitmap)->data, bitmap->size);   \
             (pos) < (bitmap)->size;                               \
-            (pos) = find_next_bit((bitmap)->data, (bitmap)->size, (pos)))
+            (pos) = cfs_find_next_bit((bitmap)->data, (bitmap)->size, (pos)))
 
 #endif