public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
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 7/8] Remove __after_morecore_hook
Date: Thu, 24 Jun 2021 19:33:56 -0400	[thread overview]
Message-ID: <xnv9626dnf.fsf@greed.delorie.com> (raw)
In-Reply-To: <20210624182312.236596-8-siddhesh@sourceware.org>

Siddhesh Poyarekar <siddhesh@sourceware.org> writes:
> Remove __after_morecore_hook from the API and finalize the symbol so
> that it can no longer be used in new applications.  Old applications
> using __after_morecore_hook will find that their hook is no longer
> called.

> diff --git a/malloc/hooks.c b/malloc/hooks.c
> index cc9ffc8b63..fa6b3f4c16 100644
> --- a/malloc/hooks.c
> +++ b/malloc/hooks.c
> @@ -78,6 +78,9 @@ compat_symbol (libc, __malloc_hook, __malloc_hook, GLIBC_2_0);
>  compat_symbol (libc, __realloc_hook, __realloc_hook, GLIBC_2_0);
>  compat_symbol (libc, __memalign_hook, __memalign_hook, GLIBC_2_0);
>  
> +void weak_variable (*__after_morecore_hook) (void) = NULL;
> +compat_symbol (libc, __after_morecore_hook, __after_morecore_hook, GLIBC_2_0);
> +

Ok.

> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index 16ad933c66..51970105b5 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -1988,16 +1988,6 @@ static void     malloc_consolidate (mstate);
>  
>  /* -------------- Early definitions for debugging hooks ---------------- */
>  
> -/* Define and initialize the hook variables.  These weak definitions must
> -   appear before any use of the variables in a function (arena.c uses one).  */
> -#ifndef weak_variable
> -/* In GNU libc we want the hook variables to be weak definitions to
> -   avoid a problem with Emacs.  */
> -# define weak_variable weak_function
> -#endif
> -
> -void weak_variable (*__after_morecore_hook) (void) = NULL;
> -

Ok.

> @@ -2622,14 +2612,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
>            LIBC_PROBE (memory_sbrk_more, 2, brk, size);
>          }
>  
> -      if (brk != (char *) (MORECORE_FAILURE))
> -        {
> -          /* Call the `morecore' hook if necessary.  */
> -          void (*hook) (void) = atomic_forced_read (__after_morecore_hook);
> -          if (__builtin_expect (hook != NULL, 0))
> -            (*hook)();
> -        }
> -      else
> +      if (brk == (char *) (MORECORE_FAILURE))

Ok.

> @@ -2768,13 +2751,6 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
>                        correction = 0;
>                        snd_brk = (char *) (MORECORE (0));
>                      }
> -                  else
> -                    {
> -                      /* Call the `morecore' hook if necessary.  */
> -                      void (*hook) (void) = atomic_forced_read (__after_morecore_hook);
> -                      if (__builtin_expect (hook != NULL, 0))
> -                        (*hook)();
> -                    }

Ok.

> @@ -2933,10 +2909,6 @@ systrim (size_t pad, mstate av)
>         */
>  
>        MORECORE (-extra);
> -      /* Call the `morecore' hook if necessary.  */
> -      void (*hook) (void) = atomic_forced_read (__after_morecore_hook);
> -      if (__builtin_expect (hook != NULL, 0))
> -        (*hook)();
>        new_brk = (char *) (MORECORE (0));

Ok.

> diff --git a/malloc/malloc.h b/malloc/malloc.h
> index 709fa454b5..d066a05d82 100644
> --- a/malloc/malloc.h
> +++ b/malloc/malloc.h
> @@ -164,10 +164,5 @@ extern void malloc_stats (void) __THROW;
>  /* Output information about state of allocator to stream FP.  */
>  extern int malloc_info (int __options, FILE *__fp) __THROW;
>  
> -/* Hooks for debugging and user-defined versions. */
> -extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void)
> -  __MALLOC_DEPRECATED;
> -
> -
>  __END_DECLS
>  #endif /* malloc.h */

Ok.

LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>


  reply	other threads:[~2021-06-24 23:34 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 [this message]
2021-06-24 18:23 ` [PATCH 8/8] Remove __morecore and __default_morecore Siddhesh Poyarekar
2021-06-24 23:38   ` DJ Delorie

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=xnv9626dnf.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).