aboutsummaryrefslogtreecommitdiff
path: root/malloc
diff options
context:
space:
mode:
authorDJ Delorie <dj@delorie.com>2016-11-08 23:47:08 -0500
committerDJ Delorie <dj@delorie.com>2016-11-08 23:47:08 -0500
commit8926b32dbadf193f779e534678233ee7a965dacb (patch)
tree44feee87ca5d3709a4438e834f2871d9206a1bb3 /malloc
parent4f460c8944fa682376dfe63ceb39ac4a5a031232 (diff)
downloadglibc-8926b32dbadf193f779e534678233ee7a965dacb.tar.xz
glibc-8926b32dbadf193f779e534678233ee7a965dacb.zip
More merge-related tweaks
* add --enable-experimental-malloc/--disable-experimental-malloc (default: enabled) * syntax errors related to new lock macros * add some missing #if USE_TCACHE pairs * Undo test tweak to environment variable scanner
Diffstat (limited to 'malloc')
-rw-r--r--malloc/Makefile8
-rw-r--r--malloc/arena.c12
-rw-r--r--malloc/malloc.c7
3 files changed, 14 insertions, 13 deletions
diff --git a/malloc/Makefile b/malloc/Makefile
index f34c2a75ba..2b0c3da501 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -76,10 +76,6 @@ $(objpfx)trace_run: $(objpfx)trace_run.o
$(objpfx)trace_dump: $(objpfx)trace_dump.o
$(LINK.o) -o $@ $(objpfx)trace_dump.o
-ifeq (${CXX},)
-CXX = g++
-endif
-
$(objpfx)trace2wl: $(objpfx)trace2wl.o
$(LINK.o) -o $@ $(objpfx)trace2wl.o
@@ -88,6 +84,10 @@ $(objpfx)tst-malloc-thread-exit: $(shared-thread-library)
$(objpfx)tst-malloc-thread-fail: $(shared-thread-library)
$(objpfx)tst-malloc-fork-deadlock: $(shared-thread-library)
+ifeq ($(experimental-malloc),yes)
+CPPFLAGS-malloc.c += -DUSE_TCACHE
+endif
+
# Export the __malloc_initialize_hook variable to libc.so.
LDFLAGS-tst-mallocstate = -rdynamic
diff --git a/malloc/arena.c b/malloc/arena.c
index ada1a7245e..0a86da6513 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -229,10 +229,11 @@ next_env_entry (char ***position)
/* Save current position for next visit. */
*position = ++current;
+
break;
}
- *position = ++current;
+ ++current;
}
return result;
@@ -277,9 +278,7 @@ ptmalloc_init (void)
char **runp = _environ;
char *envline;
- while (*runp)
- {
- if (__builtin_expect ((envline = next_env_entry (&runp)) != NULL,
+ while (__builtin_expect ((envline = next_env_entry (&runp)) != NULL,
0))
{
size_t len = strcspn (envline, "=");
@@ -320,12 +319,15 @@ ptmalloc_init (void)
if (memcmp (envline, "ARENA_TEST", 10) == 0)
__libc_mallopt (M_ARENA_TEST, atoi (&envline[11]));
}
+#if USE_TCACHE
if (!__builtin_expect (__libc_enable_secure, 0))
{
if (memcmp (envline, "TCACHE_MAX", 10) == 0)
__libc_mallopt (M_TCACHE_MAX, atoi (&envline[11]));
}
+#endif
break;
+#if USE_TCACHE
case 12:
if (!__builtin_expect (__libc_enable_secure, 0))
{
@@ -333,6 +335,7 @@ ptmalloc_init (void)
__libc_mallopt (M_TCACHE_COUNT, atoi (&envline[13]));
}
break;
+#endif
case 15:
if (!__builtin_expect (__libc_enable_secure, 0))
{
@@ -346,7 +349,6 @@ ptmalloc_init (void)
break;
}
}
- }
}
if (s && s[0])
{
diff --git a/malloc/malloc.c b/malloc/malloc.c
index bd8a1d4bb8..0eabcd8430 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1068,7 +1068,7 @@ typedef struct __malloc_trace_map_entry_s {
#define TRACE_COUNT_TO_MAPPING_IDX(count) ((count) % TRACE_N_PER_MAPPING)
/* Global mutex for the trace buffer tree itself. */
-libc_lock_define_initialized (static, __malloc_trace_mutex);
+__libc_lock_define_initialized (static, __malloc_trace_mutex);
/* Global counter, "full" when equal to TRACE_MAX_COUNT. Points to
the next available slot, so POST-INCREMENT it. */
@@ -3358,7 +3358,7 @@ tcache_thread_freeres (void)
{
if (tcache.initted == 1)
{
- libc_lock_lock (tcache_mutex);
+ __libc_lock_lock (tcache_mutex);
tcache.initted = 2;
if (tcache.next)
tcache.next->prev = tcache.prev;
@@ -3366,7 +3366,7 @@ tcache_thread_freeres (void)
tcache.prev->next = tcache.next;
else
tcache_list = tcache.next;
- libc_lock_unlock (tcache_mutex);
+ __libc_lock_unlock (tcache_mutex);
}
}
text_set_element (__libc_thread_subfreeres, tcache_thread_freeres);
@@ -4206,7 +4206,6 @@ _int_malloc (mstate av, size_t bytes)
if ((unsigned long) (nb) <= (unsigned long) (get_max_fast ()))
{
-
idx = fastbin_index (nb);
mfastbinptr *fb = &fastbin (av, idx);
mchunkptr pp = *fb;