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

Reverted changed from 2005/01/24 19:14:54, which was a commit to the

wrong branch.  Sorry.
This commit is contained in:
Marius Vollmer 2005-01-24 23:41:14 +00:00
parent a54a94b397
commit 76da80e788
34 changed files with 1125 additions and 1296 deletions

View file

@ -110,21 +110,21 @@ scm_realloc (void *mem, size_t size)
if (ptr)
return ptr;
scm_pthread_mutex_lock (&scm_i_sweep_mutex);
scm_rec_mutex_lock (&scm_i_sweep_mutex);
scm_i_sweep_all_segments ("realloc");
SCM_SYSCALL (ptr = realloc (mem, size));
if (ptr)
{
pthread_mutex_unlock (&scm_i_sweep_mutex);
scm_rec_mutex_unlock (&scm_i_sweep_mutex);
return ptr;
}
scm_igc ("realloc");
scm_i_sweep_all_segments ("realloc");
pthread_mutex_unlock (&scm_i_sweep_mutex);
scm_rec_mutex_unlock (&scm_i_sweep_mutex);
SCM_SYSCALL (ptr = realloc (mem, size));
if (ptr)
@ -180,10 +180,10 @@ scm_strdup (const char *str)
static void
decrease_mtrigger (size_t size, const char * what)
{
pthread_mutex_lock (&scm_i_gc_admin_mutex);
scm_i_plugin_mutex_lock (&scm_i_gc_admin_mutex);
scm_mallocated -= size;
scm_gc_malloc_collected += size;
pthread_mutex_unlock (&scm_i_gc_admin_mutex);
scm_i_plugin_mutex_unlock (&scm_i_gc_admin_mutex);
}
static void
@ -192,7 +192,7 @@ increase_mtrigger (size_t size, const char *what)
size_t mallocated = 0;
int overflow = 0, triggered = 0;
pthread_mutex_lock (&scm_i_gc_admin_mutex);
scm_i_plugin_mutex_lock (&scm_i_gc_admin_mutex);
if (ULONG_MAX - size < scm_mallocated)
overflow = 1;
else
@ -202,10 +202,12 @@ increase_mtrigger (size_t size, const char *what)
if (scm_mallocated > scm_mtrigger)
triggered = 1;
}
pthread_mutex_unlock (&scm_i_gc_admin_mutex);
scm_i_plugin_mutex_unlock (&scm_i_gc_admin_mutex);
if (overflow)
scm_memory_error ("Overflow of scm_mallocated: too much memory in use.");
{
scm_memory_error ("Overflow of scm_mallocated: too much memory in use.");
}
/*
A program that uses a lot of malloced collectable memory (vectors,
@ -218,7 +220,7 @@ increase_mtrigger (size_t size, const char *what)
unsigned long prev_alloced;
float yield;
scm_pthread_mutex_lock (&scm_i_sweep_mutex);
scm_rec_mutex_lock (&scm_i_sweep_mutex);
prev_alloced = mallocated;
scm_igc (what);
@ -263,7 +265,7 @@ increase_mtrigger (size_t size, const char *what)
#endif
}
pthread_mutex_unlock (&scm_i_sweep_mutex);
scm_rec_mutex_unlock (&scm_i_sweep_mutex);
}
}