diff options
author | Carmelo Amoroso <carmelo.amoroso@st.com> | 2008-03-16 08:54:38 +0000 |
---|---|---|
committer | Carmelo Amoroso <carmelo.amoroso@st.com> | 2008-03-16 08:54:38 +0000 |
commit | e0a7506f8ec11c1c524fe1d6b52781d168e988db (patch) | |
tree | 2dcf7858f0c7d236efe32db885baa9379358ec8a /libpthread/linuxthreads.old/sysdeps/bfin | |
parent | e772b90e7e8190112a987f7c18c19a33766acfd0 (diff) | |
download | uClibc-alpine-e0a7506f8ec11c1c524fe1d6b52781d168e988db.tar.bz2 uClibc-alpine-e0a7506f8ec11c1c524fe1d6b52781d168e988db.tar.xz |
Merge nptl branch tree with trunk.
Step 7: merge linuxthreads and linuxthread.old folders
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libpthread/linuxthreads.old/sysdeps/bfin')
-rw-r--r-- | libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h index fef16263e..9f5cb5c1f 100644 --- a/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h +++ b/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h @@ -21,37 +21,56 @@ #ifndef _PT_MACHINE_H #define _PT_MACHINE_H 1 +#include <features.h> + #ifndef PT_EI -# define PT_EI extern inline +# define PT_EI __extern_always_inline #endif -extern long int testandset (int *spinlock); -extern int __compare_and_swap (long *, long , long); +#include <asm/fixed_code.h> /* Spinlock implementation; required. */ +/* The semantics of the TESTSET instruction cannot be guaranteed. We cannot + easily move all locks used by linux kernel to non-cacheable memory. + EXCPT 0x4 is used to trap into kernel to do the atomic testandset. + It's ugly. But it's the only thing we can do now. + The handler of EXCPT 0x4 expects the address of the lock is passed through + R0. And the result is returned by R0. */ PT_EI long int testandset (int *spinlock) { - if (*spinlock) - return 1; - else - { - *spinlock=1; - return 0; - } + long int res; + + __asm__ __volatile__ ( + "CALL (%4);" + : "=q0" (res), "=m" (*spinlock) + : "qA" (spinlock), "m" (*spinlock), "a" (ATOMIC_XCHG32), "q1" (1) + : "RETS", "cc", "memory"); + + return res; } #define HAS_COMPARE_AND_SWAP - PT_EI int __compare_and_swap (long int *p, long int oldval, long int newval) { - if((*p ^ oldval) == 0) { - *p = newval; - return 1; - } - else - return 0; + long int readval; + __asm__ __volatile__ ( + "CALL (%5);" + : "=q0" (readval), "=m" (*p) + : "qA" (p), + "q1" (oldval), + "q2" (newval), + "a" (ATOMIC_CAS32), + "m" (*p) + : "RETS", "memory", "cc"); + return readval == oldval; } +#ifdef SHARED +# define PTHREAD_STATIC_FN_REQUIRE(name) +#else +# define PTHREAD_STATIC_FN_REQUIRE(name) __asm (".globl " "_"#name); +#endif + #endif /* pt-machine.h */ |