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>.
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.
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.
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/>. */
21 #define _PT_MACHINE_H 1
26 # define PT_EI __extern_always_inline
29 #include <asm/fixed_code.h>
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. */
39 testandset (int *spinlock)
43 __asm__ __volatile__ (
45 : "=q0" (res), "=m" (*spinlock)
46 : "qA" (spinlock), "m" (*spinlock), "a" (ATOMIC_XCHG32), "q1" (1)
47 : "RETS", "cc", "memory");
52 #define HAS_COMPARE_AND_SWAP
54 __compare_and_swap (long int *p, long int oldval, long int newval)
57 __asm__ __volatile__ (
59 : "=q0" (readval), "=m" (*p)
65 : "RETS", "memory", "cc");
66 return readval == oldval;
70 # define PTHREAD_STATIC_FN_REQUIRE(name)
72 # define PTHREAD_STATIC_FN_REQUIRE(name) __asm__ (".globl " "_"#name);
75 #endif /* pt-machine.h */