1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 09:10:22 +02:00

* gc-malloc.c, gc.h (scm_gc_malloc_prehistory): New function.

* 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.
This commit is contained in:
Mikael Djurfeldt 2002-12-10 20:25:26 +00:00
parent 3cdde9d667
commit 960c408c04
4 changed files with 14 additions and 4 deletions

View 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.

View 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;

View 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);

View 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 ();