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 ******************************************************************
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;
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 */
printf("-------------------\n");
#endif
-#if defined(USE_THREADS)
- builtin_monitorexit(tree->lock);
-#endif
+ LOCK_MONITOR_EXIT(tree->lock);
/* insertion was ok */
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 */
/* 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;
}
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 */