summaryrefslogtreecommitdiff
path: root/libpthread/linuxthreads/sysdeps/microblaze
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2016-05-18 18:41:24 +0200
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-05-18 18:41:24 +0200
commit6a8ccc95528f5e86a8770ed15ce89609b5b3dee9 (patch)
treebbd4df35b4d4a6a8b00d7a5e61fb2668b850ad62 /libpthread/linuxthreads/sysdeps/microblaze
parent398a27a5b323956344b4f831d892fed3bd9813c7 (diff)
remove linuxthreads.new, rename linuxthreads.old
Linuxthreads.new isn't really useful with the existence of NPTL/TLS for well supported architectures. There is no reason to use LT.new for ARM/MIPS or other architectures supporting NPTL/TLS. It is not available for noMMU architectures like Blackfin or FR-V. To simplify the live of the few uClibc-ng developers, LT.new is removed and LT.old is renamed to LT. LINUXTHREADS_OLD -> UCLIBC_HAS_LINUXTHREADS
Diffstat (limited to 'libpthread/linuxthreads/sysdeps/microblaze')
-rw-r--r--libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h106
-rw-r--r--libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h17
2 files changed, 123 insertions, 0 deletions
diff --git a/libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h b/libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h
new file mode 100644
index 000000000..e8c03f9e5
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h
@@ -0,0 +1,106 @@
+/*
+ * sysdeps/microblaze/pt-machine.h -- microblaze-specific pthread definitions
+ *
+ * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
+ * Copyright (C) 2002 NEC Electronics Corporation
+ * Copyright (C) 2002 Miles Bader <miles@gnu.org>
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Miles Bader <miles@gnu.org>
+ */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#include <features.h>
+
+#ifndef PT_EI
+# define PT_EI extern inline
+#endif
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long *ptr, long old, long new);
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME __stack_pointer
+register char *__stack_pointer __asm__ ("r1");
+
+#define HAS_COMPARE_AND_SWAP
+#define HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
+#define IMPLEMENT_TAS_WITH_CAS
+
+/* Atomically: If *PTR == OLD, set *PTR to NEW and return true,
+ otherwise do nothing and return false. */
+PT_EI int __compare_and_swap (long *ptr, long old, long new)
+{
+ unsigned long psw;
+
+ /* disable interrupts */
+ /* This is ugly ugly ugly! */
+ __asm__ __volatile__ ("mfs %0, rmsr;"
+ "andi r3, %0, ~2;"
+ "mts rmsr, r3;"
+ : "=&r" (psw)
+ :
+ : "r3");
+
+ if (likely (*ptr == old))
+ {
+ *ptr = new;
+ __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw)); /* re-enable */
+ return 1;
+ }
+ else
+ {
+ __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw)); /* re-enable */
+ return 0;
+ }
+}
+
+/* like above's __compare_and_swap() but it first syncs the memory
+ (This is also the difference between both functions in e.g.
+ ../powerpc/pt-machine.h)
+ Doing this additional sync fixes a hang of __pthread_alt_unlock()
+ (Falk Brettschneider <fbrettschneider@baumeroptronic.de>) */
+PT_EI int
+__compare_and_swap_with_release_semantics (long *p,
+ long oldval, long newval)
+{
+ __asm__ __volatile__ ("" : : : "memory"); /*MEMORY_BARRIER ();*/
+ return __compare_and_swap (p, oldval, newval);
+}
+
+
+#ifndef IMPLEMENT_TAS_WITH_CAS
+/* Spinlock implementation; required. */
+PT_EI long int testandset (int *spinlock)
+{
+ unsigned psw;
+
+ /* disable interrupts */
+ __asm__ __volatile__ ("mfs %0, rmsr;"
+ "andi r3, %0, ~2;"
+ "mts rmsr, r3;"
+ : "=&r" (psw)
+ :
+ : "r3");
+
+ if (*spinlock)
+ {
+ /* Enable ints */
+ __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw));
+ return 1;
+ } else {
+ *spinlock=1;
+ /* Enable ints */
+ __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw));
+ return 0;
+ }
+}
+
+#endif
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h b/libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h
new file mode 100644
index 000000000..f5408ad08
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h
@@ -0,0 +1,17 @@
+/*
+ * sysdeps/microblaze/sigcontextinfo.h -- microblaze-specific pthread signal definitions
+ *
+ * Copyright (C) 2002 NEC Electronics Corporation
+ * Copyright (C) 2002 Miles Bader <miles@gnu.org>
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Miles Bader <miles@gnu.org>
+ */
+
+#include <signal.h>
+
+#define SIGCONTEXT struct sigcontext *
+#define SIGCONTEXT_EXTRA_ARGS