Whamcloud - gitweb
LU-8560 libcfs: handle PAGE_CACHE_* removal in newer kernels
[fs/lustre-release.git] / libcfs / include / libcfs / bitmap.h
index d37610b..639f4c9 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #ifndef _LIBCFS_BITMAP_H_
 #define _LIBCFS_BITMAP_H_
 
-#ifndef __KERNEL__
-#define DIV_ROUND_UP(n, d)     (((n) + (d) - 1) / (d))
-#define BITS_TO_LONGS(nr)      DIV_ROUND_UP(nr, 8 * sizeof(long))
-
-#define DECLARE_BITMAP(name, bits) \
-       unsigned long name[BITS_TO_LONGS(bits)]
-#endif /* !__KERNEL__ */
-
-typedef struct {
-       unsigned int  size;
+struct cfs_bitmap {
+       unsigned int size;
        unsigned long data[0];
-} cfs_bitmap_t;
+};
 
 #define CFS_BITMAP_SIZE(nbits) \
-     (((nbits/BITS_PER_LONG)+1)*sizeof(long)+sizeof(cfs_bitmap_t))
+       (((nbits / BITS_PER_LONG) + 1) * sizeof(long) + \
+       sizeof(struct cfs_bitmap))
 
 static inline
-cfs_bitmap_t *CFS_ALLOCATE_BITMAP(int size)
+struct cfs_bitmap *CFS_ALLOCATE_BITMAP(int size)
 {
-       cfs_bitmap_t *ptr;
+       struct cfs_bitmap *ptr;
 
        LIBCFS_ALLOC(ptr, CFS_BITMAP_SIZE(size));
        if (ptr == NULL)
@@ -66,7 +59,7 @@ cfs_bitmap_t *CFS_ALLOCATE_BITMAP(int size)
        RETURN(ptr);
 }
 
-static inline void CFS_RESET_BITMAP(cfs_bitmap_t *bitmap)
+static inline void CFS_RESET_BITMAP(struct cfs_bitmap *bitmap)
 {
        if (bitmap->size > 0) {
                int nbits = bitmap->size;
@@ -79,38 +72,38 @@ static inline void CFS_RESET_BITMAP(cfs_bitmap_t *bitmap)
 #define CFS_FREE_BITMAP(ptr)   LIBCFS_FREE(ptr, CFS_BITMAP_SIZE(ptr->size))
 
 static inline
-void cfs_bitmap_set(cfs_bitmap_t *bitmap, int nbit)
+void cfs_bitmap_set(struct cfs_bitmap *bitmap, int nbit)
 {
        set_bit(nbit, bitmap->data);
 }
 
 static inline
-void cfs_bitmap_clear(cfs_bitmap_t *bitmap, int nbit)
+void cfs_bitmap_clear(struct cfs_bitmap *bitmap, int nbit)
 {
        test_and_clear_bit(nbit, bitmap->data);
 }
 
 static inline
-int cfs_bitmap_check(cfs_bitmap_t *bitmap, int nbit)
+int cfs_bitmap_check(struct cfs_bitmap *bitmap, int nbit)
 {
        return test_bit(nbit, bitmap->data);
 }
 
 static inline
-int cfs_bitmap_test_and_clear(cfs_bitmap_t *bitmap, int nbit)
+int cfs_bitmap_test_and_clear(struct cfs_bitmap *bitmap, int nbit)
 {
        return test_and_clear_bit(nbit, bitmap->data);
 }
 
 /* return 0 is bitmap has none set bits */
 static inline
-int cfs_bitmap_check_empty(cfs_bitmap_t *bitmap)
+int cfs_bitmap_check_empty(struct cfs_bitmap *bitmap)
 {
        return find_first_bit(bitmap->data, bitmap->size) == bitmap->size;
 }
 
 static inline
-void cfs_bitmap_copy(cfs_bitmap_t *new, cfs_bitmap_t *old)
+void cfs_bitmap_copy(struct cfs_bitmap *new, struct cfs_bitmap *old)
 {
        size_t newsize;