This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v1.2] Deprecate malloc_(sg)et state.
- From: Roland McGrath <roland at hack dot frob dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, libc-alpha at sourceware dot org
- Date: Fri, 16 May 2014 13:51:49 -0700 (PDT)
- Subject: Re: [PATCH v1.2] Deprecate malloc_(sg)et state.
- Authentication-results: sourceware.org; auth=none
- References: <20140304123542 dot GA12375 at domone dot podge> <20140314170541 dot EF58A74495 at topped-with-meat dot com> <20140324092658 dot GA3973 at domone dot podge> <20140324221550 dot 649EA74484 at topped-with-meat dot com> <20140428110349 dot GA23227 at domone dot podge> <Pine dot LNX dot 4 dot 64 dot 1404281454271 dot 16435 at digraph dot polyomino dot org dot uk> <20140428150007 dot GA5597 at domone dot podge> <Pine dot LNX dot 4 dot 64 dot 1404281506290 dot 16435 at digraph dot polyomino dot org dot uk> <20140516184537 dot GA5856 at domone dot podge>
You need to remove the declarations from malloc.h, and add a NEWS item.
> --- a/malloc/hooks.c
> +++ b/malloc/hooks.c
> @@ -474,6 +474,8 @@ struct malloc_save_state
> unsigned long narenas;
> };
>
> +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_20)
> +
> void *
> __malloc_get_state (void)
> {
> @@ -644,6 +646,7 @@ __malloc_set_state (void *msptr)
> (void) mutex_unlock (&main_arena.mutex);
> return 0;
> }
> +#endif
Put the compat_symbol uses right here.
They can use the __ names on the lhs.
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -5181,9 +5181,16 @@ strong_alias (__libc_mallopt, __mallopt) weak_alias (__libc_mallopt, mallopt)
> weak_alias (__malloc_stats, malloc_stats)
> weak_alias (__malloc_usable_size, malloc_usable_size)
> weak_alias (__malloc_trim, malloc_trim)
> +
> +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_20)
> +
> weak_alias (__malloc_get_state, malloc_get_state)
> weak_alias (__malloc_set_state, malloc_set_state)
Remove these aliases entirely.
> diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
> index 69c4500..709aaba 100644
> --- a/malloc/tst-mallocstate.c
> +++ b/malloc/tst-mallocstate.c
> @@ -16,9 +16,16 @@
> License along with the GNU C Library; if not, see
> <http://www.gnu.org/licenses/>. */
>
> +#define _GNU_SOURCE
> +#include <dlfcn.h>
> #include <errno.h>
> #include <stdio.h>
> #include "malloc.h"
> +#include <abi-versions.h>
The whole body of the test needs to be conditionalized so it doesn't do
anything for 2.20+-only configurations. Let's extend shlib-compat.h with a
new macro TEST_SHLIB_COMPAT that is like SHLIB_COMPAT but does not depend
on SHARED or IS_IN_*.
> +#define STRINGIFY(x) #x
> +#define STR_GLIBC_2_0 STRINGIFY (VERSION_libc_GLIBC_2_0)
Let's add a proper macro for this rather than doing this hack.
shlib-compat.h is as good a place as any for it (unless/until we
decide to make a public API for this). Something like:
SHLIB_VERSION (libc, GLIBC_2_0)
> + void *(*malloc_get_state)();
> + void *(*malloc_set_state)(void ());
void (*malloc_get_state) (void)
int (*malloc_set_state) (void *)
and use C99 defining initializations rather than separate definitions.
> + malloc_get_state = dlvsym (RTLD_NEXT, "malloc_get_state", STR_GLIBC_2_0);
> + malloc_set_state = dlvsym (RTLD_NEXT, "malloc_set_state", STR_GLIBC_2_0);
You want RTLD_DEFAULT, not RTLD_NEXT.