@@ -113,6 +113,11 @@ Deprecated and removed features, and other changes affecting compatibility:
future release of the GNU C Library. Users may port away from these hooks by
writing and preloading their own malloc interposition library.
+* The __morecore and __after_morecore_hook malloc hooks and the default
+ implementation __default_morecore have been removed from the API. Existing
+ applications will continue to link against these symbols but the interfaces
+ no longer have any effect on malloc.
+
Changes to build and runtime requirements:
* On Linux, the shm_open, sem_open, and related functions now expect the
@@ -306,9 +306,6 @@ libc_hidden_proto (__qfcvt_r)
# define MB_CUR_MAX (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MB_CUR_MAX))
# endif
-extern void *__default_morecore (ptrdiff_t) __THROW;
-libc_hidden_proto (__default_morecore)
-
struct abort_msg_s
{
unsigned int size;
@@ -266,14 +266,6 @@ next_env_entry (char ***position)
#endif
-#if defined(SHARED) || defined(USE_MTAG)
-static void *
-__failing_morecore (ptrdiff_t d)
-{
- return (void *) MORECORE_FAILURE;
-}
-#endif
-
#ifdef SHARED
extern struct dl_open_hook *_dl_open_hook;
libc_hidden_proto (_dl_open_hook);
@@ -294,7 +286,7 @@ ptmalloc_init (void)
and that morecore does not support tagged regions, then
disable it. */
if (__MTAG_SBRK_UNTAGGED)
- __morecore = __failing_morecore;
+ __always_fail_morecore = true;
mtag_enabled = true;
mtag_mmap_flags = __MTAG_MMAP_FLAGS;
@@ -307,7 +299,7 @@ ptmalloc_init (void)
generic sbrk implementation also enforces this, but it is not
used on Hurd. */
if (!__libc_initial)
- __morecore = __failing_morecore;
+ __always_fail_morecore = true;
#endif
thread_arena = &main_arena;
@@ -46,6 +46,8 @@ 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);
+void *(*__morecore)(ptrdiff_t);
+compat_symbol (libc, __morecore, __morecore, 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
@@ -21,6 +21,7 @@
#include <malloc-machine.h>
#include <malloc-sysdep.h>
+#include <stdbool.h>
/* INTERNAL_SIZE_T is the word-size used for internal bookkeeping of
chunk sizes.
@@ -62,6 +63,8 @@
#define MALLOC_ALIGN_MASK (MALLOC_ALIGNMENT - 1)
+extern bool __always_fail_morecore attribute_hidden;
+
/* Called in the parent process before a fork. */
void __malloc_fork_lock_parent (void) attribute_hidden;
@@ -77,4 +80,6 @@ void __malloc_arena_thread_freeres (void) attribute_hidden;
/* Activate a standard set of debugging hooks. */
void __malloc_check_init (void) attribute_hidden;
+extern void *__glibc_morecore (ptrdiff_t) attribute_hidden;
+
#endif /* _MALLOC_INTERNAL_H */
@@ -382,10 +382,8 @@ __malloc_assert (const char *assertion, const char *file, unsigned int line,
/* Definition for getting more memory from the OS. */
-#define MORECORE (*__morecore)
+#define MORECORE (*__glibc_morecore)
#define MORECORE_FAILURE 0
-void * __default_morecore (ptrdiff_t);
-void *(*__morecore)(ptrdiff_t) = __default_morecore;
/* Memory tagging. */
@@ -76,14 +76,6 @@ extern void *valloc (size_t __size) __THROW __attribute_malloc__
extern void *pvalloc (size_t __size) __THROW __attribute_malloc__
__wur __attr_dealloc_free;
-/* Underlying allocation function; successive calls should return
- contiguous pieces of memory. */
-extern void *(*__morecore) (ptrdiff_t __size) __MALLOC_DEPRECATED;
-
-/* Default value of `__morecore'. */
-extern void *__default_morecore (ptrdiff_t __size)
-__THROW __attribute_malloc__ __MALLOC_DEPRECATED;
-
/* SVID2/XPG mallinfo structure */
struct mallinfo
@@ -38,16 +38,27 @@ libc_hidden_proto (__sbrk)
# define NULL 0
#endif
+#if defined(SHARED) || defined(USE_MTAG)
+bool __always_fail_morecore = false;
+#endif
+
/* Allocate INCREMENT more bytes of data space,
and return the start of data space, or NULL on errors.
If INCREMENT is negative, shrink data space. */
void *
-__default_morecore (ptrdiff_t increment)
+__glibc_morecore (ptrdiff_t increment)
{
+#if defined(SHARED) || defined(USE_MTAG)
+ if (__always_fail_morecore)
+ return NULL;
+#endif
+
void *result = (void *) __sbrk (increment);
if (result == (void *) -1)
return NULL;
return result;
}
-libc_hidden_def (__default_morecore)
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_34)
+compat_symbol (libc, __glibc_morecore, __default_morecore, GLIBC_2_0);
+#endif