/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This source file is part of SableVM. * * * * See the file "LICENSE" for the copyright information and for * * the terms and conditions for copying, distribution and * * modification of this source file. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef SVM_THREAD_H #define SVM_THREAD_H #if 0 #define _svmm_debug_synchronization(env,msg,par1,par2,par3,par4) \ _svmf_printf(env, stderr, "SYNC(%d): " msg "\n", \ env->thread.id, par1, par2, par3, par4) #else #define _svmm_debug_synchronization(env,msg,par1,par2,par3,par4) {} #endif #ifdef STATISTICS svm_static void _svmf_register_event (_svmt_JNIEnv *, const char *, const char *, const char *, size_t); #define _svmm_stat_inc(name,file,func,line) env->vm->total_##name##_count++, \ _svmf_register_event(env,#name "",file,func,line); #else /* STATISTICS */ #define _svmm_stat_inc(name,file,func,line) (0) #endif /* STATISTICS */ #define _svmm_mutex_init(mutex) \ pthread_mutex_init (&mutex, NULL) #define _svmm_mutex_destroy(mutex) \ pthread_mutex_destroy (&mutex) #define _svmm_mutex_lock(mutex) \ { \ pthread_mutex_t *_svmx_pmutex = &mutex; \ pthread_mutex_lock (_svmx_pmutex); \ _svmm_stat_inc(mutex_lock,__FILE__,__FUNCTION__,__LINE__) #define _svmm_mutex_unlock() \ pthread_mutex_unlock (_svmx_pmutex); \ _svmm_stat_inc(mutex_unlock,__FILE__,__FUNCTION__,__LINE__); \ } #define _svmm_mutex_lock_noenv(mutex) \ { \ pthread_mutex_t *_svmx_pmutex = &mutex; \ pthread_mutex_lock (_svmx_pmutex) #define _svmm_mutex_unlock_noenv() \ pthread_mutex_unlock (_svmx_pmutex); \ } #define _svmm_mutex_lock_raw(mutex) \ pthread_mutex_lock (&mutex), \ _svmm_stat_inc(mutex_lock,__FILE__,__FUNCTION__,__LINE__) #define _svmm_mutex_trylock(mutex) \ pthread_mutex_trylock(&mutex) #define _svmm_mutex_unlock_raw(mutex) \ pthread_mutex_unlock(&mutex), \ _svmm_stat_inc(mutex_unlock,__FILE__,__FUNCTION__,__LINE__) #define _svmm_cond_init(cond) \ pthread_cond_init (&cond, NULL) #define _svmm_cond_destroy(cond) \ pthread_cond_destroy (&cond) #define _svmm_cond_wait(cond, mutex) \ pthread_cond_wait (&cond, &mutex), \ _svmm_stat_inc(cond_wait,__FILE__,__FUNCTION__,__LINE__) #define _svmm_cond_timedwait(cond, mutex, abstime) \ pthread_cond_timedwait (&cond, &mutex, &abstime), \ _svmm_stat_inc(cond_timedwait,__FILE__,__FUNCTION__,__LINE__) #define _svmm_cond_signal(cond) \ pthread_cond_signal (&cond), \ _svmm_stat_inc(cond_signal,__FILE__,__FUNCTION__,__LINE__) #define _svmm_cond_broadcast(cond) \ pthread_cond_broadcast (&cond), \ _svmm_stat_inc(cond_broadcast,__FILE__,__FUNCTION__,__LINE__) #define _svmm_cond_broadcast_ptr(cond) \ pthread_cond_broadcast (cond), \ _svmm_stat_inc(cond_broadcast,__FILE__,__FUNCTION__,__LINE__) #define _svmm_kill(thread, signal) \ pthread_kill (thread, signal) static _svmt_JNIEnv *_svmf_get_current_env (void); #endif /* not SVM_THREAD_H */ #ifdef COMMENT jint _svmf_thread_init (void); jint _svmf_create_initial_thread (_svmt_JavaVM *vm, _svmt_JNIEnv **penv); void _svmf_cleanup_initial_thread (_svmt_JNIEnv **penv); void _svmf_set_current_env (_svmt_JNIEnv *env); jint _svmf_stack_init (_svmt_JNIEnv *env); jint _svmf_ensure_stack_capacity (_svmt_JNIEnv *env, size_t frame_size); #endif /* COMMENT */