Преглед на файлове

Fix crashes on windows with rbtree, unsigned long is always 32b there

Samuel Thibault преди 6 години
родител
ревизия
922106cdc5
променени са 3 файла, в които са добавени 11 реда и са изтрити 11 реда
  1. 2 2
      src/common/rbtree.c
  2. 3 3
      src/common/rbtree.h
  3. 6 6
      src/common/rbtree_i.h

+ 2 - 2
src/common/rbtree.c

@@ -82,7 +82,7 @@ static inline void starpu_rbtree_set_parent(struct starpu_rbtree_node *node,
     assert(starpu_rbtree_check_alignment(node));
     assert(starpu_rbtree_check_alignment(node));
     assert(starpu_rbtree_check_alignment(parent));
     assert(starpu_rbtree_check_alignment(parent));
 
 
-    node->parent = (unsigned long)parent | (node->parent & STARPU_RBTREE_COLOR_MASK);
+    node->parent = (uintptr_t)parent | (node->parent & STARPU_RBTREE_COLOR_MASK);
 }
 }
 
 
 /*
 /*
@@ -150,7 +150,7 @@ void starpu_rbtree_insert_rebalance(struct starpu_rbtree *tree, struct starpu_rb
     assert(starpu_rbtree_check_alignment(parent));
     assert(starpu_rbtree_check_alignment(parent));
     assert(starpu_rbtree_check_alignment(node));
     assert(starpu_rbtree_check_alignment(node));
 
 
-    node->parent = (unsigned long)parent | STARPU_RBTREE_COLOR_RED;
+    node->parent = (uintptr_t)parent | STARPU_RBTREE_COLOR_RED;
     node->children[STARPU_RBTREE_LEFT] = NULL;
     node->children[STARPU_RBTREE_LEFT] = NULL;
     node->children[STARPU_RBTREE_RIGHT] = NULL;
     node->children[STARPU_RBTREE_RIGHT] = NULL;
 
 

+ 3 - 3
src/common/rbtree.h

@@ -75,7 +75,7 @@ static inline void starpu_rbtree_node_init(struct starpu_rbtree_node *node)
 {
 {
     assert(starpu_rbtree_check_alignment(node));
     assert(starpu_rbtree_check_alignment(node));
 
 
-    node->parent = (unsigned long)node | STARPU_RBTREE_COLOR_RED;
+    node->parent = (uintptr_t)node | STARPU_RBTREE_COLOR_RED;
     node->children[STARPU_RBTREE_LEFT] = NULL;
     node->children[STARPU_RBTREE_LEFT] = NULL;
     node->children[STARPU_RBTREE_RIGHT] = NULL;
     node->children[STARPU_RBTREE_RIGHT] = NULL;
 }
 }
@@ -212,7 +212,7 @@ MACRO_END
  * it also returns a slot, which identifies an insertion point in the tree.
  * it also returns a slot, which identifies an insertion point in the tree.
  * If the returned node is null, the slot can be used by starpu_rbtree_insert_slot()
  * If the returned node is null, the slot can be used by starpu_rbtree_insert_slot()
  * to insert without the overhead of an additional lookup. The slot is a
  * to insert without the overhead of an additional lookup. The slot is a
- * simple unsigned long integer.
+ * simple uintptr_t integer.
  *
  *
  * The constraints that apply to the key parameter are the same as for
  * The constraints that apply to the key parameter are the same as for
  * starpu_rbtree_lookup().
  * starpu_rbtree_lookup().
@@ -250,7 +250,7 @@ MACRO_END
  * must not compare equal to an existing node in the tree (i.e. the slot
  * must not compare equal to an existing node in the tree (i.e. the slot
  * must denote a null node).
  * must denote a null node).
  */
  */
-static inline void starpu_rbtree_insert_slot(struct starpu_rbtree *tree, unsigned long slot,
+static inline void starpu_rbtree_insert_slot(struct starpu_rbtree *tree, uintptr_t slot,
                    struct starpu_rbtree_node *node)
                    struct starpu_rbtree_node *node)
 {
 {
     struct starpu_rbtree_node *parent;
     struct starpu_rbtree_node *parent;

+ 6 - 6
src/common/rbtree_i.h

@@ -43,7 +43,7 @@
  * special alignment constraints such as member packing.
  * special alignment constraints such as member packing.
  */
  */
 struct starpu_rbtree_node {
 struct starpu_rbtree_node {
-    unsigned long parent;
+    uintptr_t parent;
     struct starpu_rbtree_node *children[2];
     struct starpu_rbtree_node *children[2];
 };
 };
 
 
@@ -79,7 +79,7 @@ struct starpu_rbtree {
  */
  */
 static inline int starpu_rbtree_check_alignment(const struct starpu_rbtree_node *node)
 static inline int starpu_rbtree_check_alignment(const struct starpu_rbtree_node *node)
 {
 {
-    return ((unsigned long)node & (~STARPU_RBTREE_PARENT_MASK)) == 0;
+    return ((uintptr_t)node & (~STARPU_RBTREE_PARENT_MASK)) == 0;
 }
 }
 
 
 /*
 /*
@@ -112,17 +112,17 @@ static inline struct starpu_rbtree_node * starpu_rbtree_parent(const struct star
 /*
 /*
  * Translate an insertion point into a slot.
  * Translate an insertion point into a slot.
  */
  */
-static inline unsigned long starpu_rbtree_slot(struct starpu_rbtree_node *parent, int index)
+static inline uintptr_t starpu_rbtree_slot(struct starpu_rbtree_node *parent, int index)
 {
 {
     assert(starpu_rbtree_check_alignment(parent));
     assert(starpu_rbtree_check_alignment(parent));
     assert(starpu_rbtree_check_index(index));
     assert(starpu_rbtree_check_index(index));
-    return (unsigned long)parent | index;
+    return (uintptr_t)parent | index;
 }
 }
 
 
 /*
 /*
  * Extract the parent address from a slot.
  * Extract the parent address from a slot.
  */
  */
-static inline struct starpu_rbtree_node * starpu_rbtree_slot_parent(unsigned long slot)
+static inline struct starpu_rbtree_node * starpu_rbtree_slot_parent(uintptr_t slot)
 {
 {
     return (struct starpu_rbtree_node *)(slot & STARPU_RBTREE_SLOT_PARENT_MASK);
     return (struct starpu_rbtree_node *)(slot & STARPU_RBTREE_SLOT_PARENT_MASK);
 }
 }
@@ -130,7 +130,7 @@ static inline struct starpu_rbtree_node * starpu_rbtree_slot_parent(unsigned lon
 /*
 /*
  * Extract the index from a slot.
  * Extract the index from a slot.
  */
  */
-static inline int starpu_rbtree_slot_index(unsigned long slot)
+static inline int starpu_rbtree_slot_index(uintptr_t slot)
 {
 {
     return slot & STARPU_RBTREE_SLOT_INDEX_MASK;
     return slot & STARPU_RBTREE_SLOT_INDEX_MASK;
 }
 }