exceptionptr update for native threads
[cacao.git] / threads / locks.c
index e9a766e250d1b28f1458562454e111007053ac0d..f200794c816d0228f274d974f9b3e2f13e8d2ae2 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "thread.h"
 #include "locks.h"
+#include "builtin.h"
 
 #include "tables.h"
 #include "native.h"
 
 static classinfo *class_java_lang_IllegalMonitorStateException;
 
-#if 1
-#define DBG(s)
-#else
-#define DBG(s)   s
-#endif
-
 extern thread* currentThread;
 
-#if defined(USE_INTERNAL_THREADS)
-
 mutexHashEntry *mutexHashTable;
 int mutexHashTableSize;
 long mutexHashMask;
@@ -100,8 +93,8 @@ initLocks (void)
     }
 
        /* Load exception classes */
-       class_java_lang_IllegalMonitorStateException =
-               loader_load(unicode_new_char("java/lang/IllegalMonitorStateException"));
+    loader_load_sysclass(&class_java_lang_IllegalMonitorStateException,
+                         utf_new_char("java/lang/IllegalMonitorStateException"));
 }
 
 /*
@@ -421,7 +414,7 @@ broadcast_cond (iCv *cond)
 void
 internal_lock_mutex(iMux* mux)
 {
-       assert(blockInts == 1);
+       assert(blockInts > 0);
 
     if (mux->holder == 0)
     {
@@ -452,7 +445,7 @@ internal_unlock_mutex(iMux* mux)
 {
     thread* tid;
 
-       assert(blockInts == 1);
+       assert(blockInts > 0);
 
     assert(mux->holder == currentThread);
     
@@ -482,10 +475,10 @@ internal_wait_cond(iMux* mux, iCv* cv, s8 timeout)
     DBG( fprintf(stderr, "waiting on %p\n", cv); );
 
     if (mux->holder != currentThread) {
-               exceptionptr = native_new_and_init(class_java_lang_IllegalMonitorStateException);
+               *exceptionptr = native_new_and_init(class_java_lang_IllegalMonitorStateException);
     }
 
-       assert(blockInts == 1);
+       assert(blockInts > 0);
 
     count = mux->count;
     mux->holder = 0;
@@ -526,10 +519,10 @@ internal_signal_cond (iCv* cv)
     }
 
     if (cv->mux->holder != currentThread) {
-               exceptionptr = native_new_and_init(class_java_lang_IllegalMonitorStateException);
+               *exceptionptr = native_new_and_init(class_java_lang_IllegalMonitorStateException);
     }
 
-       assert(blockInts == 1);
+       assert(blockInts > 0);
 
     /* Remove one thread from cv list */
     if (cv->cvWaiters != 0) {
@@ -558,10 +551,10 @@ internal_broadcast_cond (iCv* cv)
     }
 
     if (cv->mux->holder != currentThread) {
-               exceptionptr = native_new_and_init(class_java_lang_IllegalMonitorStateException);
+               *exceptionptr = native_new_and_init(class_java_lang_IllegalMonitorStateException);
     }
 
-       assert(blockInts == 1);
+       assert(blockInts > 0);
 
     /* Find the end of the cv list */
     if (cv->cvWaiters) {
@@ -574,5 +567,3 @@ internal_broadcast_cond (iCv* cv)
                cv->cvWaiters = 0;
     }
 }
-
-#endif