summaryrefslogtreecommitdiff
path: root/libpthread
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2007-11-16 14:26:46 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2007-11-16 14:26:46 +0000
commite130b681c43ee2215512ffcf6cadcbc4487e96e6 (patch)
tree107831cfb61595a907dff264d1bdbf02e18c53f5 /libpthread
parentc08b07bc9bff10988100653d280e8afe428249f7 (diff)
Added AVR32 support to uClibc. Signed-off-by: Hans-Christian Egtvedt <hcegtvedt@atmel.com>
Diffstat (limited to 'libpthread')
-rw-r--r--libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h73
-rw-r--r--libpthread/linuxthreads/sysdeps/avr32/pt-machine.h73
2 files changed, 146 insertions, 0 deletions
diff --git a/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
new file mode 100644
index 000000000..874c8d15e
--- /dev/null
+++ b/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
@@ -0,0 +1,73 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ *
+ * Copyright (C) 2005-2007 Atmel Corporation
+ *
+ * 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.
+ */
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#include <features.h>
+
+static inline int
+_test_and_set (int *p, int v)
+{
+ int result;
+
+ __asm__ __volatile__(
+ "/* Inline test and set */\n"
+ " xchg %[old], %[mem], %[new]"
+ : [old] "=&r"(result)
+ : [mem] "r"(p), [new] "r"(v)
+ : "memory");
+
+ return result;
+}
+
+#ifndef PT_EI
+# define PT_EI extern inline
+#endif
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+
+/* Spinlock implementation; required. */
+PT_EI long int
+testandset (int *spinlock)
+{
+ return _test_and_set(spinlock, 1);
+}
+
+
+/* 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__ ("sp");
+
+/* Compare-and-swap for semaphores. */
+
+#define HAS_COMPARE_AND_SWAP
+PT_EI int
+__compare_and_swap(long int *p, long int oldval, long int newval)
+{
+ long int result;
+
+ __asm__ __volatile__(
+ "/* Inline compare and swap */\n"
+ "1: ssrf 5\n"
+ " ld.w %[result], %[mem]\n"
+ " eor %[result], %[old]\n"
+ " brne 2f\n"
+ " stcond %[mem], %[new]\n"
+ " brne 1b\n"
+ "2:"
+ : [result] "=&r"(result), [mem] "=m"(*p)
+ : "m"(*p), [new] "r"(newval), [old] "r"(oldval)
+ : "cc", "memory");
+
+ return result == 0;
+}
+
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
new file mode 100644
index 000000000..9ff55586b
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
@@ -0,0 +1,73 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ *
+ * Copyright (C) 2005-2007 Atmel Corporation
+ *
+ * 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.
+ */
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#include <features.h>
+
+static inline int
+_test_and_set (int *p, int v) __THROW
+{
+ int result;
+
+ __asm__ __volatile__(
+ "/* Inline test and set */\n"
+ " xchg %[old], %[mem], %[new]"
+ : [old] "=&r"(result)
+ : [mem] "r"(p), [new] "r"(v)
+ : "memory");
+
+ return result;
+}
+
+#ifndef PT_EI
+# define PT_EI extern inline
+#endif
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+
+/* Spinlock implementation; required. */
+PT_EI long int
+testandset (int *spinlock)
+{
+ return _test_and_set(spinlock, 1);
+}
+
+
+/* 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__ ("sp");
+
+/* Compare-and-swap for semaphores. */
+
+#define HAS_COMPARE_AND_SWAP
+PT_EI int
+__compare_and_swap(long int *p, long int oldval, long int newval)
+{
+ int result;
+
+ __asm__ __volatile__(
+ "/* Inline compare and swap */\n"
+ "1: ssrf 5\n"
+ " ld.w %[result], %[mem]\n"
+ " eor %[result], %[old]\n"
+ " brne 2f\n"
+ " stcond %[mem], %[new]\n"
+ " brne 1b\n"
+ "2:"
+ : [result] "=&r"(result), [mem] "=m"(*p)
+ : "m"(*p), [new] "r"(newval), [old] "r"(oldval)
+ : "cc", "memory");
+
+ return result == 0;
+}
+
+#endif /* pt-machine.h */