From patchwork Wed Mar 26 17:32:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 334017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2E8D3140081 for ; Thu, 27 Mar 2014 04:33:02 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=OuXPBgl0UVm1FatU eIFg+zCQnG1rsGOjk929Z2YoMUoSpR4oXbYMz4LDVHGvM4MAKhjqO+Rz6jiCFqF2 e5ce4N7HnW56CVKTVH/iwF+M4eAGM3aEHspHdRYNCUvo7vZHAIHpniNj3IuWsktc zJd25ntOFxgM4LRpXdJIoCjBh4I= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; s=default; bh=ernhriGaaU951mlcpxV7IK xg2JY=; b=lS1C+N4VlYaf1H9w3ObG+VIlgOi4iiwOwJHnNCvAUoixIHsWth6fEO PYMxKqnSiNHkb5xPsr5h5WHzTDYnykk24T2ZTiR7V2wyUdOKMUpNgmV6eKKlPAB/ QlRhqC1O1pkqhoPS+goh3Thc9l9b57fpQ4Je0rMiGSD6J6D0zDKkU= Received: (qmail 8537 invoked by alias); 26 Mar 2014 17:32:56 -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 8527 invoked by uid 89); 26 Mar 2014 17:32:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e24smtp05.br.ibm.com Message-ID: <53330F3B.6090009@linux.vnet.ibm.com> Date: Wed, 26 Mar 2014 14:32:43 -0300 From: Adhemerval Zanella User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Roland McGrath CC: "GNU C. Library" Subject: Re: [PATCH] Remove __PTHREAD_MUTEX_HAVE_ELISION undefined warning References: <5332D913.5050903@linux.vnet.ibm.com> <20140326163647.3E42A74493@topped-with-meat.com> In-Reply-To: <20140326163647.3E42A74493@topped-with-meat.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14032617-1798-0000-0000-0000021D79C1 On 26-03-2014 13:36, Roland McGrath wrote: >> +#if !defined _PTHREAD_H > This is OK but there is no reason not to use #ifndef. > >> +# error "Never include this file directly. Use instead" > Two spaces between the sentences, and a period at the end of each. > > (Those two also apply to the sysdeps variant files you're adding, of course.) > >> +#define __PTHREAD_MUTEX_HAVE_ELISION 0 > As Joseph also requested, add an explanatory comment describing the > protocol for this macro and how other sysdeps variant files might define > it. > >> +#endif >> diff --git a/nptl/sysdeps/pthread/pthread.h b/nptl/sysdeps/pthread/pthread.h >> index 1e0c5dc..39d6b91 100644 >> --- a/nptl/sysdeps/pthread/pthread.h >> +++ b/nptl/sysdeps/pthread/pthread.h >> @@ -26,6 +26,7 @@ >> #include >> #include >> #include >> +#include > I'd put it right after bits/pthreadtypes.h. > >> --- a/posix/Makefile >> +++ b/posix/Makefile >> @@ -29,7 +29,7 @@ headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \ >> bits/local_lim.h tar.h bits/utsname.h bits/confname.h \ >> bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \ >> bits/sched.h re_comp.h wait.h bits/environments.h cpio.h \ >> - sys/sysmacros.h spawn.h bits/unistd.h >> + sys/sysmacros.h spawn.h bits/unistd.h bits/pthread-elision.h > That belongs in nptl/Makefile. > > > Thanks, > Roland > Thanks for the review, what about this version (fixed all the comments): --- * nptl/sysdeps/pthread/bits/pthread-elision.h: New header: define default lock elision support and defines. * nptl/sysdeps/pthread/pthread.h: Include pthread-elision.h. * nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h (__PTHREAD_MUTEX_HAVE_ELISION): Undefine. * nptl/sysdeps/unix/sysv/linux/x86/bits/pthread-elision.h: New header: x86 specific lock elision support. * nptl/sysdeps/unix/sysv/linux/x86/bits/pthreadtypes.h: (__PTHREAD_MUTEX_HAVE_ELISION): Definition moved to specific lock elision header. * nptl/Makefile: Add bits/pthread-elision.h to install. --- diff --git a/nptl/Makefile b/nptl/Makefile index 897ac96..2c79023 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -22,7 +22,7 @@ subdir := nptl include ../Makeconfig -headers := pthread.h semaphore.h bits/semaphore.h +headers := pthread.h semaphore.h bits/semaphore.h bits/pthread-elision.h extra-libs := libpthread extra-libs-others := $(extra-libs) diff --git a/nptl/sysdeps/pthread/bits/pthread-elision.h b/nptl/sysdeps/pthread/bits/pthread-elision.h new file mode 100644 index 0000000..c2ea989 --- /dev/null +++ b/nptl/sysdeps/pthread/bits/pthread-elision.h @@ -0,0 +1,34 @@ +/* Lock elision default definitions. + Copyright (C) 2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _PTHREAD_ELISION_H +#define _PTHREAD_ELISION_H 1 + +#ifndef _PTHREAD_H +# error "Never include this file directly. Use instead" +#endif + +/* Define it if the architecture supports lock elision using transactional + memory or a similar facility. It changes the mutex initializers to add + the required elision fields. Currently, three value are possible: + * 0: No elision support, default value. + * 1: Elision support for 64 bits. + * 2: Elision support for 32 bits. */ +#define __PTHREAD_MUTEX_HAVE_ELISION 0 + +#endif diff --git a/nptl/sysdeps/pthread/pthread.h b/nptl/sysdeps/pthread/pthread.h index 1e0c5dc..47e42c6 100644 --- a/nptl/sysdeps/pthread/pthread.h +++ b/nptl/sysdeps/pthread/pthread.h @@ -24,6 +24,7 @@ #include #include +#include #include #include diff --git a/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h index 23a1698..a361db6 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h @@ -20,8 +20,6 @@ #include -# define __PTHREAD_MUTEX_HAVE_ELISION 0 - #if __WORDSIZE == 64 # define __SIZEOF_PTHREAD_ATTR_T 56 # define __SIZEOF_PTHREAD_MUTEX_T 40 diff --git a/nptl/sysdeps/unix/sysv/linux/x86/bits/pthread-elision.h b/nptl/sysdeps/unix/sysv/linux/x86/bits/pthread-elision.h new file mode 100644 index 0000000..3ab29c4 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/x86/bits/pthread-elision.h @@ -0,0 +1,32 @@ +/* x86 lock elision definitions. + Copyright (C) 2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _PTHREAD_ELISION_H +#define _PTHREAD_ELISION_H 1 + +#ifndef _PTHREAD_H +# error "Never include this file directly. Use instead" +#endif + +#ifdef __x86_64__ +# define __PTHREAD_MUTEX_HAVE_ELISION 1 +#else +# define __PTHREAD_MUTEX_HAVE_ELISION 2 +#endif + +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/x86/bits/pthreadtypes.h index 28e5144..a5363ec 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/x86/bits/pthreadtypes.h @@ -105,7 +105,6 @@ typedef union short __elision; __pthread_list_t __list; # define __PTHREAD_MUTEX_HAVE_PREV 1 -# define __PTHREAD_MUTEX_HAVE_ELISION 1 #else unsigned int __nusers; __extension__ union @@ -116,7 +115,6 @@ typedef union short __elision; # define __spins d.__espins # define __elision d.__elision -# define __PTHREAD_MUTEX_HAVE_ELISION 2 } d; __pthread_slist_t __list; };