1 /* POSIX spinlock implementation. ia64 version.
2 Copyright (C) 2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Jes Sorensen <jes@linuxcare.com>
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
25 /* This implementation is inspired by the implementation used in the
29 __pthread_spin_lock (pthread_spinlock_t *lock)
32 ("mov ar.ccv = r0\n\t"
38 "cmp4.eq p0, p7 = r0, r2\n\t"
39 "(p7) br.cond.spnt.few 1b \n\t"
40 "cmpxchg4.acq r2 = %0, r3, ar.ccv\n\t"
42 "cmp4.eq p0, p7 = r0, r2\n\t"
43 "(p7) br.cond.spnt.few 1b\n\t"
45 :: "m" (lock) : "r2", "r3", "p7", "memory");
48 weak_alias (__pthread_spin_lock, pthread_spin_lock)
52 __pthread_spin_trylock (pthread_spinlock_t *lock)
57 ("mov ar.ccv = r0\n\t"
60 "cmpxchg4.acq %0 = %1, r2, ar.ccv\n\t"
62 : "=r" (oldval) : "m" (lock) : "r2", "memory");
63 return oldval > 0 ? 0 : EBUSY;
65 weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
69 __pthread_spin_unlock (pthread_spinlock_t *lock)
73 weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
77 __pthread_spin_init (pthread_spinlock_t *lock, int pshared)
79 /* We can ignore the `pshared' parameter. Since we are busy-waiting
80 all processes which can access the memory location `lock' points
81 to can use the spinlock. */
84 weak_alias (__pthread_spin_init, pthread_spin_init)
88 __pthread_spin_destroy (pthread_spinlock_t *lock)
93 weak_alias (__pthread_spin_destroy, pthread_spin_destroy)