From patchwork Wed Mar 5 05:11:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 4 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (caibbdcaaahc.dreamhost.com [208.113.200.72]) by wilcox.dreamhost.com (Postfix) with ESMTP id 070AA3600B2 for ; Thu, 6 Mar 2014 11:00:59 -0800 (PST) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14307373) id AC5D040DDDA08; Thu, 6 Mar 2014 11:00:59 -0800 (PST) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx20.g.dreamhost.com Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTP id 7C20440D4FBC5 for ; Thu, 6 Mar 2014 11:00:59 -0800 (PST) Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s26J0wjh020423 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Mar 2014 14:00:59 -0500 Received: from spoyarek.pnq.redhat.com (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s26J0Gp1007936 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Thu, 6 Mar 2014 14:00:22 -0500 Resent-From: Siddhesh Poyarekar Resent-Date: Fri, 7 Mar 2014 00:30:54 +0530 Resent-Message-ID: <20140306190054.GX1722@spoyarek.pnq.redhat.com> Resent-To: glibc@patchwork.siddhesh.in Received: from zmta06.collab.prod.int.phx2.redhat.com (LHLO zmta06.collab.prod.int.phx2.redhat.com) (10.5.81.13) by zmail09.collab.prod.int.phx2.redhat.com with LMTP; Wed, 5 Mar 2014 00:11:16 -0500 (EST) Received: from zmta06.collab.prod.int.phx2.redhat.com (localhost [127.0.0.1]) by zmta06.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 8F5A5166942 for ; Wed, 5 Mar 2014 00:11:16 -0500 (EST) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by zmta06.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 8A75A16651E for ; Wed, 5 Mar 2014 00:11:16 -0500 (EST) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.17]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s255BE0l019717 for ; Wed, 5 Mar 2014 00:11:14 -0500 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s255BAtP021561 for ; Wed, 5 Mar 2014 00:11:11 -0500 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:subject :content-type:content-transfer-encoding; q=dns; s=default; b=Z+N UqXI94x8t4lDicROrf8k0OPajZCND9QgYsoPlhKr8atMF9EFg1TBvBgZ5vkUkfJB khjAle3SSo4JVediTFBmoLss7cS9qB/MAT2pER0H//0jaghn2zqN4B1Ux6hGrMD2 +Bn2JJrkZXuF8hBOu09g/xcigDGHWJ7pFqLc1qzQ= 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:subject :content-type:content-transfer-encoding; s=default; bh=T1h19f9ZP PK7QEDp5CBBa183vYE=; b=mgyh4c4m20sxPRrFi4PV98cm7D6ayLfVj2plP1XUN qevpM0b4CNwDQrsgca7u1PqdHC0v8ot6QBufuDMIbjcsiCu7J5ze9FMrnxsG3xVF Wo5/qy7XHcf3OjGW+iw0E8SdTp5PZPtzTeSPAb69N93+AmD3NshUFAOWcuBxh4xv 50= Received: (qmail 13632 invoked by alias); 5 Mar 2014 05:11:09 -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 13616 invoked by uid 89); 5 Mar 2014 05:11:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Message-ID: <5316B1E5.5070100@redhat.com> Date: Wed, 05 Mar 2014 00:11:01 -0500 From: "Carlos O'Donell" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: GNU C Library Subject: [PATCH] hppa: Add _STACK_GROWS_* cases to pthread_attr_[sg]etstack. X-RedHat-Spam-Score: -4.203 (BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.17 X-DH-Original-To: glibc@patchwork.siddhesh.in This is one of a several NPTL patches to build glibc on hppa. The pthread_attr_[sg]etstack functions are defined by POSIX as taking a stackaddr that is the lowest addressable byte of the storage used for the stack. However, the internal iattr variable of the same name in NPTL is actually the final stack address as usable in the stack pointer for the machine. Therefore the NPTL implementation must add and subtract stacksize for _STACK_GROWS_DOWN architectures. HPPA is a _STACK_GROWS_UP architecture and doesn't need to add or subtract anything, the stack address *is* the lowest addressable byte of the storage. Tested on hppa-linux-gnu, with no regressions. Can't impact any other targets because of the conditionals. If nobody objects I'll check this in at the end of the week. I can't see there being any objections to this patch except that it introduces more code to maintain for an old architecture (perhaps we'll get another _S_G_U target in the future?). 2014-03-05 Carlos O'Donell * nptl/pthread_attr_setstack.c (__pthread_attr_setstack) [!_STACK_GROWS_DOWN]: Don't add stacksize to stackaddr. (__old_pthread_attr_setstack): Likewise. * nptl/pthread_attr_getstack.c (__pthread_attr_getstack) [!_STACK_GROWS_DOWN]: Likewise. diff --git a/nptl/pthread_attr_setstack.c b/nptl/pthread_attr_setstack.c index 19a5b54..4785501 100644 --- a/nptl/pthread_attr_setstack.cDon't add stacksize to stackaddr. +++ b/nptl/pthread_attr_setstack.c @@ -48,7 +48,11 @@ __pthread_attr_setstack (attr, stackaddr, stacksize) #endif iattr->stacksize = stacksize; +#if _STACK_GROWS_DOWN iattr->stackaddr = (char *) stackaddr + stacksize; +#else + iattr->stackaddr = (char *) stackaddr; +#endif iattr->flags |= ATTR_FLAG_STACKADDR; return 0; @@ -81,7 +85,11 @@ __old_pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, # endif iattr->stacksize = stacksize; +#if _STACK_GROWS_DOWN iattr->stackaddr = (char *) stackaddr + stacksize; +#else + iattr->stackaddr = (char *) stackaddr; +#endif iattr->flags |= ATTR_FLAG_STACKADDR; return 0; --- Cheers, Carlos. diff --git a/nptl/pthread_attr_getstack.c b/nptl/pthread_attr_getstack.c index 3f4fd8d..4c1a098 100644 --- a/nptl/pthread_attr_getstack.c +++ b/nptl/pthread_attr_getstack.c @@ -32,7 +32,11 @@ __pthread_attr_getstack (attr, stackaddr, stacksize) iattr = (struct pthread_attr *) attr; /* Store the result. */ +#ifdef _STACK_GROWS_DOWN *stackaddr = (char *) iattr->stackaddr - iattr->stacksize; +#else + *stackaddr = (char *) iattr->stackaddr; +#endif *stacksize = iattr->stacksize; return 0;