mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
* malloc/malloc.c (malloc_info): New function.
* malloc/malloc.h: Declare it. * malloc/Versions: Export malloc_info for GLIBC_2.10. * resolv/nss_dns/dns-host.c (getanswer_r): Use strcasecmp
This commit is contained in:
@ -1,5 +1,9 @@
|
|||||||
2009-04-08 Ulrich Drepper <drepper@redhat.com>
|
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
|
* sysdeps/unix/sysv/linux/preadv64.c (PREAD): Use __libc_pread64
|
||||||
to avoid PLT slot.
|
to avoid PLT slot.
|
||||||
|
|
||||||
@ -18,9 +22,8 @@
|
|||||||
* sysdeps/unix/sysv/linux/kernel-features.h: Power also has
|
* sysdeps/unix/sysv/linux/kernel-features.h: Power also has
|
||||||
preadv/pwritev in 2.6.30.
|
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.
|
instead of __strcasecmp.
|
||||||
* resolv/nss_dns/dns-host.c (getanswer_r): Likewise.
|
|
||||||
|
|
||||||
* string/stratcliff.c (do_test): Add memchr tests..
|
* string/stratcliff.c (do_test): Add memchr tests..
|
||||||
* wcsmbs/wcsatcliff.c (MEMCHR): Define.
|
* wcsmbs/wcsatcliff.c (MEMCHR): Define.
|
||||||
|
4
NEWS
4
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.
|
Copyright (C) 1992-2008, 2009 Free Software Foundation, Inc.
|
||||||
See the end for copying conditions.
|
See the end for copying conditions.
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ using `glibc' in the "product" field.
|
|||||||
|
|
||||||
Version 2.10
|
Version 2.10
|
||||||
|
|
||||||
* New interfaces: preadv, preadv64, pwritev, pwritev64
|
* New interfaces: preadv, preadv64, pwritev, pwritev64, malloc_info
|
||||||
Implemented by Ulrich Drepper.
|
Implemented by Ulrich Drepper.
|
||||||
|
|
||||||
* New Linux interfaces: accept4, fallocate, fallocate64.
|
* New Linux interfaces: accept4, fallocate, fallocate64.
|
||||||
|
@ -55,6 +55,9 @@ libc {
|
|||||||
# p*
|
# p*
|
||||||
posix_memalign;
|
posix_memalign;
|
||||||
}
|
}
|
||||||
|
GLIBC_2.10 {
|
||||||
|
malloc_info;
|
||||||
|
}
|
||||||
GLIBC_PRIVATE {
|
GLIBC_PRIVATE {
|
||||||
# Internal startup hook for libpthread.
|
# Internal startup hook for libpthread.
|
||||||
__libc_malloc_pthread_startup;
|
__libc_malloc_pthread_startup;
|
||||||
|
146
malloc/malloc.c
146
malloc/malloc.c
@ -6219,6 +6219,152 @@ __posix_memalign (void **memptr, size_t alignment, size_t size)
|
|||||||
}
|
}
|
||||||
weak_alias (__posix_memalign, posix_memalign)
|
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_calloc, __calloc) weak_alias (__libc_calloc, calloc)
|
||||||
strong_alias (__libc_free, __cfree) weak_alias (__libc_free, cfree)
|
strong_alias (__libc_free, __cfree) weak_alias (__libc_free, cfree)
|
||||||
strong_alias (__libc_free, __free) strong_alias (__libc_free, free)
|
strong_alias (__libc_free, __free) strong_alias (__libc_free, free)
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <features.h>
|
#include <features.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
# define __malloc_ptr_t void *
|
# define __malloc_ptr_t void *
|
||||||
|
|
||||||
/* Used by GNU libc internals. */
|
/* 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. */
|
/* Prints brief summary statistics on stderr. */
|
||||||
extern void malloc_stats __MALLOC_P ((void));
|
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. */
|
/* Record the state of all malloc variables in an opaque data structure. */
|
||||||
extern void *malloc_get_state __MALLOC_P ((void));
|
extern void *malloc_get_state __MALLOC_P ((void));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user