From patchwork Thu Jun 24 18:23:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 44006 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A696739B2402 for ; Thu, 24 Jun 2021 18:28:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A696739B2402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624559326; bh=KA3c4ju0aFob2Fzo+trsL6oYV9ChTM1KFIUoAnZnwK4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=M8xceonKinJBoFGzKiJi197qS1+I4kVbvLZbRlts6qAKzyFlfCTIsQX9F4qdTU7v/ 5fi83sXNCGj19IRC7fm3ib/HGQeZ/gv8ZWizKhxDG8o7JoX9miFQj2wzLv+2uCyzlr lD7DBymKpOapcTZFeqHx+vQ+ehfoiCX0vLmetEf4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from antelope.elm.relay.mailchannels.net (antelope.elm.relay.mailchannels.net [23.83.212.4]) by sourceware.org (Postfix) with ESMTPS id E0C5039B040B for ; Thu, 24 Jun 2021 18:23:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E0C5039B040B 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 D0846401FC2; Thu, 24 Jun 2021 18:23:54 +0000 (UTC) Received: from pdx1-sub0-mail-a66.g.dreamhost.com (100-96-18-93.trex.outbound.svc.cluster.local [100.96.18.93]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 58C24402094; Thu, 24 Jun 2021 18:23:54 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a66.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.18.93 (trex/6.3.3); Thu, 24 Jun 2021 18:23:54 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Share-Shelf: 4e3d55541e42e6d4_1624559034672_2213011170 X-MC-Loop-Signature: 1624559034671:3792306308 X-MC-Ingress-Time: 1624559034671 Received: from pdx1-sub0-mail-a66.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a66.g.dreamhost.com (Postfix) with ESMTP id 1ABF08DD5C; Thu, 24 Jun 2021 11:23:54 -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-a66.g.dreamhost.com (Postfix) with ESMTPSA id D006B8DD5D; Thu, 24 Jun 2021 11:23:51 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a66 To: libc-alpha@sourceware.org Subject: [PATCH 7/8] Remove __after_morecore_hook Date: Thu, 24 Jun 2021 23:53:11 +0530 Message-Id: <20210624182312.236596-8-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210624182312.236596-1-siddhesh@sourceware.org> References: <20210624182312.236596-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-3494.6 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_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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. Reviewed-by: DJ Delorie --- malloc/hooks.c | 3 +++ malloc/malloc.c | 30 +----------------------------- malloc/malloc.h | 5 ----- 3 files changed, 4 insertions(+), 34 deletions(-) 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); + /* These hooks will get executed only through the interposed allocator functions in libmalloc_compathooks. This means that the calls to malloc, realloc, etc. will lead back into the interposed functions, which is what we 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; - /* This function is called from the arena shutdown hook, to free the thread cache (if it exists). */ static void tcache_thread_shutdown (void); @@ -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)) { /* If have mmap, try using it as a backup when MORECORE fails or @@ -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)(); - } } /* handle non-contiguous cases */ @@ -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)); 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; -/* Hooks for debugging and user-defined versions. */ -extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void) - __MALLOC_DEPRECATED; - - __END_DECLS #endif /* malloc.h */