public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/siddhesh/malloc-hooks-new] Remove __after_morecore_hook
@ 2021-07-05 14:42 Siddhesh Poyarekar
0 siblings, 0 replies; 2+ messages in thread
From: Siddhesh Poyarekar @ 2021-07-05 14:42 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=258e6098334ef4749681c1d931d25ed36f96059f
commit 258e6098334ef4749681c1d931d25ed36f96059f
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Mon Jul 5 20:03:19 2021 +0530
Remove __after_morecore_hook
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:
---
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
#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 *) = memalign_hook_ini;
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);
+
/* 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);
/* -------------- 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);
@@ -2623,14 +2613,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
@@ -2769,13 +2752,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 */
@@ -2934,10 +2910,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 */
^ permalink raw reply [flat|nested] 2+ messages in thread
* [glibc/siddhesh/malloc-hooks-new] Remove __after_morecore_hook
@ 2021-07-07 2:07 Siddhesh Poyarekar
0 siblings, 0 replies; 2+ messages in thread
From: Siddhesh Poyarekar @ 2021-07-07 2:07 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f28506227b1680f8618208e9aecf9a3e0bc18c1c
commit f28506227b1680f8618208e9aecf9a3e0bc18c1c
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Mon Jul 5 20:03:19 2021 +0530
Remove __after_morecore_hook
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:
---
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 0ae3abed63..166160bc98 100644
--- a/malloc/hooks.c
+++ b/malloc/hooks.c
@@ -24,6 +24,10 @@ compat_symbol (libc, __malloc_initialize_hook,
#endif
#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 *) = memalign_hook_ini;
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);
+
/* 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);
/* -------------- 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);
@@ -2623,14 +2613,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
@@ -2769,13 +2752,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 */
@@ -2934,10 +2910,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 */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-07 2:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 14:42 [glibc/siddhesh/malloc-hooks-new] Remove __after_morecore_hook Siddhesh Poyarekar
2021-07-07 2:07 Siddhesh Poyarekar
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).