]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / linuxthreads.old / sysdeps / bfin / pt-machine.h
1 /* Machine-dependent pthreads configuration and inline functions.
2    Copyright (C) 1996, 1998, 2000, 2002 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Richard Henderson <rth@tamu.edu>.
5
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public License as
8    published by the Free Software Foundation; either version 2.1 of the
9    License, or (at your option) any later version.
10
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    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; see the file COPYING.LIB.  If
18    not, see <http://www.gnu.org/licenses/>.  */
19
20 #ifndef _PT_MACHINE_H
21 #define _PT_MACHINE_H   1
22
23 #include <features.h>
24
25 #ifndef PT_EI
26 # define PT_EI __extern_always_inline
27 #endif
28
29 #include <asm/fixed_code.h>
30
31 /* Spinlock implementation; required.  */
32 /* The semantics of the TESTSET instruction cannot be guaranteed. We cannot
33    easily move all locks used by linux kernel to non-cacheable memory.
34    EXCPT 0x4 is used to trap into kernel to do the atomic testandset.
35    It's ugly. But it's the only thing we can do now.
36    The handler of EXCPT 0x4 expects the address of the lock is passed through
37    R0. And the result is returned by R0.  */
38 PT_EI long int
39 testandset (int *spinlock)
40 {
41     long int res;
42
43     __asm__ __volatile__ (
44                 "CALL (%4);"
45                 : "=q0" (res), "=m" (*spinlock)
46                 : "qA" (spinlock), "m" (*spinlock), "a" (ATOMIC_XCHG32), "q1" (1)
47                 : "RETS", "cc", "memory");
48
49     return res;
50 }
51
52 #define HAS_COMPARE_AND_SWAP
53 PT_EI int
54 __compare_and_swap (long int *p, long int oldval, long int newval)
55 {
56     long int readval;
57     __asm__ __volatile__ (
58                 "CALL (%5);"
59                 : "=q0" (readval), "=m" (*p)
60                 : "qA" (p),
61                   "q1" (oldval),
62                   "q2" (newval),
63                   "a" (ATOMIC_CAS32),
64                   "m" (*p)
65                 : "RETS", "memory", "cc");
66     return readval == oldval;
67 }
68
69 #ifdef SHARED
70 # define PTHREAD_STATIC_FN_REQUIRE(name)
71 #else
72 # define PTHREAD_STATIC_FN_REQUIRE(name) __asm__ (".globl " "_"#name);
73 #endif
74
75 #endif /* pt-machine.h */