From: Siddhesh Poyarekar via Libc-alpha <libc-alpha@sourceware.org>
To: libc-alpha@sourceware.org
Cc: fweimer@redhat.com
Subject: [PATCH v3 09/10] Remove __after_morecore_hook
Date: Fri, 2 Jul 2021 08:05:45 +0530 [thread overview]
Message-ID: <20210702023546.3081774-10-siddhesh@sourceware.org> (raw)
In-Reply-To: <20210702023546.3081774-1-siddhesh@sourceware.org>
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 <dj@redhat.com>
---
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 397220aaba..5e9355761a 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 f6d7309721..296e4f9789 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 */
--
2.31.1
next prev parent reply other threads:[~2021-07-02 2:43 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-02 2:35 [PATCH v3 00/10] Remove malloc hooks Siddhesh Poyarekar via Libc-alpha
2021-07-02 2:35 ` [PATCH v3 01/10] mtrace: Deprecate mallwatch and tr_break Siddhesh Poyarekar via Libc-alpha
2021-07-02 2:35 ` [PATCH v3 02/10] Add mcheck tests to malloc Siddhesh Poyarekar via Libc-alpha
2021-07-06 14:50 ` Stefan Liebler via Libc-alpha
2021-07-06 15:54 ` Siddhesh Poyarekar
2021-07-08 23:37 ` H.J. Lu via Libc-alpha
2021-07-09 0:06 ` H.J. Lu via Libc-alpha
2021-07-09 1:46 ` Siddhesh Poyarekar
2021-07-09 3:53 ` [PATCH] Add a generic malloc test for MALLOC_ALIGNMENT H.J. Lu via Libc-alpha
2021-07-09 4:07 ` Siddhesh Poyarekar
2021-07-09 12:24 ` [PATCH v2] " H.J. Lu via Libc-alpha
2021-07-09 13:00 ` Siddhesh Poyarekar
2021-07-09 13:31 ` [PATCH v3] " H.J. Lu via Libc-alpha
2021-07-09 13:34 ` Siddhesh Poyarekar
2021-07-12 18:02 ` [PATCH v3 02/10] Add mcheck tests to malloc Matheus Castanho via Libc-alpha
2021-07-13 1:06 ` Siddhesh Poyarekar
2021-07-13 12:11 ` Matheus Castanho via Libc-alpha
2021-07-02 2:35 ` [PATCH v3 03/10] Move glibc.malloc.check implementation into its own file Siddhesh Poyarekar via Libc-alpha
2021-07-02 9:05 ` Andreas Schwab
2021-07-02 9:29 ` Siddhesh Poyarekar via Libc-alpha
2021-07-02 9:59 ` Andreas Schwab
2021-07-02 2:35 ` [PATCH v3 04/10] malloc: Move malloc hook references to hooks.c Siddhesh Poyarekar via Libc-alpha
2021-07-02 2:35 ` [PATCH v3 05/10] glibc.malloc.check: Wean away from malloc hooks Siddhesh Poyarekar via Libc-alpha
2021-07-02 2:35 ` [PATCH v3 06/10] mcheck: " Siddhesh Poyarekar via Libc-alpha
2021-07-02 2:35 ` [PATCH v3 07/10] mtrace: " Siddhesh Poyarekar via Libc-alpha
2021-07-02 2:35 ` [PATCH v3 08/10] Remove " Siddhesh Poyarekar via Libc-alpha
2021-07-02 2:35 ` Siddhesh Poyarekar via Libc-alpha [this message]
2021-07-02 2:35 ` [PATCH v3 10/10] Remove __morecore and __default_morecore Siddhesh Poyarekar via Libc-alpha
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210702023546.3081774-10-siddhesh@sourceware.org \
--to=libc-alpha@sourceware.org \
--cc=fweimer@redhat.com \
--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).