[PATCH] Deprecate malloc_(sg)et state.
Adhemerval Zanella
azanella@linux.vnet.ibm.com
Fri Mar 14 14:11:00 GMT 2014
On 04-03-2014 09:35, OndÅej BÃlka wrote:
> Hi,
>
> I asked at emacs-devel how much are these needed.
>
> It turned out that there is already a configure check to use alternative
> when malloc_set_state is not available. Replacement is bit slower but
> there was agreement that improving malloc has higher priority.
I would like to see this function deprecated, it will allows up to finally move on
https://sourceware.org/bugzilla/show_bug.cgi?id=6527
>
> See following thread:
>
> http://lists.gnu.org/archive/html/emacs-devel/2014-02/msg00541.html
>
>
> What needs to be added to following patch? A test for malloc_set_state
> naturaly cannot compile so how link that? Also what write to NEWS?
For mailist thread it wasn't clear exactly what is happening to emacs performance.
However, as Paul has stated, this should not inhibit glibc to moving forward.
We can add to NEW exactly what the patch proposes: malloc_(sg)et_state is
now deprecated and should not be use in new programs.
>
> * malloc/malloc.c: Make malloc_get_state and malloc_set_state
> compatibility symbols.
> * malloc/tst-mallocstate.c: Disable test.
>
> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index 9a45707..36d94e2 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -5180,6 +5180,13 @@ weak_alias (__malloc_trim, malloc_trim)
> weak_alias (__malloc_get_state, malloc_get_state)
> weak_alias (__malloc_set_state, malloc_set_state)
>
> +#include <shlib-compat.h>
> +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_20)
> +
> +compat_symbol (libc, malloc_get_state, malloc_get_state, GLIBC_2_0);
> +compat_symbol (libc, malloc_set_state, malloc_set_state, GLIBC_2_0);
> +
> +#endif
>
> /* ------------------------------------------------------------
> History:
> diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
> index 69c4500..eec2e5a 100644
> --- a/malloc/tst-mallocstate.c
> +++ b/malloc/tst-mallocstate.c
> @@ -32,6 +32,7 @@ merror (const char *msg)
> int
> main (void)
> {
> +/*
> void *p1, *p2;
> void *save_state;
> long i;
> @@ -56,7 +57,9 @@ main (void)
> merror ("malloc_get_state () failed.");
> break;
> }
> + */
> /*free (malloc (10)); This could change the top chunk! */
> + /*
> malloc_set_state (save_state);
> p1 = realloc (p1, i * 4 + 4);
> if (p1 == NULL)
> @@ -72,6 +75,7 @@ main (void)
> free (p1);
>
> return errors != 0;
> +*/
> }
>
> /*
Shouldn't we just remove this test?
More information about the Libc-alpha
mailing list