From ef4009734b84903615be28b38638c166e5455692 Mon Sep 17 00:00:00 2001 From: Maxim Kuvyrkov Date: Wed, 15 Aug 2012 16:29:06 -0700 Subject: Add generic versions of pthread_spin_lock and pthread_spin_trylock. --- ports/sysdeps/hppa/nptl/pthread_spin_lock.c | 26 +++++--------------- ports/sysdeps/hppa/nptl/pthread_spin_trylock.c | 33 -------------------------- 2 files changed, 6 insertions(+), 53 deletions(-) delete mode 100644 ports/sysdeps/hppa/nptl/pthread_spin_trylock.c (limited to 'ports/sysdeps/hppa') diff --git a/ports/sysdeps/hppa/nptl/pthread_spin_lock.c b/ports/sysdeps/hppa/nptl/pthread_spin_lock.c index bcf22408da..e011853130 100644 --- a/ports/sysdeps/hppa/nptl/pthread_spin_lock.c +++ b/ports/sysdeps/hppa/nptl/pthread_spin_lock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2005-2012 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 @@ -15,23 +15,9 @@ License along with the GNU C Library. If not, see . */ -#include -#include "pthreadP.h" +#define SPIN_LOCK_READS_BETWEEN_CMPXCHG 1000 -int -pthread_spin_lock (pthread_spinlock_t *lock) -{ -#if 0 - volatile unsigned int *addr = __ldcw_align (lock); - - while (__ldcw (addr) == 0) - while (*addr == 0) ; - - return 0; -#endif - - while (atomic_compare_and_exchange_val_acq(lock, 1, 0) == 1) - while (*lock == 1); - - return 0; -} +/* We can't use the normal "#include " because + it will resolve to this very file. Using "sysdeps/.." as reference to the + top level directory does the job. */ +#include diff --git a/ports/sysdeps/hppa/nptl/pthread_spin_trylock.c b/ports/sysdeps/hppa/nptl/pthread_spin_trylock.c deleted file mode 100644 index a802861012..0000000000 --- a/ports/sysdeps/hppa/nptl/pthread_spin_trylock.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2005 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 - . */ - -#include -#include -#include "pthreadP.h" - -int -pthread_spin_trylock (pthread_spinlock_t *lock) -{ -#if 0 - volatile unsigned int *a = __ldcw_align (lock); - - return __ldcw (a) ? 0 : EBUSY; -#endif - - return atomic_compare_and_exchange_val_acq(lock, 1, 0) ? EBUSY : 0; - -} -- cgit 1.4.1