* src/vm/jit/i386/asmpart.S: Made position independent.
[cacao.git] / src / toolbox / avl.c
index 4fe67c5c992af864f4d44c727f00df683831af79..d9d31210b3a863ecf9015efd341b2dc86c33c197 100644 (file)
@@ -1,9 +1,7 @@
 /* src/toolbox/avl.c - AVL tree implementation
 
-   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
 
 #include "vm/types.h"
 
-#include "mm/memory.h"
+#include "mm/memory.hpp"
 
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
 
 #include "toolbox/avl.h"
-#include "toolbox/logging.h"
+#include "toolbox/logging.hpp"
 
 #include "vm/global.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 
 /* avl_create ******************************************************************
@@ -54,18 +52,11 @@ avl_tree_t *avl_create(avl_comparator *comparator)
 
        t = NEW(avl_tree_t);
 
+       t->mutex      = Mutex_new();
        t->root       = NULL;
        t->comparator = comparator;
        t->entries    = 0;
 
-#if defined(ENABLE_THREADS)
-       /* create lock object for this tree */
-
-       t->lock       = NEW(java_object_t);
-
-       LOCK_INIT_OBJECT_LOCK(t->lock);
-#endif
-
        return t;
 }
 
@@ -312,7 +303,7 @@ bool avl_insert(avl_tree_t *tree, void *data)
        assert(tree);
        assert(data);
 
-       LOCK_MONITOR_ENTER(tree->lock);
+       Mutex_lock(tree->mutex);
 
        /* if we don't have a root node, create one */
 
@@ -325,7 +316,7 @@ bool avl_insert(avl_tree_t *tree, void *data)
 
        tree->entries++;
 
-       LOCK_MONITOR_EXIT(tree->lock);
+       Mutex_unlock(tree->mutex);
 
        /* insertion was ok */
 
@@ -348,7 +339,7 @@ void *avl_find(avl_tree_t *tree, void *data)
        assert(tree);
        assert(data);
 
-       LOCK_MONITOR_ENTER(tree->lock);
+       Mutex_lock(tree->mutex);
 
        /* search the tree for the given node */
 
@@ -360,7 +351,7 @@ void *avl_find(avl_tree_t *tree, void *data)
                /* was the entry found? return it */
 
                if (res == 0) {
-                       LOCK_MONITOR_EXIT(tree->lock);
+                       Mutex_unlock(tree->mutex);
 
                        return node->data;
                }
@@ -370,7 +361,7 @@ void *avl_find(avl_tree_t *tree, void *data)
                node = node->childs[(res < 0) ? AVL_LEFT : AVL_RIGHT];
        }
 
-       LOCK_MONITOR_EXIT(tree->lock);
+       Mutex_unlock(tree->mutex);
 
        /* entry was not found, returning NULL */