From: DJ Delorie <dj@redhat.com>
To: Siddhesh Poyarekar <siddhesh@sourceware.org>
Cc: libc-alpha@sourceware.org, carlos@redhat.com, fweimer@redhat.com
Subject: Re: [PATCH 8/8] Remove __morecore and __default_morecore
Date: Thu, 24 Jun 2021 19:38:34 -0400 [thread overview]
Message-ID: <xnr1gq6dfp.fsf@greed.delorie.com> (raw)
In-Reply-To: <20210624182312.236596-9-siddhesh@sourceware.org>
Siddhesh Poyarekar <siddhesh@sourceware.org> writes:
> Make the __morecore and __default_morecore symbols compat-only and
> remove their declarations from the API.
> diff --git a/NEWS b/NEWS
>
> +* The __morecore and __after_morecore_hook malloc hooks and the default
> + implementation __default_morecore have been removed from the API. Existing
> + applications will continue to link against these symbols but the interfaces
> + no longer have any effect on malloc.
> +
Ok.
> diff --git a/include/stdlib.h b/include/stdlib.h
> index e2453c1896..c5cccce85c 100644
> --- a/include/stdlib.h
> +++ b/include/stdlib.h
> @@ -300,9 +300,6 @@ libc_hidden_proto (__qfcvt_r)
> # define MB_CUR_MAX (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MB_CUR_MAX))
> # endif
>
> -extern void *__default_morecore (ptrdiff_t) __THROW;
> -libc_hidden_proto (__default_morecore)
> -
Ok.
> diff --git a/malloc/arena.c b/malloc/arena.c
> -#if defined(SHARED) || defined(USE_MTAG)
> -static void *
> -__failing_morecore (ptrdiff_t d)
> -{
> - return (void *) MORECORE_FAILURE;
> -}
> -#endif
> -
Ok.
> @@ -300,7 +292,7 @@ ptmalloc_init (void)
> and that morecore does not support tagged regions, then
> disable it. */
> if (__MTAG_SBRK_UNTAGGED)
> - __morecore = __failing_morecore;
> + __always_fail_morecore = true;
Ok.
> @@ -313,7 +305,7 @@ ptmalloc_init (void)
> generic sbrk implementation also enforces this, but it is not
> used on Hurd. */
> if (!__libc_initial)
> - __morecore = __failing_morecore;
> + __always_fail_morecore = true;
> #endif
Ok.
> diff --git a/malloc/hooks.c b/malloc/hooks.c
>
> +void *(*__morecore)(ptrdiff_t);
> +compat_symbol (libc, __morecore, __morecore, GLIBC_2_0);
Ok.
> diff --git a/malloc/malloc-internal.h b/malloc/malloc-internal.h
>
> #include <malloc-machine.h>
> #include <malloc-sysdep.h>
> +#include <stdbool.h>
Ok.
> @@ -63,6 +64,8 @@
>
> #define top(ar_ptr) ((ar_ptr)->top)
>
> +extern bool __always_fail_morecore attribute_hidden;
> +
Ok
> @@ -78,4 +81,6 @@ void __malloc_arena_thread_freeres (void) attribute_hidden;
> /* Activate a standard set of debugging hooks. */
> void __malloc_check_init (void) attribute_hidden;
>
> +extern void *__glibc_morecore (ptrdiff_t) attribute_hidden;
> +
Ok.
> diff --git a/malloc/malloc.c b/malloc/malloc.c
>
>
> /* Definition for getting more memory from the OS. */
> -#define MORECORE (*__morecore)
> +#define MORECORE (*__glibc_morecore)
> #define MORECORE_FAILURE 0
> -void * __default_morecore (ptrdiff_t);
> -void *(*__morecore)(ptrdiff_t) = __default_morecore;
Ok.
> diff --git a/malloc/malloc.h b/malloc/malloc.h
> @@ -76,14 +76,6 @@ extern void *valloc (size_t __size) __THROW __attribute_malloc__
> extern void *pvalloc (size_t __size) __THROW __attribute_malloc__
> __wur __attr_dealloc_free;
>
> -/* Underlying allocation function; successive calls should return
> - contiguous pieces of memory. */
> -extern void *(*__morecore) (ptrdiff_t __size) __MALLOC_DEPRECATED;
> -
> -/* Default value of `__morecore'. */
> -extern void *__default_morecore (ptrdiff_t __size)
> -__THROW __attribute_malloc__ __MALLOC_DEPRECATED;
> -
Ok.
> diff --git a/malloc/morecore.c b/malloc/morecore.c
> index 047228779b..c85a85c0eb 100644
> --- a/malloc/morecore.c
> +++ b/malloc/morecore.c
> @@ -38,16 +38,27 @@ libc_hidden_proto (__sbrk)
> # define NULL 0
> #endif
>
> +#if defined(SHARED) || defined(USE_MTAG)
> +bool __always_fail_morecore = false;
> +#endif
> +
Ok.
> /* Allocate INCREMENT more bytes of data space,
> and return the start of data space, or NULL on errors.
> If INCREMENT is negative, shrink data space. */
> void *
> -__default_morecore (ptrdiff_t increment)
> +__glibc_morecore (ptrdiff_t increment)
> {
> +#if defined(SHARED) || defined(USE_MTAG)
> + if (__always_fail_morecore)
> + return NULL;
> +#endif
> +
> void *result = (void *) __sbrk (increment);
> if (result == (void *) -1)
> return NULL;
>
> return result;
> }
> -libc_hidden_def (__default_morecore)
> +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_34)
> +compat_symbol (libc, __glibc_morecore, __default_morecore, GLIBC_2_0);
> +#endif
Ok.
LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>
prev parent reply other threads:[~2021-06-24 23:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-24 18:23 [PATCH 0/8] Remove malloc hooks Siddhesh Poyarekar
2021-06-24 18:23 ` [PATCH 1/8] Move glibc.malloc.check implementation into its own file Siddhesh Poyarekar
2021-06-24 19:57 ` DJ Delorie
2021-06-28 4:34 ` Siddhesh Poyarekar
2021-06-24 18:23 ` [PATCH 2/8] malloc: Move malloc hook references to hooks.c Siddhesh Poyarekar
2021-06-24 21:10 ` DJ Delorie
2021-06-24 18:23 ` [PATCH 3/8] glibc.malloc.check: Wean away from malloc hooks Siddhesh Poyarekar
2021-06-24 21:43 ` DJ Delorie
2021-06-24 18:23 ` [PATCH 4/8] mcheck: " Siddhesh Poyarekar
2021-06-24 22:51 ` DJ Delorie
2021-06-28 6:22 ` Siddhesh Poyarekar
2021-06-24 18:23 ` [PATCH 5/8] mtrace: " Siddhesh Poyarekar
2021-06-24 23:13 ` DJ Delorie
2021-06-28 6:25 ` Siddhesh Poyarekar
2021-06-24 18:23 ` [PATCH 6/8] Remove " Siddhesh Poyarekar
2021-06-24 23:31 ` DJ Delorie
2021-06-28 6:37 ` Siddhesh Poyarekar
2021-06-24 18:23 ` [PATCH 7/8] Remove __after_morecore_hook Siddhesh Poyarekar
2021-06-24 23:33 ` DJ Delorie
2021-06-24 18:23 ` [PATCH 8/8] Remove __morecore and __default_morecore Siddhesh Poyarekar
2021-06-24 23:38 ` DJ Delorie [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xnr1gq6dfp.fsf@greed.delorie.com \
--to=dj@redhat.com \
--cc=carlos@redhat.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=siddhesh@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).