aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include/linux/bitops.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat/linuxkpi/common/include/linux/bitops.h')
-rw-r--r--sys/compat/linuxkpi/common/include/linux/bitops.h170
1 files changed, 2 insertions, 168 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/bitops.h b/sys/compat/linuxkpi/common/include/linux/bitops.h
index a0d5be646c0b..43e412c104b3 100644
--- a/sys/compat/linuxkpi/common/include/linux/bitops.h
+++ b/sys/compat/linuxkpi/common/include/linux/bitops.h
@@ -2,7 +2,7 @@
* Copyright (c) 2010 Isilon Systems, Inc.
* Copyright (c) 2010 iX Systems, Inc.
* Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -256,70 +256,6 @@ find_next_zero_bit(const unsigned long *addr, unsigned long size,
return (bit);
}
-static inline void
-bitmap_zero(unsigned long *addr, int size)
-{
- int len;
-
- len = BITS_TO_LONGS(size) * sizeof(long);
- memset(addr, 0, len);
-}
-
-static inline void
-bitmap_fill(unsigned long *addr, int size)
-{
- int tail;
- int len;
-
- len = (size / BITS_PER_LONG) * sizeof(long);
- memset(addr, 0xff, len);
- tail = size & (BITS_PER_LONG - 1);
- if (tail)
- addr[size / BITS_PER_LONG] = BITMAP_LAST_WORD_MASK(tail);
-}
-
-static inline int
-bitmap_full(unsigned long *addr, int size)
-{
- unsigned long mask;
- int tail;
- int len;
- int i;
-
- len = size / BITS_PER_LONG;
- for (i = 0; i < len; i++)
- if (addr[i] != ~0UL)
- return (0);
- tail = size & (BITS_PER_LONG - 1);
- if (tail) {
- mask = BITMAP_LAST_WORD_MASK(tail);
- if ((addr[i] & mask) != mask)
- return (0);
- }
- return (1);
-}
-
-static inline int
-bitmap_empty(unsigned long *addr, int size)
-{
- unsigned long mask;
- int tail;
- int len;
- int i;
-
- len = size / BITS_PER_LONG;
- for (i = 0; i < len; i++)
- if (addr[i] != 0)
- return (0);
- tail = size & (BITS_PER_LONG - 1);
- if (tail) {
- mask = BITMAP_LAST_WORD_MASK(tail);
- if ((addr[i] & mask) != 0)
- return (0);
- }
- return (1);
-}
-
#define __set_bit(i, a) \
atomic_set_long(&((volatile unsigned long *)(a))[BIT_WORD(i)], BIT_MASK(i))
@@ -396,48 +332,6 @@ __test_and_set_bit(long bit, volatile unsigned long *var)
return !!(val & bit);
}
-static inline void
-bitmap_set(unsigned long *map, int start, int nr)
-{
- unsigned long *p = map + BIT_WORD(start);
- const int size = start + nr;
- int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
- unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
-
- while (nr - bits_to_set >= 0) {
- *p |= mask_to_set;
- nr -= bits_to_set;
- bits_to_set = BITS_PER_LONG;
- mask_to_set = ~0UL;
- p++;
- }
- if (nr) {
- mask_to_set &= BITMAP_LAST_WORD_MASK(size);
- *p |= mask_to_set;
- }
-}
-
-static inline void
-bitmap_clear(unsigned long *map, int start, int nr)
-{
- unsigned long *p = map + BIT_WORD(start);
- const int size = start + nr;
- int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
- unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
-
- while (nr - bits_to_clear >= 0) {
- *p &= ~mask_to_clear;
- nr -= bits_to_clear;
- bits_to_clear = BITS_PER_LONG;
- mask_to_clear = ~0UL;
- p++;
- }
- if (nr) {
- mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
- *p &= ~mask_to_clear;
- }
-}
-
enum {
REG_OP_ISFREE,
REG_OP_ALLOC,
@@ -445,7 +339,7 @@ enum {
};
static inline int
-__reg_op(unsigned long *bitmap, int pos, int order, int reg_op)
+linux_reg_op(unsigned long *bitmap, int pos, int order, int reg_op)
{
int nbits_reg;
int index;
@@ -489,71 +383,11 @@ done:
return ret;
}
-static inline int
-bitmap_find_free_region(unsigned long *bitmap, int bits, int order)
-{
- int pos;
- int end;
-
- for (pos = 0 ; (end = pos + (1 << order)) <= bits; pos = end) {
- if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
- continue;
- __reg_op(bitmap, pos, order, REG_OP_ALLOC);
- return pos;
- }
- return -ENOMEM;
-}
-
-static inline int
-bitmap_allocate_region(unsigned long *bitmap, int pos, int order)
-{
- if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
- return -EBUSY;
- __reg_op(bitmap, pos, order, REG_OP_ALLOC);
- return 0;
-}
-
-static inline void
-bitmap_release_region(unsigned long *bitmap, int pos, int order)
-{
- __reg_op(bitmap, pos, order, REG_OP_RELEASE);
-}
-
#define for_each_set_bit(bit, addr, size) \
for ((bit) = find_first_bit((addr), (size)); \
(bit) < (size); \
(bit) = find_next_bit((addr), (size), (bit) + 1))
-static inline unsigned
-bitmap_weight(unsigned long *bitmap, unsigned nbits)
-{
- unsigned bit;
- unsigned retval = 0;
-
- for_each_set_bit(bit, bitmap, nbits)
- retval++;
- return (retval);
-}
-
-static inline int
-bitmap_equal(const unsigned long *pa,
- const unsigned long *pb, unsigned bits)
-{
- unsigned x;
- unsigned y = bits / BITS_PER_LONG;
-
- for (x = 0; x != y; x++) {
- if (pa[x] != pb[x])
- return (0);
- }
-
- y = bits % BITS_PER_LONG;
- if (y != 0) {
- if ((pa[x] ^ pb[x]) & BITMAP_LAST_WORD_MASK(y))
- return (0);
- }
- return (1);
-}
static inline uint64_t
sign_extend64(uint64_t value, int index)