-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* 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.
+ *
+ * Copyright (c) 2012, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
static inline
void cfs_bitmap_set(cfs_bitmap_t *bitmap, int nbit)
{
- cfs_set_bit(nbit, bitmap->data);
+ set_bit(nbit, bitmap->data);
}
static inline
void cfs_bitmap_clear(cfs_bitmap_t *bitmap, int nbit)
{
- cfs_test_and_clear_bit(nbit, bitmap->data);
+ test_and_clear_bit(nbit, bitmap->data);
}
static inline
int cfs_bitmap_check(cfs_bitmap_t *bitmap, int nbit)
{
- return cfs_test_bit(nbit, bitmap->data);
+ return 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 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)
{
- return cfs_find_first_bit(bitmap->data, bitmap->size) == bitmap->size;
+ return find_first_bit(bitmap->data, bitmap->size) == bitmap->size;
+}
+
+static inline
+void cfs_bitmap_copy(cfs_bitmap_t *new, cfs_bitmap_t *old)
+{
+ int newsize;
+
+ LASSERT(new->size >= old->size);
+ newsize = new->size;
+ memcpy(new, old, CFS_BITMAP_SIZE(old->size));
+ new->size = newsize;
}
-#define cfs_foreach_bit(bitmap, pos) \
- for((pos)=cfs_find_first_bit((bitmap)->data, bitmap->size); \
- (pos) < (bitmap)->size; \
- (pos) = cfs_find_next_bit((bitmap)->data, (bitmap)->size, (pos)))
+#define cfs_foreach_bit(bitmap, pos) \
+ for ((pos) = find_first_bit((bitmap)->data, bitmap->size); \
+ (pos) < (bitmap)->size; \
+ (pos) = find_next_bit((bitmap)->data, (bitmap)->size, (pos) + 1))
#endif