+2006-12-20 Aleksey Demakov <ademakov@gmail.com>
+
+ * jit/jit-thread.h, jit/jit-thread.c: add _jit_global_lock mutex.
+ * jit/jit-init.c (jit_init): make sure that initialization is done
+ only once.
+
2006-12-17 Klaus Treichel <ktreichel@web.de>
* include/jit/jit-function.h, jit/jit-function.c: Add the function
- jit_function_from_vtable_pointer to convert a vtable pointer back to the
- jit_function_t.
+ jit_function_from_vtable_pointer to convert a vtable pointer back to
+ the jit_function_t.
2006-11-29 Aleksey Demakov <ademakov@gmail.com>
@*/
void jit_init(void)
{
+ static int init_done = 0;
+
/* Make sure that the thread subsystem is initialized */
_jit_thread_init();
+ /* Make sure that the initialization is done only once
+ (requires the global lock initialized above) */
+ jit_mutex_lock(&_jit_global_lock);
+ if(init_done)
+ {
+ goto done;
+ }
+ init_done = 1;
+
#ifdef JIT_USE_SIGNALS
/* Initialize the signal handlers */
_jit_signal_init();
/* Initialize the backend */
_jit_init_backend();
+
+done:
+ jit_mutex_unlock(&_jit_global_lock);
}
/*@
#endif
#include <errno.h>
+/*
+ * Mutex that synchronizes global data initialization.
+ */
+jit_mutex_t _jit_global_lock;
+
#if defined(JIT_THREADS_PTHREAD)
/*
*/
static void init_pthread(void)
{
+ jit_mutex_create(&_jit_global_lock);
+
/* Allocate a thread-specific variable for the JIT's thread
control object, and arrange for it to be freed when the
thread exits or is otherwise terminated */
*/
static void init_win32_thread(void)
{
+ jit_mutex_create(&_jit_global_lock);
+
control_key = TlsAlloc();
}
#endif
+/*
+ * Mutex that synchronizes global data initialization.
+ */
+extern jit_mutex_t _jit_global_lock;
+
/*
* Define the primitive monitor operations.
*/