]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Updated to fedora-glibc-20090409T1422 cvs/fedora-glibc-2_9_90-15
authorJakub Jelinek <jakub@redhat.com>
Thu, 9 Apr 2009 20:47:09 +0000 (20:47 +0000)
committerJakub Jelinek <jakub@redhat.com>
Thu, 9 Apr 2009 20:47:09 +0000 (20:47 +0000)
ChangeLog
NEWS
fedora/branch.mk
fedora/glibc.spec.in
malloc/Versions
malloc/hooks.c
malloc/malloc.c
malloc/malloc.h
sysdeps/unix/sysv/linux/preadv64.c

index ce7cbdc7040e663fce0c73ae251950752b36dcf4..e3f23e35c1c31468a2c811b0e08876f54c6e2781 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-04-08  Ulrich Drepper  <drepper@redhat.com>
+
+       * malloc/malloc.c (malloc_info): New function.
+       * malloc/malloc.h: Declare it.
+       * malloc/Versions: Export malloc_info for GLIBC_2.10.
+
+       * sysdeps/unix/sysv/linux/preadv64.c (PREAD): Use __libc_pread64
+       to avoid PLT slot.
+
+       * malloc/malloc.c (_int_realloc): Add parameter with old block
+       size.  Remove duplicated test.  Don't handle mmap'ed blocks here.
+       Adjust all callers.
+       * malloc/hooks.c (realloc_check): Adjust _int_realloc call.
+
 2009-04-07  Ulrich Drepper  <drepper@redhat.com>
 
        * sysdeps/x86_64/strchrnul.S: New file.
@@ -8,9 +22,8 @@
        * sysdeps/unix/sysv/linux/kernel-features.h: Power also has
        preadv/pwritev in 2.6.30.
 
-       * resolv/res_hconf.c (_res_hconf_trim_domain): Use strcasecmp
+       * resolv/nss_dns/dns-host.c (getanswer_r): Use strcasecmp
        instead of __strcasecmp.
-       * resolv/nss_dns/dns-host.c (getanswer_r): Likewise.
 
        * string/stratcliff.c (do_test): Add memchr tests..
        * wcsmbs/wcsatcliff.c (MEMCHR): Define.
diff --git a/NEWS b/NEWS
index c50a66bb435814a06660366ae7cb3c29238265e4..74feed6f3b0b0e09b9fb8998546e0d435388c83d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU C Library NEWS -- history of user-visible changes.  2009-4-7
+GNU C Library NEWS -- history of user-visible changes.  2009-4-8
 Copyright (C) 1992-2008, 2009 Free Software Foundation, Inc.
 See the end for copying conditions.
 
@@ -7,7 +7,7 @@ using `glibc' in the "product" field.
 \f
 Version 2.10
 
-* New interfaces: preadv, preadv64, pwritev, pwritev64
+* New interfaces: preadv, preadv64, pwritev, pwritev64, malloc_info
   Implemented by Ulrich Drepper.
 
 * New Linux interfaces: accept4, fallocate, fallocate64.
index 040c0d225a24969a247c9d5fdabd28f92edb15c5..4c3dc344b6c13988d7d6f2f830bf277c3da0ed7b 100644 (file)
@@ -3,5 +3,5 @@ glibc-branch := fedora
 glibc-base := HEAD
 DIST_BRANCH := devel
 COLLECTION := dist-f8
-fedora-sync-date := 2009-04-08 16:02 UTC
-fedora-sync-tag := fedora-glibc-20090408T1602
+fedora-sync-date := 2009-04-09 14:22 UTC
+fedora-sync-tag := fedora-glibc-20090409T1422
index e388b94a1cf5399b187937b6cc31d9932eda383a..db1124fad986bfef955c6044c79a6415cbf27567 100644 (file)
@@ -19,7 +19,7 @@
 Summary: The GNU libc libraries
 Name: glibc
 Version: @glibcversion@
-Release: 14
+Release: 15
 # GPLv2+ is used in a bunch of programs, LGPLv2+ is used for libraries.
 # Things that are linked directly into dynamically linked programs
 # and shared libraries (e.g. crt files, lib*_nonshared.a) have an additional
index 0c578f95b61cdd30d7438e28b02e2f5182c4d2f4..cf0b1e559a8c4c0644ace1f33996cd0dfd8a8b02 100644 (file)
@@ -55,6 +55,9 @@ libc {
     # p*
     posix_memalign;
   }
+  GLIBC_2.10 {
+    malloc_info;
+  }
   GLIBC_PRIVATE {
     # Internal startup hook for libpthread.
     __libc_malloc_pthread_startup;
index fe89db83f48cb636bcf60be7ac49b4db9c3c20cc..72c29293d9ab8c7c47fa0bdcfe5bf89e17f1df13 100644 (file)
@@ -358,7 +358,7 @@ realloc_check(oldmem, bytes, caller)
     if (top_check() >= 0) {
       INTERNAL_SIZE_T nb;
       checked_request2size(bytes + 1, nb);
-      newmem = _int_realloc(&main_arena, oldp, nb);
+      newmem = _int_realloc(&main_arena, oldp, oldsize, nb);
     }
 #if 0 /* Erase freed memory. */
     if(newmem)
@@ -501,7 +501,7 @@ free_starter(mem, caller) Void_t* mem; const Void_t *caller;
    then the hooks are reset to 0.  */
 
 #define MALLOC_STATE_MAGIC   0x444c4541l
-#define MALLOC_STATE_VERSION (0*0x100l + 3l) /* major*0x100 + minor */
+#define MALLOC_STATE_VERSION (0*0x100l + 4l) /* major*0x100 + minor */
 
 struct malloc_save_state {
   long          magic;
@@ -521,6 +521,10 @@ struct malloc_save_state {
   unsigned long mmapped_mem;
   unsigned long max_mmapped_mem;
   int           using_malloc_checking;
+  unsigned long max_fast;
+  unsigned long arena_test;
+  unsigned long arena_max;
+  unsigned long narenas;
 };
 
 Void_t*
@@ -568,6 +572,12 @@ public_gET_STATe(void)
   ms->mmapped_mem = mp_.mmapped_mem;
   ms->max_mmapped_mem = mp_.max_mmapped_mem;
   ms->using_malloc_checking = using_malloc_checking;
+  ms->max_fast = get_max_fast();
+#ifdef PER_THREAD
+  ms->arena_test = mp_.arena_test;
+  ms->arena_max = mp_.arena_max;
+  ms->narenas = narenas;
+#endif
   (void)mutex_unlock(&main_arena.mutex);
   return (Void_t*)ms;
 }
@@ -587,7 +597,10 @@ public_sET_STATe(Void_t* msptr)
   (void)mutex_lock(&main_arena.mutex);
   /* There are no fastchunks.  */
   clear_fastchunks(&main_arena);
-  set_max_fast(DEFAULT_MXFAST);
+  if (ms->version >= 4)
+    set_max_fast(ms->max_fast);
+  else
+    set_max_fast(64);  /* 64 used to be the value we always used.  */
   for (i=0; i<NFASTBINS; ++i)
     fastbin (&main_arena, i) = 0;
   for (i=0; i<BINMAPSIZE; ++i)
@@ -663,6 +676,13 @@ public_sET_STATe(Void_t* msptr)
       using_malloc_checking = 0;
     }
   }
+  if (ms->version >= 4) {
+#ifdef PER_THREAD
+    mp_.arena_test = ms->arena_test;
+    mp_.arena_max = ms->arena_max;
+    narenas = ms->narenas;
+#endif
+  }
   check_malloc_state(&main_arena);
 
   (void)mutex_unlock(&main_arena.mutex);
index bb7ea36c802b56b3593d9b3cff5531586c012238..17e4e03bac34e0ad909e9acbe96dd4a914b6eb4f 100644 (file)
@@ -1586,7 +1586,8 @@ static void     _int_free(mstate, mchunkptr, int);
 #else
 static void     _int_free(mstate, mchunkptr);
 #endif
-static Void_t*  _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T);
+static Void_t*  _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T,
+                            INTERNAL_SIZE_T);
 static Void_t*  _int_memalign(mstate, size_t, size_t);
 static Void_t*  _int_valloc(mstate, size_t);
 static Void_t*  _int_pvalloc(mstate, size_t);
@@ -3778,7 +3779,7 @@ public_rEALLOc(Void_t* oldmem, size_t bytes)
   tsd_setspecific(arena_key, (Void_t *)ar_ptr);
 #endif
 
-  newp = _int_realloc(ar_ptr, oldp, nb);
+  newp = _int_realloc(ar_ptr, oldp, oldsize, nb);
 
   (void)mutex_unlock(&ar_ptr->mutex);
   assert(!newp || chunk_is_mmapped(mem2chunk(newp)) ||
@@ -5102,7 +5103,8 @@ static void malloc_consolidate(av) mstate av;
 */
 
 Void_t*
-_int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T nb)
+_int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize,
+            INTERNAL_SIZE_T nb)
 {
   mchunkptr        newp;            /* chunk to return */
   INTERNAL_SIZE_T  newsize;         /* its size */
@@ -5123,28 +5125,25 @@ _int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T nb)
 
   const char *errstr = NULL;
 
-  /* Simple tests for old block integrity.  */
-  if (__builtin_expect (misaligned_chunk (oldp), 0))
-    {
-      errstr = "realloc(): invalid pointer";
-    errout:
-      malloc_printerr (check_action, errstr, chunk2mem(oldp));
-      return NULL;
-    }
-
   /* oldmem size */
-  const INTERNAL_SIZE_T oldsize = chunksize(oldp);
-
   if (__builtin_expect (oldp->size <= 2 * SIZE_SZ, 0)
       || __builtin_expect (oldsize >= av->system_mem, 0))
     {
       errstr = "realloc(): invalid old size";
-      goto errout;
+    errout:
+      malloc_printerr (check_action, errstr, chunk2mem(oldp));
+      return NULL;
     }
 
   check_inuse_chunk(av, oldp);
 
-  if (!chunk_is_mmapped(oldp)) {
+  /* All callers already filter out mmap'ed chunks.  */
+#if 0
+  if (!chunk_is_mmapped(oldp))
+#else
+  assert (!chunk_is_mmapped(oldp));
+#endif
+  {
 
     next = chunk_at_offset(oldp, oldsize);
     INTERNAL_SIZE_T nextsize = chunksize(next);
@@ -5271,6 +5270,7 @@ _int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T nb)
     return chunk2mem(newp);
   }
 
+#if 0
   /*
     Handle mmap cases
   */
@@ -5339,6 +5339,7 @@ _int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T nb)
     return 0;
 #endif
   }
+#endif
 }
 
 /*
@@ -6218,6 +6219,152 @@ __posix_memalign (void **memptr, size_t alignment, size_t size)
 }
 weak_alias (__posix_memalign, posix_memalign)
 
+
+int
+malloc_info (int options, FILE *fp)
+{
+  /* For now, at least.  */
+  if (options != 0)
+    return EINVAL;
+
+  int n = 0;
+  size_t total_nblocks = 0;
+  size_t total_nfastblocks = 0;
+  size_t total_avail = 0;
+  size_t total_fastavail = 0;
+
+  void mi_arena (mstate ar_ptr)
+  {
+    fprintf (fp, "<heap nr=\"%d\">\n<sizes>\n", n++);
+
+    size_t nblocks = 0;
+    size_t nfastblocks = 0;
+    size_t avail = 0;
+    size_t fastavail = 0;
+    struct
+    {
+      size_t from;
+      size_t to;
+      size_t total;
+      size_t count;
+    } sizes[NFASTBINS + NBINS - 1];
+#define nsizes (sizeof (sizes) / sizeof (sizes[0]))
+
+    mutex_lock (&ar_ptr->mutex);
+
+    for (size_t i = 0; i < NFASTBINS; ++i)
+      {
+       mchunkptr p = fastbin (ar_ptr, i);
+       if (p != NULL)
+         {
+           size_t nthissize = 0;
+           size_t thissize = chunksize (p);
+
+           while (p != NULL)
+             {
+               ++nthissize;
+               p = p->fd;
+             }
+
+           fastavail += nthissize * thissize;
+           nfastblocks += nthissize;
+           sizes[i].from = thissize - (MALLOC_ALIGNMENT - 1);
+           sizes[i].to = thissize;
+           sizes[i].count = nthissize;
+         }
+       else
+         sizes[i].from = sizes[i].to = sizes[i].count = 0;
+
+       sizes[i].total = sizes[i].count * sizes[i].to;
+      }
+
+    mbinptr bin = bin_at (ar_ptr, 1);
+    struct malloc_chunk *r = bin->fd;
+    while (r != bin)
+      {
+       ++sizes[NFASTBINS].count;
+       sizes[NFASTBINS].total += r->size;
+       sizes[NFASTBINS].from = MIN (sizes[NFASTBINS].from, r->size);
+       sizes[NFASTBINS].to = MAX (sizes[NFASTBINS].to, r->size);
+       r = r->fd;
+      }
+    nblocks += sizes[NFASTBINS].count;
+    avail += sizes[NFASTBINS].total;
+
+    for (size_t i = 2; i < NBINS; ++i)
+      {
+       bin = bin_at (ar_ptr, i);
+       r = bin->fd;
+       sizes[NFASTBINS - 1 + i].from = ~((size_t) 0);
+       sizes[NFASTBINS - 1 + i].to = sizes[NFASTBINS - 1 + i].total
+         = sizes[NFASTBINS - 1 + i].count = 0;
+
+       while (r != bin)
+         {
+           ++sizes[NFASTBINS - 1 + i].count;
+           sizes[NFASTBINS - 1 + i].total += r->size;
+           sizes[NFASTBINS - 1 + i].from = MIN (sizes[NFASTBINS - 1 + i].from,
+                                                r->size);
+           sizes[NFASTBINS - 1 + i].to = MAX (sizes[NFASTBINS - 1 + i].to,
+                                              r->size);
+
+           r = r->fd;
+         }
+
+       if (sizes[NFASTBINS - 1 + i].count == 0)
+         sizes[NFASTBINS - 1 + i].from = 0;
+       nblocks += sizes[NFASTBINS - 1 + i].count;
+       avail += sizes[NFASTBINS - 1 + i].total;
+      }
+
+    mutex_unlock (&ar_ptr->mutex);
+
+    total_nfastblocks += nfastblocks;
+    total_fastavail += fastavail;
+
+    total_nblocks += nblocks;
+    total_avail += avail;
+
+    for (size_t i = 0; i < nsizes; ++i)
+      if (sizes[i].count != 0 && i != NFASTBINS)
+       fprintf (fp, "\
+<size from=\"%zu\" to=\"%zu\" total=\"%zu\" count=\"%zu\"/>\n",
+                sizes[i].from, sizes[i].to, sizes[i].total, sizes[i].count);
+
+    if (sizes[NFASTBINS].count != 0)
+      fprintf (fp, "\
+<unsorted from=\"%zu\" to=\"%zu\" total=\"%zu\" count=\"%zu\"/>\n",
+              sizes[NFASTBINS].from, sizes[NFASTBINS].to,
+              sizes[NFASTBINS].total, sizes[NFASTBINS].count);
+
+    fprintf (fp,
+            "</sizes>\n<total type=\"fast\" count=\"%zu\" size=\"%zu\"/>\n"
+            "<total type=\"rest\" count=\"%zu\" size=\"%zu\"/>\n"
+            "</heap>\n",
+            nfastblocks, fastavail, nblocks, avail);
+  }
+
+  fputs ("<malloc version=\"1\">\n", fp);
+
+  /* Iterate over all arenas currently in use.  */
+  mstate ar_ptr = &main_arena;
+  do
+    {
+      mi_arena (ar_ptr);
+      ar_ptr = ar_ptr->next;
+    }
+  while (ar_ptr != &main_arena);
+
+  fprintf (fp,
+          "<total type=\"fast\" count=\"%zu\" size=\"%zu\"/>\n"
+          "<total type=\"rest\" count=\"%zu\" size=\"%zu\"/>\n"
+          "</malloc>\n",
+          total_nfastblocks, total_fastavail, total_nblocks, total_avail);
+
+  return 0;
+}
+
+
 strong_alias (__libc_calloc, __calloc) weak_alias (__libc_calloc, calloc)
 strong_alias (__libc_free, __cfree) weak_alias (__libc_free, cfree)
 strong_alias (__libc_free, __free) strong_alias (__libc_free, free)
index 2c0ee35c4eced6c1bf4d394cbefeb9475be0213d..d0aedc0cdf2cbe913a91f1718026a69de48d8b53 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <features.h>
 #include <stddef.h>
+#include <stdio.h>
 # define __malloc_ptr_t  void *
 
 /* Used by GNU libc internals. */
@@ -144,6 +145,9 @@ extern size_t malloc_usable_size __MALLOC_P ((void *__ptr));
 /* Prints brief summary statistics on stderr. */
 extern void malloc_stats __MALLOC_P ((void));
 
+/* Output information about state of allocator to stream FP.  */
+extern int malloc_info (int __options, FILE *__fp);
+
 /* Record the state of all malloc variables in an opaque data structure. */
 extern void *malloc_get_state __MALLOC_P ((void));
 
index 739df0025707625e01c8ad2817a406108b2ef087..936ff1426c4f292bf84fa856044301f5e50649c1 100644 (file)
@@ -1,6 +1,6 @@
 #define PREADV preadv64
 #define PREADV_REPLACEMENT __atomic_preadv64_replacement
-#define PREAD __pread64
+#define PREAD __libc_pread64
 #define OFF_T off64_t
 
 #include "preadv.c"