-/* -*- 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/
#define __LIBCFS_USER_BITOPS_H__
/* test if bit nr is set in bitmap addr; returns previous value of bit nr */
-static __inline__ int cfs_test_and_set_bit(int nr, unsigned long *addr)
+static inline int test_and_set_bit(int nr, unsigned long *addr)
{
unsigned long mask;
return nr;
}
-#define cfs_set_bit(n, a) cfs_test_and_set_bit(n, a)
+#define set_bit(n, a) test_and_set_bit(n, a)
/* clear bit nr in bitmap addr; returns previous value of bit nr*/
-static __inline__ int cfs_test_and_clear_bit(int nr, unsigned long *addr)
+static inline int test_and_clear_bit(int nr, unsigned long *addr)
{
unsigned long mask;
return nr;
}
-#define cfs_clear_bit(n, a) cfs_test_and_clear_bit(n, a)
+#define clear_bit(n, a) test_and_clear_bit(n, a)
-static __inline__ int cfs_test_bit(int nr, const unsigned long *addr)
+static inline int test_bit(int nr, const unsigned long *addr)
{
return ((1UL << (nr & (BITS_PER_LONG - 1))) &
((addr)[nr / BITS_PER_LONG])) != 0;
}
/* using binary seach */
-static __inline__ unsigned long __cfs_fls(long data)
+static __inline__ unsigned long fls(long data)
{
int pos = 32;
return 0;
#if BITS_PER_LONG == 64
- pos += 32;
-
- if ((data & 0xFFFFFFFF) == 0) {
- data <<= 32;
- pos -= 32;
+ /* If any bit of the high 32 bits are set, shift the high
+ * 32 bits down and pretend like it is a 32-bit value. */
+ if ((data & 0xFFFFFFFF00000000llu)) {
+ data >>= 32;
+ pos += 32;
}
#endif
return pos;
}
-#define __cfs_ffz(x) __cfs_ffs(~(x))
-#define __cfs_flz(x) __cfs_fls(~(x))
+#define ffz(x) ffs(~(x))
+#define flz(x) fls(~(x))
-unsigned long cfs_find_next_bit(unsigned long *addr,
- unsigned long size, unsigned long offset);
+unsigned long find_next_bit(unsigned long *addr,
+ unsigned long size, unsigned long offset);
-unsigned long cfs_find_next_zero_bit(unsigned long *addr,
- unsigned long size, unsigned long offset);
+unsigned long find_next_zero_bit(unsigned long *addr,
+ unsigned long size, unsigned long offset);
-#define cfs_find_first_bit(addr,size) (cfs_find_next_bit((addr),(size),0))
-#define cfs_find_first_zero_bit(addr,size) \
- (cfs_find_next_zero_bit((addr),(size),0))
+#define find_first_bit(addr, size) find_next_bit((addr), (size),0)
+#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size),0)
#endif