From patchwork Sat Aug 20 14:48:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 14796 Received: (qmail 73746 invoked by alias); 20 Aug 2016 15:49:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 73726 invoked by uid 89); 20 Aug 2016 15:49:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_NEUTRAL autolearn=no version=3.3.2 spammy=H*MI:sk:2016082, 2016-08-20 X-HELO: hera.aquilenet.fr Date: Sat, 20 Aug 2016 16:48:01 +0200 From: Samuel Thibault To: fweimer@redhat.com Cc: libc-alpha@sourceware.org Subject: Re: Replace MUTEX_INITIALIZER with _LIBC_LOCK_INITIALIZER in generic code Message-ID: <20160820144801.GC1620@var.home> References: <20160820143610.GA14327@var> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160820143610.GA14327@var> User-Agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) Samuel Thibault, on Sat 20 Aug 2016 16:36:10 +0200, wrote: > And anyway, either malloc should be made to just use libc-lock or lll > explicitly, or the malloc-machine.h layer should be providing a complete > interface and users shouldn't be assuming anything about it. Put another way, I'd tend to commit this. Samuel commit 0f0af158aabda65027634a369f4ce25aa0f20c1a Author: Samuel Thibault Date: Sat Aug 20 16:46:59 2016 +0200 malloc: Restore using MUTEX_INITIALIZER * malloc/malloc.c (main_arena): Use MUTEX_INITIALIZER instead of _LIBC_LOCK_INITIALIZER. * sysdeps/nptl/malloc-machine.h (MUTEX_INITIALIZER): Define. * sysdeps/mach/hurd/malloc-machine.h (MUTEX_INITIALIZER): Comment about macro definition coming from cthreads.h. diff --git a/ChangeLog b/ChangeLog index ae29267..a9ddf8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2016-08-20 Samuel Thibault + + * malloc/malloc.c (main_arena): Use MUTEX_INITIALIZER instead of + _LIBC_LOCK_INITIALIZER. + * sysdeps/nptl/malloc-machine.h (MUTEX_INITIALIZER): Define. + * sysdeps/mach/hurd/malloc-machine.h (MUTEX_INITIALIZER): Comment + about macro definition coming from cthreads.h. + 2016-08-16 Joseph Myers * soft-fp/extended.h [_FP_W_TYPE_SIZE < 64] (FP_UNPACK_RAW_E): diff --git a/malloc/malloc.c b/malloc/malloc.c index bb52b3e..a42d846 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1687,7 +1687,7 @@ struct malloc_par static struct malloc_state main_arena = { - .mutex = _LIBC_LOCK_INITIALIZER, + .mutex = MUTEX_INITIALIZER, .next = &main_arena, .attached_threads = 1 }; diff --git a/sysdeps/mach/hurd/malloc-machine.h b/sysdeps/mach/hurd/malloc-machine.h index f778b0d..803d96a 100644 --- a/sysdeps/mach/hurd/malloc-machine.h +++ b/sysdeps/mach/hurd/malloc-machine.h @@ -41,6 +41,8 @@ #define mutex_trylock(m) (!__mutex_trylock(m)) +/* MUTEX_INITIALIZER already defined by cthreads.h. */ + /* No we're *not* using pthreads. */ #define __pthread_initialize ((void (*)(void))0) diff --git a/sysdeps/nptl/malloc-machine.h b/sysdeps/nptl/malloc-machine.h index 1a2af6f..6d16f90 100644 --- a/sysdeps/nptl/malloc-machine.h +++ b/sysdeps/nptl/malloc-machine.h @@ -29,6 +29,7 @@ __libc_lock_define (typedef, mutex_t) #define mutex_lock(m) __libc_lock_lock (*(m)) #define mutex_trylock(m) __libc_lock_trylock (*(m)) #define mutex_unlock(m) __libc_lock_unlock (*(m)) +#define MUTEX_INITIALIZER LLL_LOCK_INITIALIZER #include