From d6f3d91d455659f715248fb1727274c05f8c0b84 Mon Sep 17 00:00:00 2001 From: stefan Date: Wed, 21 Jan 2004 00:49:42 +0000 Subject: [PATCH] More NATIVE_THREADS ifdefs --- builtin.c | 10 +++++----- jit/jit.c | 8 +++++++- jni.c | 6 +++++- loader.c | 22 +++++++++++++++------- main.c | 12 ++++++------ mm/boehm.c | 4 ++-- nat/Thread.c | 20 ++++++++++---------- nat/VMObject.c | 8 ++++---- src/cacao/cacao.c | 12 ++++++------ src/mm/boehm.c | 4 ++-- src/native/jni.c | 6 +++++- src/native/vm/VMObject.c | 8 ++++---- src/native/vm/VMThread.c | 20 ++++++++++---------- src/threads/green/locks.c | 4 ++++ src/threads/green/threadio.c | 3 +++ src/threads/green/threads.c | 19 +++++++++++-------- src/threads/green/threads.h | 4 +++- src/vm/builtin.c | 10 +++++----- src/vm/jit/jit.c | 8 +++++++- src/vm/loader.c | 22 +++++++++++++++------- threads/locks.c | 4 ++++ threads/thread.c | 19 +++++++++++-------- threads/thread.h | 4 +++- threads/threadio.c | 3 +++ 24 files changed, 150 insertions(+), 90 deletions(-) diff --git a/builtin.c b/builtin.c index bf2511e04..237141b23 100644 --- a/builtin.c +++ b/builtin.c @@ -34,7 +34,7 @@ calls instead of machine instructions, using the C calling convention. - $Id: builtin.c 890 2004-01-19 12:24:13Z edwin $ + $Id: builtin.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -1010,7 +1010,7 @@ void builtin_displaymethodexception(methodinfo *method) */ void internal_lock_mutex_for_object(java_objectheader *object) { -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) mutexHashEntry *entry; int hashValue; @@ -1060,7 +1060,7 @@ void internal_lock_mutex_for_object(java_objectheader *object) */ void internal_unlock_mutex_for_object (java_objectheader *object) { -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) int hashValue; mutexHashEntry *entry; @@ -1092,7 +1092,7 @@ void internal_unlock_mutex_for_object (java_objectheader *object) void builtin_monitorenter(java_objectheader *o) { -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) int hashValue; assert(blockInts == 0); @@ -1115,7 +1115,7 @@ void builtin_monitorenter(java_objectheader *o) void builtin_monitorexit (java_objectheader *o) { -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) int hashValue; assert(blockInts == 0); diff --git a/jit/jit.c b/jit/jit.c index 178d3f611..c877520d9 100644 --- a/jit/jit.c +++ b/jit/jit.c @@ -29,7 +29,7 @@ Changes: Edwin Steiner - $Id: jit.c 892 2004-01-19 12:32:29Z edwin $ + $Id: jit.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -1454,7 +1454,9 @@ methodptr jit_compile(methodinfo *m) pthread_mutex_lock(&compiler_mutex); #endif +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsDisable(); /* disable interrupts */ +#endif regs_ok = false; @@ -1477,7 +1479,9 @@ methodptr jit_compile(methodinfo *m) utf_sprint(logtext+strlen(logtext), m->name); utf_sprint(logtext+strlen(logtext), m->descriptor); log_text(logtext); +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsRestore(); /* enable interrupts again */ +#endif return (methodptr) do_nothing_function; /* return empty method */ } @@ -1595,7 +1599,9 @@ methodptr jit_compile(methodinfo *m) compilingtime += (stoptime - starttime); } +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsRestore(); /* enable interrupts again */ +#endif #if defined(USE_THREADS) && defined(NATIVE_THREADS) pthread_mutex_unlock(&compiler_mutex); diff --git a/jni.c b/jni.c index 289e01556..e3e5ca983 100644 --- a/jni.c +++ b/jni.c @@ -28,7 +28,7 @@ Changes: Joseph Wenninger - $Id: jni.c 862 2004-01-06 23:42:01Z stefan $ + $Id: jni.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -212,7 +212,9 @@ char fill_callblock_objA(void *obj, utf *descr, jni_callblock blk[], java_object u4 dummy; char c; char *cp; +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsDisable(); +#endif if (utf_char==0) { utf_char=utf_new_char("java/lang/Character"); utf_bool=utf_new_char("java/lang/Boolean"); @@ -223,7 +225,9 @@ char fill_callblock_objA(void *obj, utf *descr, jni_callblock blk[], java_object utf_float=utf_new_char("java/lang/Float"); utf_double=utf_new_char("java/lang/Double"); } +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsRestore(); +#endif /* log_text("fill_callblock"); diff --git a/loader.c b/loader.c index e8d8bd58d..aae004cf1 100644 --- a/loader.c +++ b/loader.c @@ -30,7 +30,7 @@ Mark Probst Edwin Steiner - $Id: loader.c 890 2004-01-19 12:24:13Z edwin $ + $Id: loader.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -2785,7 +2785,7 @@ void class_init(classinfo *c) { methodinfo *m; s4 i; -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) int b; #endif @@ -2849,7 +2849,7 @@ void class_init(classinfo *c) log_text(logtext); } -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) b = blockInts; blockInts = 0; #endif @@ -2857,7 +2857,7 @@ void class_init(classinfo *c) /* now call the initializer */ asm_calljavafunction(m, NULL, NULL, NULL, NULL); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) assert(blockInts == 0); blockInts = b; #endif @@ -2896,14 +2896,14 @@ void class_init(classinfo *c) return; } -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) b = blockInts; blockInts = 0; #endif asm_calljavafunction(m, NULL, NULL, NULL, NULL); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) assert(blockInts == 0); blockInts = b; #endif @@ -3200,7 +3200,9 @@ classinfo *loader_load(utf *topname) loader_load_running++; +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsDisable(); +#endif if (getloadingtime) starttime = getcputime(); @@ -3277,7 +3279,9 @@ classinfo *loader_load(utf *topname) } } +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsRestore(); +#endif #if defined(USE_THREADS) && defined(NATIVE_THREADS) pthread_mutex_unlock(&compiler_mutex); @@ -3656,7 +3660,7 @@ void loader_init(u1 *stackbottom) /* correct vftbl-entries (retarded loading of class java/lang/String) */ stringtable_update(); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) if (stackbottom!=0) initLocks(); #endif @@ -3758,7 +3762,9 @@ void loader_compute_subclasses() { classinfo *c; +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsDisable(); /* schani */ +#endif c = list_first(&linkedclasses); while (c) { @@ -3787,7 +3793,9 @@ void loader_compute_subclasses() cast_unlock(); #endif +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsRestore(); /* schani */ +#endif } diff --git a/main.c b/main.c index 3c8d71c49..7bcca06a7 100644 --- a/main.c +++ b/main.c @@ -37,7 +37,7 @@ - Calling the class loader - Running the main method - $Id: main.c 895 2004-01-19 13:53:43Z edwin $ + $Id: main.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -119,7 +119,7 @@ bool opt_verify = true; /* true if classfiles should be verified */ static classinfo *topclass; -#ifndef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) void **stackbottom = 0; #endif @@ -567,7 +567,7 @@ void exit_handler(void) if (showconstantpool) class_showconstantpool(topclass); if (showutf) utf_show(); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) clear_thread_flags(); /* restores standard file descriptor flags */ #endif @@ -618,7 +618,7 @@ int main(int argc, char **argv) char *specificmethodname = NULL; char *specificsignature = NULL; -#ifndef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) stackbottom = &dummy; #endif @@ -903,7 +903,7 @@ int main(int argc, char **argv) /* initialize the garbage collector */ gc_init(); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) initThreads((u1*) &dummy); #endif @@ -954,7 +954,7 @@ int main(int argc, char **argv) printf("\n"); } -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) killThread(currentThread); #endif fprintf(stderr, "still here\n"); diff --git a/mm/boehm.c b/mm/boehm.c index 0ca2deaa3..fb9800452 100644 --- a/mm/boehm.c +++ b/mm/boehm.c @@ -26,7 +26,7 @@ Authors: Stefan Ring - $Id: boehm.c 862 2004-01-06 23:42:01Z stefan $ + $Id: boehm.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -84,7 +84,7 @@ static void *stackcall_free(void *p, u4 bytelength) } -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) #define MAINTHREADCALL(r,m,pp,ll) \ if (currentThread == NULL || currentThread == mainThread) { \ r = m(pp, ll); \ diff --git a/nat/Thread.c b/nat/Thread.c index 683b5ddf3..b6478e08f 100644 --- a/nat/Thread.c +++ b/nat/Thread.c @@ -28,7 +28,7 @@ Changes: Joseph Wenninger - $Id: Thread.c 873 2004-01-11 20:59:29Z twisti $ + $Id: Thread.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -70,7 +70,7 @@ JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_Thread_currentThread(JNIEnv * if (runverbose) log_text("java_lang_Thread_currentThread called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) t = (java_lang_Thread *) currentThread; if (!t->group) { @@ -112,7 +112,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, java_lang_Thread if (runverbose) log_text("java_lang_Thread_isAlive called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) return aliveThread((thread *) this); #else return 0; @@ -154,7 +154,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_nativeResume(JNIEnv *env, java_lang if (runverbose) log_text("java_lang_Thread_resume0 called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) resumeThread((thread *) this); #endif } @@ -170,7 +170,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_nativeSetPriority(JNIEnv *env, java if (runverbose) log_text("java_lang_Thread_setPriority0 called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) setPriorityThread((thread *) this, par1); #endif } @@ -186,7 +186,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_sleep(JNIEnv *env, jclass clazz, s8 if (runverbose) log_text("java_lang_Thread_sleep called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) sleepThread(millis); #endif } @@ -202,7 +202,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_start(JNIEnv *env, java_lang_Thread if (runverbose) log_text("java_lang_Thread_start called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) startThread((thread*)this); #endif } @@ -219,7 +219,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_nativeStop(JNIEnv *env, java_lang_T log_text ("java_lang_Thread_stop0 called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) if (currentThread == (thread*)this) { log_text("killing"); killThread(0); @@ -246,7 +246,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_nativeSuspend(JNIEnv *env, java_lan if (runverbose) log_text("java_lang_Thread_suspend0 called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) suspendThread((thread*)this); #endif } @@ -262,7 +262,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_yield(JNIEnv *env, jclass clazz) if (runverbose) log_text("java_lang_Thread_yield called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) yieldThread(); #endif } diff --git a/nat/VMObject.c b/nat/VMObject.c index 425a66c5d..f3baf6202 100644 --- a/nat/VMObject.c +++ b/nat/VMObject.c @@ -28,7 +28,7 @@ Changes: Joseph Wenninger - $Id: VMObject.c 873 2004-01-11 20:59:29Z twisti $ + $Id: VMObject.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -101,7 +101,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, if (runverbose) log_text("java_lang_Object_notify called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) signal_cond_for_object(&this->header); #endif } @@ -117,7 +117,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass cla if (runverbose) log_text("java_lang_Object_notifyAll called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) broadcast_cond_for_object(&this->header); #endif } @@ -133,7 +133,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, j if (runverbose) log_text("java_lang_Object_wait called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) wait_cond_for_object(&this->header, time); #endif } diff --git a/src/cacao/cacao.c b/src/cacao/cacao.c index 8d0ff3448..39d360060 100644 --- a/src/cacao/cacao.c +++ b/src/cacao/cacao.c @@ -37,7 +37,7 @@ - Calling the class loader - Running the main method - $Id: cacao.c 895 2004-01-19 13:53:43Z edwin $ + $Id: cacao.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -119,7 +119,7 @@ bool opt_verify = true; /* true if classfiles should be verified */ static classinfo *topclass; -#ifndef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) void **stackbottom = 0; #endif @@ -567,7 +567,7 @@ void exit_handler(void) if (showconstantpool) class_showconstantpool(topclass); if (showutf) utf_show(); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) clear_thread_flags(); /* restores standard file descriptor flags */ #endif @@ -618,7 +618,7 @@ int main(int argc, char **argv) char *specificmethodname = NULL; char *specificsignature = NULL; -#ifndef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) stackbottom = &dummy; #endif @@ -903,7 +903,7 @@ int main(int argc, char **argv) /* initialize the garbage collector */ gc_init(); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) initThreads((u1*) &dummy); #endif @@ -954,7 +954,7 @@ int main(int argc, char **argv) printf("\n"); } -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) killThread(currentThread); #endif fprintf(stderr, "still here\n"); diff --git a/src/mm/boehm.c b/src/mm/boehm.c index 0ca2deaa3..fb9800452 100644 --- a/src/mm/boehm.c +++ b/src/mm/boehm.c @@ -26,7 +26,7 @@ Authors: Stefan Ring - $Id: boehm.c 862 2004-01-06 23:42:01Z stefan $ + $Id: boehm.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -84,7 +84,7 @@ static void *stackcall_free(void *p, u4 bytelength) } -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) #define MAINTHREADCALL(r,m,pp,ll) \ if (currentThread == NULL || currentThread == mainThread) { \ r = m(pp, ll); \ diff --git a/src/native/jni.c b/src/native/jni.c index 289e01556..e3e5ca983 100644 --- a/src/native/jni.c +++ b/src/native/jni.c @@ -28,7 +28,7 @@ Changes: Joseph Wenninger - $Id: jni.c 862 2004-01-06 23:42:01Z stefan $ + $Id: jni.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -212,7 +212,9 @@ char fill_callblock_objA(void *obj, utf *descr, jni_callblock blk[], java_object u4 dummy; char c; char *cp; +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsDisable(); +#endif if (utf_char==0) { utf_char=utf_new_char("java/lang/Character"); utf_bool=utf_new_char("java/lang/Boolean"); @@ -223,7 +225,9 @@ char fill_callblock_objA(void *obj, utf *descr, jni_callblock blk[], java_object utf_float=utf_new_char("java/lang/Float"); utf_double=utf_new_char("java/lang/Double"); } +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsRestore(); +#endif /* log_text("fill_callblock"); diff --git a/src/native/vm/VMObject.c b/src/native/vm/VMObject.c index 425a66c5d..f3baf6202 100644 --- a/src/native/vm/VMObject.c +++ b/src/native/vm/VMObject.c @@ -28,7 +28,7 @@ Changes: Joseph Wenninger - $Id: VMObject.c 873 2004-01-11 20:59:29Z twisti $ + $Id: VMObject.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -101,7 +101,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, if (runverbose) log_text("java_lang_Object_notify called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) signal_cond_for_object(&this->header); #endif } @@ -117,7 +117,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass cla if (runverbose) log_text("java_lang_Object_notifyAll called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) broadcast_cond_for_object(&this->header); #endif } @@ -133,7 +133,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, j if (runverbose) log_text("java_lang_Object_wait called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) wait_cond_for_object(&this->header, time); #endif } diff --git a/src/native/vm/VMThread.c b/src/native/vm/VMThread.c index 92c5a130e..33eddef50 100644 --- a/src/native/vm/VMThread.c +++ b/src/native/vm/VMThread.c @@ -28,7 +28,7 @@ Changes: Joseph Wenninger - $Id: VMThread.c 873 2004-01-11 20:59:29Z twisti $ + $Id: VMThread.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -70,7 +70,7 @@ JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_Thread_currentThread(JNIEnv * if (runverbose) log_text("java_lang_Thread_currentThread called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) t = (java_lang_Thread *) currentThread; if (!t->group) { @@ -112,7 +112,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, java_lang_Thread if (runverbose) log_text("java_lang_Thread_isAlive called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) return aliveThread((thread *) this); #else return 0; @@ -154,7 +154,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_nativeResume(JNIEnv *env, java_lang if (runverbose) log_text("java_lang_Thread_resume0 called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) resumeThread((thread *) this); #endif } @@ -170,7 +170,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_nativeSetPriority(JNIEnv *env, java if (runverbose) log_text("java_lang_Thread_setPriority0 called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) setPriorityThread((thread *) this, par1); #endif } @@ -186,7 +186,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_sleep(JNIEnv *env, jclass clazz, s8 if (runverbose) log_text("java_lang_Thread_sleep called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) sleepThread(millis); #endif } @@ -202,7 +202,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_start(JNIEnv *env, java_lang_Thread if (runverbose) log_text("java_lang_Thread_start called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) startThread((thread*)this); #endif } @@ -219,7 +219,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_nativeStop(JNIEnv *env, java_lang_T log_text ("java_lang_Thread_stop0 called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) if (currentThread == (thread*)this) { log_text("killing"); killThread(0); @@ -246,7 +246,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_nativeSuspend(JNIEnv *env, java_lan if (runverbose) log_text("java_lang_Thread_suspend0 called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) suspendThread((thread*)this); #endif } @@ -262,7 +262,7 @@ JNIEXPORT void JNICALL Java_java_lang_Thread_yield(JNIEnv *env, jclass clazz) if (runverbose) log_text("java_lang_Thread_yield called"); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) yieldThread(); #endif } diff --git a/src/threads/green/locks.c b/src/threads/green/locks.c index f200794c8..0a9e1ddf5 100644 --- a/src/threads/green/locks.c +++ b/src/threads/green/locks.c @@ -25,6 +25,8 @@ #include "native.h" #include "loader.h" +#if !defined(NATIVE_THREADS) + static classinfo *class_java_lang_IllegalMonitorStateException; extern thread* currentThread; @@ -567,3 +569,5 @@ internal_broadcast_cond (iCv* cv) cv->cvWaiters = 0; } } + +#endif diff --git a/src/threads/green/threadio.c b/src/threads/green/threadio.c index cc7b20b66..1f9036cec 100644 --- a/src/threads/green/threadio.c +++ b/src/threads/green/threadio.c @@ -23,6 +23,7 @@ #include "config.h" #include "thread.h" +#if !defined(NATIVE_THREADS) #define TH_READ 0 #define TH_WRITE 1 @@ -475,3 +476,5 @@ checkEvents(bool block) } } } + +#endif diff --git a/src/threads/green/threads.c b/src/threads/green/threads.c index 5a94efa9a..7ae98e6d8 100644 --- a/src/threads/green/threads.c +++ b/src/threads/green/threads.c @@ -97,7 +97,16 @@ int cast_counter; #ifndef HAVE___THREAD pthread_key_t tkey_threadinfo; #endif -#endif + +void cast_lock() +{ +} + +void cast_unlock() +{ +} + +#else // !defined(NATIVE_THREADS) static classinfo *class_java_lang_ThreadDeath; @@ -842,10 +851,4 @@ reschedule(void) } } -void cast_lock() -{ -} - -void cast_unlock() -{ -} +#endif diff --git a/src/threads/green/threads.h b/src/threads/green/threads.h index b7fa97452..509395e80 100644 --- a/src/threads/green/threads.h +++ b/src/threads/green/threads.h @@ -49,6 +49,8 @@ #define SDBG(s) s #endif +#if !defined(NATIVE_THREADS) + struct _thread; typedef struct _ctx @@ -175,7 +177,7 @@ typedef struct { java_objectheader *_exceptionptr; } nativethread; -#if defined(NATIVE_THREADS) +#else // defined(NATIVE_THREADS) #if !defined(HAVE___THREAD) extern pthread_key_t tkey_threadinfo; diff --git a/src/vm/builtin.c b/src/vm/builtin.c index bf2511e04..237141b23 100644 --- a/src/vm/builtin.c +++ b/src/vm/builtin.c @@ -34,7 +34,7 @@ calls instead of machine instructions, using the C calling convention. - $Id: builtin.c 890 2004-01-19 12:24:13Z edwin $ + $Id: builtin.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -1010,7 +1010,7 @@ void builtin_displaymethodexception(methodinfo *method) */ void internal_lock_mutex_for_object(java_objectheader *object) { -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) mutexHashEntry *entry; int hashValue; @@ -1060,7 +1060,7 @@ void internal_lock_mutex_for_object(java_objectheader *object) */ void internal_unlock_mutex_for_object (java_objectheader *object) { -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) int hashValue; mutexHashEntry *entry; @@ -1092,7 +1092,7 @@ void internal_unlock_mutex_for_object (java_objectheader *object) void builtin_monitorenter(java_objectheader *o) { -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) int hashValue; assert(blockInts == 0); @@ -1115,7 +1115,7 @@ void builtin_monitorenter(java_objectheader *o) void builtin_monitorexit (java_objectheader *o) { -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) int hashValue; assert(blockInts == 0); diff --git a/src/vm/jit/jit.c b/src/vm/jit/jit.c index 178d3f611..c877520d9 100644 --- a/src/vm/jit/jit.c +++ b/src/vm/jit/jit.c @@ -29,7 +29,7 @@ Changes: Edwin Steiner - $Id: jit.c 892 2004-01-19 12:32:29Z edwin $ + $Id: jit.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -1454,7 +1454,9 @@ methodptr jit_compile(methodinfo *m) pthread_mutex_lock(&compiler_mutex); #endif +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsDisable(); /* disable interrupts */ +#endif regs_ok = false; @@ -1477,7 +1479,9 @@ methodptr jit_compile(methodinfo *m) utf_sprint(logtext+strlen(logtext), m->name); utf_sprint(logtext+strlen(logtext), m->descriptor); log_text(logtext); +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsRestore(); /* enable interrupts again */ +#endif return (methodptr) do_nothing_function; /* return empty method */ } @@ -1595,7 +1599,9 @@ methodptr jit_compile(methodinfo *m) compilingtime += (stoptime - starttime); } +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsRestore(); /* enable interrupts again */ +#endif #if defined(USE_THREADS) && defined(NATIVE_THREADS) pthread_mutex_unlock(&compiler_mutex); diff --git a/src/vm/loader.c b/src/vm/loader.c index e8d8bd58d..aae004cf1 100644 --- a/src/vm/loader.c +++ b/src/vm/loader.c @@ -30,7 +30,7 @@ Mark Probst Edwin Steiner - $Id: loader.c 890 2004-01-19 12:24:13Z edwin $ + $Id: loader.c 897 2004-01-21 00:49:42Z stefan $ */ @@ -2785,7 +2785,7 @@ void class_init(classinfo *c) { methodinfo *m; s4 i; -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) int b; #endif @@ -2849,7 +2849,7 @@ void class_init(classinfo *c) log_text(logtext); } -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) b = blockInts; blockInts = 0; #endif @@ -2857,7 +2857,7 @@ void class_init(classinfo *c) /* now call the initializer */ asm_calljavafunction(m, NULL, NULL, NULL, NULL); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) assert(blockInts == 0); blockInts = b; #endif @@ -2896,14 +2896,14 @@ void class_init(classinfo *c) return; } -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) b = blockInts; blockInts = 0; #endif asm_calljavafunction(m, NULL, NULL, NULL, NULL); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) assert(blockInts == 0); blockInts = b; #endif @@ -3200,7 +3200,9 @@ classinfo *loader_load(utf *topname) loader_load_running++; +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsDisable(); +#endif if (getloadingtime) starttime = getcputime(); @@ -3277,7 +3279,9 @@ classinfo *loader_load(utf *topname) } } +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsRestore(); +#endif #if defined(USE_THREADS) && defined(NATIVE_THREADS) pthread_mutex_unlock(&compiler_mutex); @@ -3656,7 +3660,7 @@ void loader_init(u1 *stackbottom) /* correct vftbl-entries (retarded loading of class java/lang/String) */ stringtable_update(); -#ifdef USE_THREADS +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) if (stackbottom!=0) initLocks(); #endif @@ -3758,7 +3762,9 @@ void loader_compute_subclasses() { classinfo *c; +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsDisable(); /* schani */ +#endif c = list_first(&linkedclasses); while (c) { @@ -3787,7 +3793,9 @@ void loader_compute_subclasses() cast_unlock(); #endif +#if defined(USE_THREADS) && !defined(NATIVE_THREADS) intsRestore(); /* schani */ +#endif } diff --git a/threads/locks.c b/threads/locks.c index f200794c8..0a9e1ddf5 100644 --- a/threads/locks.c +++ b/threads/locks.c @@ -25,6 +25,8 @@ #include "native.h" #include "loader.h" +#if !defined(NATIVE_THREADS) + static classinfo *class_java_lang_IllegalMonitorStateException; extern thread* currentThread; @@ -567,3 +569,5 @@ internal_broadcast_cond (iCv* cv) cv->cvWaiters = 0; } } + +#endif diff --git a/threads/thread.c b/threads/thread.c index 5a94efa9a..7ae98e6d8 100644 --- a/threads/thread.c +++ b/threads/thread.c @@ -97,7 +97,16 @@ int cast_counter; #ifndef HAVE___THREAD pthread_key_t tkey_threadinfo; #endif -#endif + +void cast_lock() +{ +} + +void cast_unlock() +{ +} + +#else // !defined(NATIVE_THREADS) static classinfo *class_java_lang_ThreadDeath; @@ -842,10 +851,4 @@ reschedule(void) } } -void cast_lock() -{ -} - -void cast_unlock() -{ -} +#endif diff --git a/threads/thread.h b/threads/thread.h index b7fa97452..509395e80 100644 --- a/threads/thread.h +++ b/threads/thread.h @@ -49,6 +49,8 @@ #define SDBG(s) s #endif +#if !defined(NATIVE_THREADS) + struct _thread; typedef struct _ctx @@ -175,7 +177,7 @@ typedef struct { java_objectheader *_exceptionptr; } nativethread; -#if defined(NATIVE_THREADS) +#else // defined(NATIVE_THREADS) #if !defined(HAVE___THREAD) extern pthread_key_t tkey_threadinfo; diff --git a/threads/threadio.c b/threads/threadio.c index cc7b20b66..1f9036cec 100644 --- a/threads/threadio.c +++ b/threads/threadio.c @@ -23,6 +23,7 @@ #include "config.h" #include "thread.h" +#if !defined(NATIVE_THREADS) #define TH_READ 0 #define TH_WRITE 1 @@ -475,3 +476,5 @@ checkEvents(bool block) } } } + +#endif -- 2.25.1