* src/vm/stack.c (new_stack_analyse): Removed assert to check, that
[cacao.git] / src / toolbox / avl.c
index 7933ad2e54045a0cbbf9e4a8f5194b6d04b7602a..24981f51c0ed556687a368d3f21b2cac21c0731c 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: avl.c 4908 2006-05-12 16:49:50Z edwin $
+   $Id: avl.c 5123 2006-07-12 21:45:34Z twisti $
 
 */
 
 #include "mm/memory.h"
 #include "toolbox/avl.h"
 
-#if defined(USE_THREADS)
-# if defined(NATIVE_THREADS)
-#  include "threads/native/threads.h"
-# else
-#  include "threads/green/threads.h"
-# endif
+#if defined(ENABLE_THREADS)
+# include "threads/native/lock.h"
+# include "threads/native/threads.h"
+#else
+# include "threads/none/lock.h"
 #endif
 
-#include "vm/builtin.h"
-
 
 /* avl_create ******************************************************************
 
@@ -69,14 +66,12 @@ avl_tree *avl_create(avl_comparator *compar)
        t->comparator = compar;
        t->entries    = 0;
 
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
        /* create lock object for this tree */
 
        t->lock       = NEW(java_objectheader);
 
-# if defined(NATIVE_THREADS)
        lock_init_object_lock(t->lock);
-# endif
 #endif
 
        return t;
@@ -325,9 +320,7 @@ bool avl_insert(avl_tree *tree, void *data)
        assert(tree);
        assert(data);
 
-#if defined(USE_THREADS)
-       builtin_monitorenter(tree->lock);
-#endif
+       LOCK_MONITOR_ENTER(tree->lock);
 
        /* if we don't have a root node, create one */
 
@@ -350,9 +343,7 @@ bool avl_insert(avl_tree *tree, void *data)
        printf("-------------------\n");
 #endif
 
-#if defined(USE_THREADS)
-       builtin_monitorexit(tree->lock);
-#endif
+       LOCK_MONITOR_EXIT(tree->lock);
 
        /* insertion was ok */
 
@@ -375,9 +366,7 @@ void *avl_find(avl_tree *tree, void *data)
        assert(tree);
        assert(data);
 
-#if defined(USE_THREADS)
-       builtin_monitorenter(tree->lock);
-#endif
+       LOCK_MONITOR_ENTER(tree->lock);
 
        /* search the tree for the given node */
 
@@ -389,9 +378,7 @@ void *avl_find(avl_tree *tree, void *data)
                /* was the entry found? return it */
 
                if (res == 0) {
-#if defined(USE_THREADS)
-                       builtin_monitorexit(tree->lock);
-#endif
+                       LOCK_MONITOR_EXIT(tree->lock);
 
                        return node->data;
                }
@@ -401,9 +388,7 @@ void *avl_find(avl_tree *tree, void *data)
                node = node->childs[(res < 0) ? AVL_LEFT : AVL_RIGHT];
        }
 
-#if defined(USE_THREADS)
-       builtin_monitorexit(tree->lock);
-#endif
+       LOCK_MONITOR_EXIT(tree->lock);
 
        /* entry was not found, returning NULL */