mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
malloc: Automated part of conversion to __libc_lock
This commit is contained in:
@ -2870,7 +2870,7 @@ __libc_malloc (size_t bytes)
|
||||
}
|
||||
|
||||
if (ar_ptr != NULL)
|
||||
(void) mutex_unlock (&ar_ptr->mutex);
|
||||
__libc_lock_unlock (ar_ptr->mutex);
|
||||
|
||||
assert (!victim || chunk_is_mmapped (mem2chunk (victim)) ||
|
||||
ar_ptr == arena_for_chunk (mem2chunk (victim)));
|
||||
@ -3012,11 +3012,11 @@ __libc_realloc (void *oldmem, size_t bytes)
|
||||
return newmem;
|
||||
}
|
||||
|
||||
(void) mutex_lock (&ar_ptr->mutex);
|
||||
__libc_lock_lock (ar_ptr->mutex);
|
||||
|
||||
newp = _int_realloc (ar_ptr, oldp, oldsize, nb);
|
||||
|
||||
(void) mutex_unlock (&ar_ptr->mutex);
|
||||
__libc_lock_unlock (ar_ptr->mutex);
|
||||
assert (!newp || chunk_is_mmapped (mem2chunk (newp)) ||
|
||||
ar_ptr == arena_for_chunk (mem2chunk (newp)));
|
||||
|
||||
@ -3098,7 +3098,7 @@ _mid_memalign (size_t alignment, size_t bytes, void *address)
|
||||
}
|
||||
|
||||
if (ar_ptr != NULL)
|
||||
(void) mutex_unlock (&ar_ptr->mutex);
|
||||
__libc_lock_unlock (ar_ptr->mutex);
|
||||
|
||||
assert (!p || chunk_is_mmapped (mem2chunk (p)) ||
|
||||
ar_ptr == arena_for_chunk (mem2chunk (p)));
|
||||
@ -3219,7 +3219,7 @@ __libc_calloc (size_t n, size_t elem_size)
|
||||
}
|
||||
|
||||
if (av != NULL)
|
||||
(void) mutex_unlock (&av->mutex);
|
||||
__libc_lock_unlock (av->mutex);
|
||||
|
||||
/* Allocation failed even after a retry. */
|
||||
if (mem == 0)
|
||||
@ -3835,7 +3835,7 @@ _int_free (mstate av, mchunkptr p, int have_lock)
|
||||
errstr = "free(): invalid pointer";
|
||||
errout:
|
||||
if (!have_lock && locked)
|
||||
(void) mutex_unlock (&av->mutex);
|
||||
__libc_lock_unlock (av->mutex);
|
||||
malloc_printerr (check_action, errstr, chunk2mem (p), av);
|
||||
return;
|
||||
}
|
||||
@ -3874,7 +3874,7 @@ _int_free (mstate av, mchunkptr p, int have_lock)
|
||||
after getting the lock. */
|
||||
if (have_lock
|
||||
|| ({ assert (locked == 0);
|
||||
mutex_lock(&av->mutex);
|
||||
__libc_lock_lock (av->mutex);
|
||||
locked = 1;
|
||||
chunk_at_offset (p, size)->size <= 2 * SIZE_SZ
|
||||
|| chunksize (chunk_at_offset (p, size)) >= av->system_mem;
|
||||
@ -3885,7 +3885,7 @@ _int_free (mstate av, mchunkptr p, int have_lock)
|
||||
}
|
||||
if (! have_lock)
|
||||
{
|
||||
(void)mutex_unlock(&av->mutex);
|
||||
__libc_lock_unlock (av->mutex);
|
||||
locked = 0;
|
||||
}
|
||||
}
|
||||
@ -3931,7 +3931,7 @@ _int_free (mstate av, mchunkptr p, int have_lock)
|
||||
|
||||
else if (!chunk_is_mmapped(p)) {
|
||||
if (! have_lock) {
|
||||
(void)mutex_lock(&av->mutex);
|
||||
__libc_lock_lock (av->mutex);
|
||||
locked = 1;
|
||||
}
|
||||
|
||||
@ -4064,7 +4064,7 @@ _int_free (mstate av, mchunkptr p, int have_lock)
|
||||
|
||||
if (! have_lock) {
|
||||
assert (locked);
|
||||
(void)mutex_unlock(&av->mutex);
|
||||
__libc_lock_unlock (av->mutex);
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -4531,9 +4531,9 @@ __malloc_trim (size_t s)
|
||||
mstate ar_ptr = &main_arena;
|
||||
do
|
||||
{
|
||||
(void) mutex_lock (&ar_ptr->mutex);
|
||||
__libc_lock_lock (ar_ptr->mutex);
|
||||
result |= mtrim (ar_ptr, s);
|
||||
(void) mutex_unlock (&ar_ptr->mutex);
|
||||
__libc_lock_unlock (ar_ptr->mutex);
|
||||
|
||||
ar_ptr = ar_ptr->next;
|
||||
}
|
||||
@ -4662,9 +4662,9 @@ __libc_mallinfo (void)
|
||||
ar_ptr = &main_arena;
|
||||
do
|
||||
{
|
||||
(void) mutex_lock (&ar_ptr->mutex);
|
||||
__libc_lock_lock (ar_ptr->mutex);
|
||||
int_mallinfo (ar_ptr, &m);
|
||||
(void) mutex_unlock (&ar_ptr->mutex);
|
||||
__libc_lock_unlock (ar_ptr->mutex);
|
||||
|
||||
ar_ptr = ar_ptr->next;
|
||||
}
|
||||
@ -4694,7 +4694,7 @@ __malloc_stats (void)
|
||||
struct mallinfo mi;
|
||||
|
||||
memset (&mi, 0, sizeof (mi));
|
||||
(void) mutex_lock (&ar_ptr->mutex);
|
||||
__libc_lock_lock (ar_ptr->mutex);
|
||||
int_mallinfo (ar_ptr, &mi);
|
||||
fprintf (stderr, "Arena %d:\n", i);
|
||||
fprintf (stderr, "system bytes = %10u\n", (unsigned int) mi.arena);
|
||||
@ -4705,7 +4705,7 @@ __malloc_stats (void)
|
||||
#endif
|
||||
system_b += mi.arena;
|
||||
in_use_b += mi.uordblks;
|
||||
(void) mutex_unlock (&ar_ptr->mutex);
|
||||
__libc_lock_unlock (ar_ptr->mutex);
|
||||
ar_ptr = ar_ptr->next;
|
||||
if (ar_ptr == &main_arena)
|
||||
break;
|
||||
@ -4733,7 +4733,7 @@ __libc_mallopt (int param_number, int value)
|
||||
|
||||
if (__malloc_initialized < 0)
|
||||
ptmalloc_init ();
|
||||
(void) mutex_lock (&av->mutex);
|
||||
__libc_lock_lock (av->mutex);
|
||||
/* Ensure initialization/consolidation */
|
||||
malloc_consolidate (av);
|
||||
|
||||
@ -4811,7 +4811,7 @@ __libc_mallopt (int param_number, int value)
|
||||
}
|
||||
break;
|
||||
}
|
||||
(void) mutex_unlock (&av->mutex);
|
||||
__libc_lock_unlock (av->mutex);
|
||||
return res;
|
||||
}
|
||||
libc_hidden_def (__libc_mallopt)
|
||||
@ -5058,7 +5058,7 @@ __malloc_info (int options, FILE *fp)
|
||||
} sizes[NFASTBINS + NBINS - 1];
|
||||
#define nsizes (sizeof (sizes) / sizeof (sizes[0]))
|
||||
|
||||
mutex_lock (&ar_ptr->mutex);
|
||||
__libc_lock_lock (ar_ptr->mutex);
|
||||
|
||||
for (size_t i = 0; i < NFASTBINS; ++i)
|
||||
{
|
||||
@ -5117,7 +5117,7 @@ __malloc_info (int options, FILE *fp)
|
||||
avail += sizes[NFASTBINS - 1 + i].total;
|
||||
}
|
||||
|
||||
mutex_unlock (&ar_ptr->mutex);
|
||||
__libc_lock_unlock (ar_ptr->mutex);
|
||||
|
||||
total_nfastblocks += nfastblocks;
|
||||
total_fastavail += fastavail;
|
||||
|
Reference in New Issue
Block a user