Browse Source

make sure that backend initialization is done only once

cache-refactoring
Aleksey Demakov 18 years ago
parent
commit
5abea97ffa
  1. 10
      ChangeLog
  2. 14
      jit/jit-init.c
  3. 9
      jit/jit-thread.c
  4. 5
      jit/jit-thread.h

10
ChangeLog

@ -1,8 +1,14 @@
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>

14
jit/jit-init.c

@ -37,9 +37,20 @@
@*/
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();
@ -47,6 +58,9 @@ void jit_init(void)
/* Initialize the backend */
_jit_init_backend();
done:
jit_mutex_unlock(&_jit_global_lock);
}
/*@

9
jit/jit-thread.c

@ -34,6 +34,11 @@
#endif
#include <errno.h>
/*
* Mutex that synchronizes global data initialization.
*/
jit_mutex_t _jit_global_lock;
#if defined(JIT_THREADS_PTHREAD)
/*
@ -46,6 +51,8 @@ static pthread_key_t control_key;
*/
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 */
@ -64,6 +71,8 @@ static DWORD control_key;
*/
static void init_win32_thread(void)
{
jit_mutex_create(&_jit_global_lock);
control_key = TlsAlloc();
}

5
jit/jit-thread.h

@ -115,6 +115,11 @@ typedef int jit_mutex_t;
#endif
/*
* Mutex that synchronizes global data initialization.
*/
extern jit_mutex_t _jit_global_lock;
/*
* Define the primitive monitor operations.
*/

Loading…
Cancel
Save