/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#ifndef _LIBCFS_BITMAP_H_
#define _LIBCFS_BITMAP_H_
+#if !defined(__linux__) || !defined(__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
typedef struct {
int size;
static inline
cfs_bitmap_t *CFS_ALLOCATE_BITMAP(int size)
{
- cfs_bitmap_t *ptr;
+ cfs_bitmap_t *ptr;
- OBD_ALLOC(ptr, CFS_BITMAP_SIZE(size));
- if (ptr == NULL)
- RETURN(ptr);
+ LIBCFS_ALLOC(ptr, CFS_BITMAP_SIZE(size));
+ if (ptr == NULL)
+ RETURN(ptr);
- ptr->size = size;
+ ptr->size = size;
- RETURN (ptr);
+ RETURN(ptr);
}
-#define CFS_FREE_BITMAP(ptr) OBD_FREE(ptr, CFS_BITMAP_SIZE(ptr->size))
+#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)