diff --git a/src/keys.h b/src/keys.h index 5ad6c8cf..832e6bc0 100644 --- a/src/keys.h +++ b/src/keys.h @@ -136,9 +136,6 @@ // ---------------------------------------------------------------------------- -extern pthread_mutex_t interface_mutex; -extern pthread_cond_t cpu_thread_cond; -extern pthread_cond_t ui_thread_cond; extern bool caps_lock; int c_mygetch(int block); diff --git a/src/meta/debugger.c b/src/meta/debugger.c index e7541e75..df255efc 100644 --- a/src/meta/debugger.c +++ b/src/meta/debugger.c @@ -1170,7 +1170,7 @@ static int begin_cpu_stepping() { if ((err = pthread_cond_signal(&cpu_thread_cond))) { ERRLOG("pthread_cond_signal : %d", err); } - if ((err = pthread_cond_wait(&ui_thread_cond, &interface_mutex))) { + if ((err = pthread_cond_wait(&dbg_thread_cond, &interface_mutex))) { ERRLOG("pthread_cond_wait : %d", err); } diff --git a/src/timing.c b/src/timing.c index 1dc9f3bd..d2a2d134 100644 --- a/src/timing.c +++ b/src/timing.c @@ -70,16 +70,18 @@ static bool alt_speed_enabled = false; volatile uint8_t emul_reinitialize = 0; pthread_t cpu_thread_id = 0; pthread_mutex_t interface_mutex = { 0 }; -pthread_cond_t ui_thread_cond = PTHREAD_COND_INITIALIZER; +pthread_cond_t dbg_thread_cond = PTHREAD_COND_INITIALIZER; pthread_cond_t cpu_thread_cond = PTHREAD_COND_INITIALIZER; // ----------------------------------------------------------------------------- __attribute__((constructor)) -static void _init_timing() { +static void _init_timing(void) { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); +#if !TESTING pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); +#endif pthread_mutex_init(&interface_mutex, &attr); } @@ -262,7 +264,7 @@ void *cpu_thread(void *dummyptr) { debugging_cycles -= cpu65_cycle_count; if (c_debugger_should_break() || (debugging_cycles <= 0)) { int err = 0; - if ((err = pthread_cond_signal(&ui_thread_cond))) { + if ((err = pthread_cond_signal(&dbg_thread_cond))) { ERRLOG("pthread_cond_signal : %d", err); } if ((err = pthread_cond_wait(&cpu_thread_cond, &interface_mutex))) { diff --git a/src/timing.h b/src/timing.h index 74336ce6..87687977 100644 --- a/src/timing.h +++ b/src/timing.h @@ -52,6 +52,9 @@ extern double cpu_altscale_factor; // scale factor #2 extern bool is_fullspeed; // emulation in full native speed? extern pthread_t cpu_thread_id; +extern pthread_mutex_t interface_mutex; +extern pthread_cond_t cpu_thread_cond; +extern pthread_cond_t dbg_thread_cond; /* * calculate the difference between two timespec structures