* gc-malloc.c, gc.h (scm_gc_malloc_prehistory): New function.
authorMikael Djurfeldt <djurfeldt@nada.kth.se>
Tue, 10 Dec 2002 20:25:26 +0000 (20:25 +0000)
committerMikael Djurfeldt <djurfeldt@nada.kth.se>
Tue, 10 Dec 2002 20:25:26 +0000 (20:25 +0000)
* gc-malloc.c (malloc_mutex): New mutex.
(scm_gc_malloc_prehistory): Initialize it.
(scm_realloc): Serialize call to realloc
(scm_calloc): Same for calloc.
Thanks to Wolfgang Jaehrling!
(Now we have to make sure all calls to malloc/realloc are made
through scm_malloc.)

* init.c (scm_init_guile_1): Call scm_gc_malloc_prehistory.

libguile/ChangeLog
libguile/gc-malloc.c
libguile/gc.h
libguile/init.c

index b280678..9798ee1 100644 (file)
@@ -1,13 +1,17 @@
 2002-12-10  Mikael Djurfeldt  <mdj@kvast.blakulla.net>
 
+       * gc-malloc.c, gc.h (scm_gc_malloc_prehistory): New function.
+
        * gc-malloc.c (malloc_mutex): New mutex.
-       (scm_gc_init_malloc): Initialize it.
+       (scm_gc_malloc_prehistory): Initialize it.
        (scm_realloc): Serialize call to realloc
        (scm_calloc): Same for calloc.
        Thanks to Wolfgang Jaehrling!
        (Now we have to make sure all calls to malloc/realloc are made
        through scm_malloc.)
 
+       * init.c (scm_init_guile_1): Call scm_gc_malloc_prehistory.
+
        * threads.c (really_launch): Release heap (to prevent deadlock).
        (create_thread): Release heap before locking thread admin mutex.
 
index f6138f8..b2c73a1 100644 (file)
@@ -101,6 +101,12 @@ static int scm_i_minyield_malloc;
 
 static scm_t_mutex malloc_mutex;
 
+void
+scm_gc_malloc_prehistory ()
+{
+  scm_i_plugin_mutex_init (&malloc_mutex, 0);
+}
+
 void
 scm_gc_init_malloc (void)
 {
@@ -116,8 +122,6 @@ scm_gc_init_malloc (void)
 
   if (scm_mtrigger < 0)
     scm_mtrigger = SCM_DEFAULT_INIT_MALLOC_LIMIT;
-
-  scm_i_plugin_mutex_init (&malloc_mutex, 0);
 }
 
 
@@ -132,7 +136,7 @@ scm_realloc (void *mem, size_t size)
 
   scm_i_plugin_mutex_lock (&malloc_mutex);
   SCM_SYSCALL (ptr = realloc (mem, size));
-  scm_i_plugin_mutex_lock (&malloc_mutex);
+  scm_i_plugin_mutex_unlock (&malloc_mutex);
   if (ptr)
     return ptr;
 
index ebb7ff6..73c06cd 100644 (file)
@@ -372,6 +372,7 @@ SCM_API void scm_gc_register_root (SCM *p);
 SCM_API void scm_gc_unregister_root (SCM *p);
 SCM_API void scm_gc_register_roots (SCM *b, unsigned long n);
 SCM_API void scm_gc_unregister_roots (SCM *b, unsigned long n);
+SCM_API void scm_gc_malloc_prehistory (void);
 SCM_API int scm_init_storage (void);
 SCM_API void *scm_get_stack_base (void);
 SCM_API void scm_init_gc (void);
index c9dec66..2051fdb 100644 (file)
@@ -444,6 +444,7 @@ scm_init_guile_1 (SCM_STACKITEM *base)
 
   scm_block_gc = 1;
 
+  scm_gc_malloc_prehistory ();
   scm_threads_prehistory ();
   scm_ports_prehistory ();
   scm_smob_prehistory ();