return (mt->ma_flags & MAPLE_ALLOC_RANGE);
}
-
-static inline unsigned int mte_parent_shift(unsigned long parent)
-{
- if (!(parent & 2))
- return 2; // maple_range_16
- return 3;
-}
+#define MAPLE_PARENT_SHIFT 3
static inline enum maple_type mte_parent_range_enum(unsigned long parent)
{
struct maple_enode *node)
{
unsigned long parent = 6;
- unsigned long slot_shift;
- if (!mte_is_root(mas->node)) {
+ if (likely(!mte_is_root(mas->node))) {
parent = (unsigned long) mte_to_node(node)->parent;
- slot_shift = mte_parent_shift(parent);
- parent &= (1 << slot_shift) - 1;
+ parent &= (1 << MAPLE_PARENT_SHIFT) - 1;
}
if (mt_is_alloc(mas->tree))
* Type is encoded in the enode->parent
* bit 0: 1 = root, 0 otherwise
* bit 1: Reserved.
- * bit 2: 0 = range 32, 1 = [a]range 64 | lowest bit of range_16's slot.
+ * bit 2: 0 = range 32, 1 = [a]range 64
*
* Slot number is encoded in the enode->parent
* range_32, slot number is encoded in bits 3-6
unsigned char slot)
{
unsigned long bitmask = 0x78;
- unsigned long slot_shift = 3;
unsigned long val = (unsigned long) parent;
unsigned long type = 0;
switch (mte_node_type(parent)) {
case maple_range_64:
case maple_arange_64:
- type |= 4;
- type |= 2;
+ type = 6;
break;
default:
break;
}
val &= ~bitmask; // Remove any old slot number.
- val |= (slot << slot_shift); // Set the slot.
+ val |= (slot << MAPLE_PARENT_SHIFT); // Set the slot.
val |= type;
mte_to_node(enode)->parent = ma_parent_ptr(val);
}
{
unsigned long bitmask = 0x7C;
unsigned long val = (unsigned long) mte_to_node(enode)->parent;
- unsigned long slot_shift = mte_parent_shift(val);
if (val & 1)
return 0; // Root.
- return (val & bitmask) >> slot_shift;
+ return (val & bitmask) >> MAPLE_PARENT_SHIFT;
}
/*