From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from antelope.elm.relay.mailchannels.net (antelope.elm.relay.mailchannels.net [23.83.212.4]) by sourceware.org (Postfix) with ESMTPS id 1D71D384002D for ; Mon, 5 Jul 2021 17:09:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D71D384002D X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 6A99564160D; Mon, 5 Jul 2021 17:09:22 +0000 (UTC) Received: from pdx1-sub0-mail-a29.g.dreamhost.com (100-105-161-161.trex-nlb.outbound.svc.cluster.local [100.105.161.161]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 02619641AE1; Mon, 5 Jul 2021 17:09:21 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a29.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.105.161.161 (trex/6.3.3); Mon, 05 Jul 2021 17:09:22 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Chief-Whimsical: 54df50c168ff2752_1625504962269_3648464233 X-MC-Loop-Signature: 1625504962269:3995954268 X-MC-Ingress-Time: 1625504962268 Received: from pdx1-sub0-mail-a29.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a29.g.dreamhost.com (Postfix) with ESMTP id 779D97E509; Mon, 5 Jul 2021 10:09:21 -0700 (PDT) Received: from rhbox.intra.reserved-bit.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a29.g.dreamhost.com (Postfix) with ESMTPSA id 9F9737E4A5; Mon, 5 Jul 2021 10:09:18 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a29 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Cc: dj@redhat.com, carlos@redhat.com, fweimer@redhat.com Subject: [PATCH v5 7/8] Remove __after_morecore_hook Date: Mon, 5 Jul 2021 22:38:13 +0530 Message-Id: <20210705170814.4132997-8-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210705170814.4132997-1-siddhesh@sourceware.org> References: <20210705170814.4132997-1-siddhesh@sourceware.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3494.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jul 2021 17:09:25 -0000 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. --- malloc/hooks.c | 7 +++++++ malloc/malloc.c | 30 +----------------------------- malloc/malloc.h | 5 ----- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/malloc/hooks.c b/malloc/hooks.c index ffaf3a645a..50ea03b562 100644 --- a/malloc/hooks.c +++ b/malloc/hooks.c @@ -24,6 +24,10 @@ compat_symbol (libc, __malloc_initialize_hook, #endif =20 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_34) +# ifndef weak_variable +# define weak_variable weak_function +# endif + static void *malloc_hook_ini (size_t, const void *) __THROW; static void *realloc_hook_ini (void *, size_t, const void *) __THROW; static void *memalign_hook_ini (size_t, size_t, const void *) __THROW; @@ -40,6 +44,9 @@ void *weak_variable (*__memalign_hook) (size_t, size_t, const void *) =3D memalign_hook_ini; compat_symbol (libc, __memalign_hook, __memalign_hook, GLIBC_2_0); =20 +void weak_variable (*__after_morecore_hook) (void) =3D NULL; +compat_symbol (libc, __after_morecore_hook, __after_morecore_hook, GLIBC= _2_0); + /* This is interposed by libc_malloc_debug.so to match with a compatible= libc. We don't use dlsym or equivalent because the dlsym symbol version got= bumped in 2.34 and is hence unusable in libc_malloc_debug.so. */ diff --git a/malloc/malloc.c b/malloc/malloc.c index 1c1e1ab60b..00fcc676a0 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1988,16 +1988,6 @@ static void malloc_consolidate (mstate); =20 /* -------------- Early definitions for debugging hooks ----------------= */ =20 -/* Define and initialize the hook variables. These weak definitions mus= t - appear before any use of the variables in a function (arena.c uses on= e). */ -#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) =3D NULL; - /* This function is called from the arena shutdown hook, to free the thread cache (if it exists). */ static void tcache_thread_shutdown (void); @@ -2623,14 +2613,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) LIBC_PROBE (memory_sbrk_more, 2, brk, size); } =20 - if (brk !=3D (char *) (MORECORE_FAILURE)) - { - /* Call the `morecore' hook if necessary. */ - void (*hook) (void) =3D atomic_forced_read (__after_morecore_h= ook); - if (__builtin_expect (hook !=3D NULL, 0)) - (*hook)(); - } - else + if (brk =3D=3D (char *) (MORECORE_FAILURE)) { /* If have mmap, try using it as a backup when MORECORE fails = or @@ -2769,13 +2752,6 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) correction =3D 0; snd_brk =3D (char *) (MORECORE (0)); } - else - { - /* Call the `morecore' hook if necessary. */ - void (*hook) (void) =3D atomic_forced_read (__afte= r_morecore_hook); - if (__builtin_expect (hook !=3D NULL, 0)) - (*hook)(); - } } =20 /* handle non-contiguous cases */ @@ -2934,10 +2910,6 @@ systrim (size_t pad, mstate av) */ =20 MORECORE (-extra); - /* Call the `morecore' hook if necessary. */ - void (*hook) (void) =3D atomic_forced_read (__after_morecore_hook)= ; - if (__builtin_expect (hook !=3D NULL, 0)) - (*hook)(); new_brk =3D (char *) (MORECORE (0)); =20 LIBC_PROBE (memory_sbrk_less, 2, new_brk, extra); 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; =20 -/* Hooks for debugging and user-defined versions. */ -extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void) - __MALLOC_DEPRECATED; - - __END_DECLS #endif /* malloc.h */ --=20 2.31.1