diff options
author | DJ Delorie <dj@delorie.com> | 2016-11-08 23:47:08 -0500 |
---|---|---|
committer | DJ Delorie <dj@delorie.com> | 2016-11-08 23:47:08 -0500 |
commit | 8926b32dbadf193f779e534678233ee7a965dacb (patch) | |
tree | 44feee87ca5d3709a4438e834f2871d9206a1bb3 | |
parent | 4f460c8944fa682376dfe63ceb39ac4a5a031232 (diff) |
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
-rw-r--r-- | config.make.in | 2 | ||||
-rwxr-xr-x | configure | 13 | ||||
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | malloc/Makefile | 8 | ||||
-rw-r--r-- | malloc/arena.c | 12 | ||||
-rw-r--r-- | malloc/malloc.c | 7 |
6 files changed, 36 insertions, 13 deletions
diff --git a/config.make.in b/config.make.in index 04a8b3ed7f..86717fea07 100644 --- a/config.make.in +++ b/config.make.in @@ -74,6 +74,8 @@ multi-arch = @multi_arch@ mach-interface-list = @mach_interface_list@ +experimental-malloc = @experimental_malloc@ + nss-crypt = @libc_cv_nss_crypt@ # Configuration options. @@ -666,6 +666,7 @@ build_pt_chown build_nscd link_obsolete_rpc libc_cv_nss_crypt +experimental_malloc enable_werror all_warnings force_install @@ -770,6 +771,7 @@ enable_kernel enable_all_warnings enable_werror enable_multi_arch +enable_experimental_malloc enable_nss_crypt enable_obsolete_rpc enable_systemtap @@ -1436,6 +1438,8 @@ Optional Features: --disable-werror do not build with -Werror --enable-multi-arch enable single DSO with optimizations for multiple architectures + --disable-experimental-malloc + disable experimental malloc features --enable-nss-crypt enable libcrypt to use nss --enable-obsolete-rpc build and install the obsolete RPC code for link-time usage @@ -3492,6 +3496,15 @@ else fi +# Check whether --enable-experimental-malloc was given. +if test "${enable_experimental_malloc+set}" = set; then : + enableval=$enable_experimental_malloc; experimental_malloc=$enableval +else + experimental_malloc=yes +fi + + + # Check whether --enable-nss-crypt was given. if test "${enable_nss_crypt+set}" = set; then : enableval=$enable_nss_crypt; nss_crypt=$enableval diff --git a/configure.ac b/configure.ac index a64aeb9979..9b1c552762 100644 --- a/configure.ac +++ b/configure.ac @@ -301,6 +301,13 @@ AC_ARG_ENABLE([multi-arch], [multi_arch=$enableval], [multi_arch=default]) +AC_ARG_ENABLE([experimental-malloc], + AC_HELP_STRING([--disable-experimental-malloc], + [disable experimental malloc features]), + [experimental_malloc=$enableval], + [experimental_malloc=yes]) +AC_SUBST(experimental_malloc) + AC_ARG_ENABLE([nss-crypt], AC_HELP_STRING([--enable-nss-crypt], [enable libcrypt to use nss]), 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; |