]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
More merge-related tweaks
authorDJ Delorie <dj@delorie.com>
Wed, 9 Nov 2016 04:47:08 +0000 (23:47 -0500)
committerDJ Delorie <dj@delorie.com>
Wed, 9 Nov 2016 04:47:08 +0000 (23:47 -0500)
* 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

config.make.in
configure
configure.ac
malloc/Makefile
malloc/arena.c
malloc/malloc.c

index 04a8b3ed7f06f2b244c07f75ae6f6f328c5b1a3d..86717fea07ebe2d94172e3c9e960af1da4db7f82 100644 (file)
@@ -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.
index e80e0ad56c3b025614cb7125ed79698ffe371d46..de224a9b444755bbb58cc4c8b1e5ccd5816518a4 100755 (executable)
--- a/configure
+++ b/configure
@@ -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
index a64aeb9979a53cd7f69c20f6f38db75c7a1bdf49..9b1c552762f4010cc56a249f3f7f51060837a6bf 100644 (file)
@@ -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]),
index f34c2a75baba67eec2f4ba31390bded5d6b260b9..2b0c3da501b969c0bc9514f032c43f02ac2f6bf3 100644 (file)
@@ -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
 
index ada1a7245e183990d47820599eff9412ae701b3c..0a86da6513c5dd8cdea0e62afe70ffe8edfb533e 100644 (file)
@@ -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])
     {
index bd8a1d4bb882c416b37c2fa9c12dab94a0ca4962..0eabcd8430c5136b7201500bcd51c038237dc6b9 100644 (file)
@@ -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;