static inline
void *mt_mk_node(const struct maple_node *node, enum maple_type type)
{
- return (void *)((unsigned long)node | (type << 3));
+ return (void *)((unsigned long)node | (type << 3) | 4);
}
-static inline struct maple_node *mt_safe_root(const void *entry)
+static inline
+void *mt_mk_root(const struct maple_node *node)
+{
+ return (void *)((unsigned long)node | 2);
+}
+static inline
+void *mt_safe_root(const struct maple_node *node)
+{
+ return (void *)((unsigned long)node & ~2);
+}
+static inline
+void *mt_is_full(const struct maple_node *node)
{
- return (struct maple_node *)((unsigned long)entry & ~2);
+ return (void *)((unsigned long)node & ~4);
}
static inline
-void *mt_mk_root(const struct maple_node *node)
+void mt_set_full(const struct maple_node *node)
{
- return (void *)((unsigned long)node | 2);
+ node = (void *)((unsigned long)node | 4);
}
static inline bool mas_is_err(struct ma_state *mas)
static inline unsigned int mt_parent_shift(unsigned long parent)
{
- if (parent & 1)
- return 0; // Root.
if (!(parent & 2))
return 2; // maple_range_16
return 3;
unsigned long val = (unsigned long) mt_to_node(node)->parent;
unsigned long slot_shift = mt_parent_shift(val);
- if (!slot_shift)
- return 0;
+ if (val & 1)
+ return 0; // Root.
return (val & bitmask) >> slot_shift;
}
unsigned long parent = (unsigned long) mt_to_node(node)->parent;
unsigned long slot_shift = mt_parent_shift(parent);
- parent &= (1 << (slot_shift + 1)) - 1;
+ parent &= (1 << slot_shift ) - 1;
switch (parent) {
case 6:
return maple_range_64;
} else {
entry = mt_safe_root(entry);
}
+
} else {
entry = mas->node;
}
enum maple_type ptype; // parent type.
unsigned long pivot;
- if (ma_is_root(full)) {
+ if (ma_is_root(mas->node)) {
old_parent = full;
ptype = maple_range_64;
p_slot = 0;
if (mas->index && min != mas->index - 1)
n_end++;
- if (n_end > MAPLE_RANGE64_SLOTS -1) {
+ if (n_end > MAPLE_RANGE64_SLOTS - 1) {
unsigned char split = ma_split(mas, slot, o_end);
if (mas_is_err(mas))
return 0;