This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v1.2] Deprecate malloc_(sg)et state.


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]