From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 4E9273857820 for ; Thu, 24 Jun 2021 23:38:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4E9273857820 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-257-XUG4VetuOZCvky1DihJZNg-1; Thu, 24 Jun 2021 19:38:42 -0400 X-MC-Unique: XUG4VetuOZCvky1DihJZNg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 25935800D62; Thu, 24 Jun 2021 23:38:41 +0000 (UTC) Received: from greed.delorie.com (ovpn-112-111.rdu2.redhat.com [10.10.112.111]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 483285D9D3; Thu, 24 Jun 2021 23:38:36 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.15.2/8.15.2) with ESMTP id 15ONcYYb448734; Thu, 24 Jun 2021 19:38:34 -0400 From: DJ Delorie To: Siddhesh Poyarekar Cc: libc-alpha@sourceware.org, carlos@redhat.com, fweimer@redhat.com Subject: Re: [PATCH 8/8] Remove __morecore and __default_morecore In-Reply-To: <20210624182312.236596-9-siddhesh@sourceware.org> Date: Thu, 24 Jun 2021 19:38:34 -0400 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, 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-List-Received-Date: Thu, 24 Jun 2021 23:38:45 -0000 Siddhesh Poyarekar writes: > Make the __morecore and __default_morecore symbols compat-only and > remove their declarations from the API. > diff --git a/NEWS b/NEWS > > +* 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. > + Ok. > diff --git a/include/stdlib.h b/include/stdlib.h > index e2453c1896..c5cccce85c 100644 > --- a/include/stdlib.h > +++ b/include/stdlib.h > @@ -300,9 +300,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) > - Ok. > diff --git a/malloc/arena.c b/malloc/arena.c > -#if defined(SHARED) || defined(USE_MTAG) > -static void * > -__failing_morecore (ptrdiff_t d) > -{ > - return (void *) MORECORE_FAILURE; > -} > -#endif > - Ok. > @@ -300,7 +292,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; Ok. > @@ -313,7 +305,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 Ok. > diff --git a/malloc/hooks.c b/malloc/hooks.c > > +void *(*__morecore)(ptrdiff_t); > +compat_symbol (libc, __morecore, __morecore, GLIBC_2_0); Ok. > diff --git a/malloc/malloc-internal.h b/malloc/malloc-internal.h > > #include > #include > +#include Ok. > @@ -63,6 +64,8 @@ > > #define top(ar_ptr) ((ar_ptr)->top) > > +extern bool __always_fail_morecore attribute_hidden; > + Ok > @@ -78,4 +81,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; > + Ok. > diff --git a/malloc/malloc.c b/malloc/malloc.c > > > /* 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; Ok. > diff --git a/malloc/malloc.h b/malloc/malloc.h > @@ -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; > - Ok. > diff --git a/malloc/morecore.c b/malloc/morecore.c > index 047228779b..c85a85c0eb 100644 > --- a/malloc/morecore.c > +++ b/malloc/morecore.c > @@ -38,16 +38,27 @@ libc_hidden_proto (__sbrk) > # define NULL 0 > #endif > > +#if defined(SHARED) || defined(USE_MTAG) > +bool __always_fail_morecore = false; > +#endif > + Ok. > /* 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 Ok. LGTM Reviewed-by: DJ Delorie