From patchwork Thu Jul 10 21:55:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 2002 Received: (qmail 10891 invoked by alias); 10 Jul 2014 21:55:50 -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 10877 invoked by uid 89); 10 Jul 2014 21:55:50 -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 autolearn=ham version=3.3.2 X-HELO: e24smtp03.br.ibm.com Message-ID: <53BF0BDA.7060803@linux.vnet.ibm.com> Date: Thu, 10 Jul 2014 18:55:38 -0300 From: Adhemerval Zanella User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "GNU C. Library" Subject: Re: [COMMITTED] [PATCH] PowerPC: Fix build due missing lll_robust_trylock References: <53BF0B98.4080704@linux.vnet.ibm.com> In-Reply-To: <53BF0B98.4080704@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 14071021-9564-0000-0000-000001412253 On 10-07-2014 18:54, Adhemerval Zanella wrote: > Commit 887865f remove the lll_robust_trylock definition on all > architectures, however for powerpc both __lll_trylock and > __lll_cond_trylock were based on lll_robust_trylock definition. > It breaks powerpc build with a missing lll_robust_trylock due: > > -- > > In file included from ../include/errno.h:27:0, > from ../sysdeps/pthread/ftrylockfile.c:19: > ../sysdeps/pthread/ftrylockfile.c: In function ‘__ftrylockfile’: > ../sysdeps/powerpc/nptl/tls.h:93:45: warning: implicit declaration of function ‘__lll_robust_trylock’ [-Wimplicit-function-declaration] > # define TLS_TCB_ALIGN __alignof__ (struct pthread) > ^ > ../sysdeps/powerpc/nptl/tls.h:98:52: note: in expansion of macro ‘TLS_TCB_ALIGN’ > + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1))) > ^ > ../sysdeps/powerpc/nptl/tls.h:146:24: note: in expansion of macro ‘TLS_PRE_TCB_SIZE’ > - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)) > ^ > ../sysdeps/nptl/bits/stdio-lock.h:53:20: note: in expansion of macro ‘THREAD_SELF’ > void *__self = THREAD_SELF; \ > ^ > ../sysdeps/pthread/ftrylockfile.c:29:10: note: in expansion of macro ‘_IO_lock_trylock’ > return _IO_lock_trylock (*stream->_lock); > > -- > > This patch restore it with a different name. > > Checked on powerpc64be and powerpc64le. I would advise architecture maintainers > to check build on other arches as well. > > And I forgot to add the contents... --- * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (__lll_base_trylock): New define. (__lll_trylock): Use __lll_base_trylock. (__lll_cond_trylock): Likewise. --- diff --git a/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h index d7e1e38..a651d23 100644 --- a/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h +++ b/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h @@ -190,13 +190,28 @@ # endif #endif +/* Set *futex to ID if it is 0, atomically. Returns the old value */ +#define __lll_base_trylock(futex, id) \ + ({ int __val; \ + __asm __volatile ("1: lwarx %0,0,%2" MUTEX_HINT_ACQ "\n" \ + " cmpwi 0,%0,0\n" \ + " bne 2f\n" \ + " stwcx. %3,0,%2\n" \ + " bne- 1b\n" \ + "2: " __lll_acq_instr \ + : "=&r" (__val), "=m" (*futex) \ + : "r" (futex), "r" (id), "m" (*futex) \ + : "cr0", "memory"); \ + __val; \ + }) + /* Set *futex to 1 if it is 0, atomically. Returns the old value */ -#define __lll_trylock(futex) __lll_robust_trylock (futex, 1) +#define __lll_trylock(futex) __lll_base_trylock (futex, 1) #define lll_trylock(lock) __lll_trylock (&(lock)) /* Set *futex to 2 if it is 0, atomically. Returns the old value */ -#define __lll_cond_trylock(futex) __lll_robust_trylock (futex, 2) +#define __lll_cond_trylock(futex) __lll_base_trylock (futex, 2) #define lll_cond_trylock(lock) __lll_cond_trylock (&(lock))