summaryrefslogtreecommitdiffstats
path: root/libpthread
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2008-03-16 08:54:38 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2008-03-16 08:54:38 +0000
commite0a7506f8ec11c1c524fe1d6b52781d168e988db (patch)
tree2dcf7858f0c7d236efe32db885baa9379358ec8a /libpthread
parente772b90e7e8190112a987f7c18c19a33766acfd0 (diff)
downloaduClibc-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')
-rw-r--r--libpthread/linuxthreads.old/attr.c26
-rw-r--r--libpthread/linuxthreads.old/cancel.c7
-rw-r--r--libpthread/linuxthreads.old/condvar.c18
-rw-r--r--libpthread/linuxthreads.old/join.c2
-rw-r--r--libpthread/linuxthreads.old/manager.c7
-rw-r--r--libpthread/linuxthreads.old/pthread.c41
-rw-r--r--libpthread/linuxthreads.old/sysdeps/alpha/pt-machine.h7
-rw-r--r--libpthread/linuxthreads.old/sysdeps/arm/pt-machine.h7
-rw-r--r--libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h73
-rw-r--r--libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h53
-rw-r--r--libpthread/linuxthreads.old/sysdeps/cris/pt-machine.h8
-rw-r--r--libpthread/linuxthreads.old/sysdeps/frv/pt-machine.h4
-rw-r--r--libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h6
-rw-r--r--libpthread/linuxthreads.old/sysdeps/i386/pt-machine.h6
-rw-r--r--libpthread/linuxthreads.old/sysdeps/ia64/pt-machine.h6
-rw-r--r--libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h7
-rw-r--r--libpthread/linuxthreads.old/sysdeps/mips/pt-machine.h12
-rw-r--r--libpthread/linuxthreads.old/sysdeps/nios/pt-machine.h5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/nios2/pt-machine.h6
-rw-r--r--libpthread/linuxthreads.old/sysdeps/powerpc/pt-machine.h7
-rw-r--r--libpthread/linuxthreads.old/sysdeps/pthread/pthread.h5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sh/pt-machine.h7
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.h13
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sparc/sparc32/pt-machine.h2
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sparc/sparc64/pt-machine.h2
-rw-r--r--libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h8
-rw-r--r--libpthread/linuxthreads.old/sysdeps/x86_64/pt-machine.h19
-rw-r--r--libpthread/linuxthreads.old/sysdeps/xtensa/pt-machine.h48
-rw-r--r--libpthread/linuxthreads.old/wrapsyscall.c2
-rw-r--r--libpthread/linuxthreads/descr.h2
-rw-r--r--libpthread/linuxthreads/internals.h4
-rw-r--r--libpthread/linuxthreads/sysdeps/alpha/pt-machine.h7
-rw-r--r--libpthread/linuxthreads/sysdeps/arm/pt-machine.h7
-rw-r--r--libpthread/linuxthreads/sysdeps/avr32/pt-machine.h73
-rw-r--r--libpthread/linuxthreads/sysdeps/cris/pt-machine.h7
-rw-r--r--libpthread/linuxthreads/sysdeps/hppa/pt-machine.h6
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h2
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/pt-machine.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/useldt.h2
-rw-r--r--libpthread/linuxthreads/sysdeps/ia64/pt-machine.h6
-rw-r--r--libpthread/linuxthreads/sysdeps/m68k/pt-machine.h7
-rw-r--r--libpthread/linuxthreads/sysdeps/mips/pt-machine.h7
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h2
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h2
-rw-r--r--libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h2
-rw-r--r--libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h2
-rw-r--r--libpthread/linuxthreads/sysdeps/sh/pt-machine.h7
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h2
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h2
-rw-r--r--libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h7
50 files changed, 445 insertions, 130 deletions
diff --git a/libpthread/linuxthreads.old/attr.c b/libpthread/linuxthreads.old/attr.c
index 9deeee0ef..30294afe4 100644
--- a/libpthread/linuxthreads.old/attr.c
+++ b/libpthread/linuxthreads.old/attr.c
@@ -25,6 +25,19 @@
#include "pthread.h"
#include "internals.h"
+libpthread_hidden_proto(pthread_attr_destroy)
+libpthread_hidden_proto(pthread_attr_init)
+libpthread_hidden_proto(pthread_attr_getdetachstate)
+libpthread_hidden_proto(pthread_attr_setdetachstate)
+libpthread_hidden_proto(pthread_attr_getinheritsched)
+libpthread_hidden_proto(pthread_attr_setinheritsched)
+libpthread_hidden_proto(pthread_attr_setschedparam)
+libpthread_hidden_proto(pthread_attr_getschedparam)
+libpthread_hidden_proto(pthread_attr_getschedpolicy)
+libpthread_hidden_proto(pthread_attr_setschedpolicy)
+libpthread_hidden_proto(pthread_attr_getscope)
+libpthread_hidden_proto(pthread_attr_setscope)
+
/* NOTE: With uClibc I don't think we need this versioning stuff.
* Therefore, define the function pthread_attr_init() here using
* a strong symbol. */
@@ -45,6 +58,7 @@ int pthread_attr_init(pthread_attr_t *attr)
attr->__stacksize = STACK_SIZE - ps;
return 0;
}
+libpthread_hidden_def(pthread_attr_init)
/* uClibc: leave out this for now. */
#if DO_PTHREAD_VERSIONING_WITH_UCLIBC
@@ -70,6 +84,8 @@ int pthread_attr_destroy(pthread_attr_t *attr attribute_unused)
{
return 0;
}
+libpthread_hidden_def(pthread_attr_destroy)
+
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
{
@@ -79,12 +95,14 @@ int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
attr->__detachstate = detachstate;
return 0;
}
+libpthread_hidden_def(pthread_attr_setdetachstate)
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
{
*detachstate = attr->__detachstate;
return 0;
}
+libpthread_hidden_def(pthread_attr_getdetachstate)
int pthread_attr_setschedparam(pthread_attr_t *attr,
const struct sched_param *param)
@@ -97,6 +115,7 @@ int pthread_attr_setschedparam(pthread_attr_t *attr,
memcpy (&attr->__schedparam, param, sizeof (struct sched_param));
return 0;
}
+libpthread_hidden_def(pthread_attr_setschedparam)
int pthread_attr_getschedparam(const pthread_attr_t *attr,
struct sched_param *param)
@@ -104,6 +123,7 @@ int pthread_attr_getschedparam(const pthread_attr_t *attr,
memcpy (param, &attr->__schedparam, sizeof (struct sched_param));
return 0;
}
+libpthread_hidden_def(pthread_attr_getschedparam)
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
{
@@ -112,12 +132,14 @@ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
attr->__schedpolicy = policy;
return 0;
}
+libpthread_hidden_def(pthread_attr_setschedpolicy)
int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy)
{
*policy = attr->__schedpolicy;
return 0;
}
+libpthread_hidden_def(pthread_attr_getschedpolicy)
int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit)
{
@@ -126,12 +148,14 @@ int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit)
attr->__inheritsched = inherit;
return 0;
}
+libpthread_hidden_def(pthread_attr_setinheritsched)
int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit)
{
*inherit = attr->__inheritsched;
return 0;
}
+libpthread_hidden_def(pthread_attr_getinheritsched)
int pthread_attr_setscope(pthread_attr_t *attr, int scope)
{
@@ -145,12 +169,14 @@ int pthread_attr_setscope(pthread_attr_t *attr, int scope)
return EINVAL;
}
}
+libpthread_hidden_def(pthread_attr_setscope)
int pthread_attr_getscope(const pthread_attr_t *attr, int *scope)
{
*scope = attr->__scope;
return 0;
}
+libpthread_hidden_def(pthread_attr_getscope)
int __pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
{
diff --git a/libpthread/linuxthreads.old/cancel.c b/libpthread/linuxthreads.old/cancel.c
index ac66c5855..79409675f 100644
--- a/libpthread/linuxthreads.old/cancel.c
+++ b/libpthread/linuxthreads.old/cancel.c
@@ -37,6 +37,8 @@ extern void __rpc_thread_destroy(void);
# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
#endif
+libpthread_hidden_proto(pthread_setcancelstate)
+libpthread_hidden_proto(pthread_setcanceltype)
int pthread_setcancelstate(int state, int * oldstate)
{
@@ -51,6 +53,7 @@ int pthread_setcancelstate(int state, int * oldstate)
__pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
return 0;
}
+libpthread_hidden_def(pthread_setcancelstate)
int pthread_setcanceltype(int type, int * oldtype)
{
@@ -65,6 +68,7 @@ int pthread_setcanceltype(int type, int * oldtype)
__pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
return 0;
}
+libpthread_hidden_def(pthread_setcanceltype)
int pthread_cancel(pthread_t thread)
{
@@ -165,6 +169,7 @@ void _pthread_cleanup_push_defer(struct _pthread_cleanup_buffer * buffer,
THREAD_SETMEM(self, p_canceltype, PTHREAD_CANCEL_DEFERRED);
THREAD_SETMEM(self, p_cleanup, buffer);
}
+strong_alias(_pthread_cleanup_push_defer,__pthread_cleanup_push_defer)
void _pthread_cleanup_pop_restore(struct _pthread_cleanup_buffer * buffer,
int execute)
@@ -178,6 +183,8 @@ void _pthread_cleanup_pop_restore(struct _pthread_cleanup_buffer * buffer,
THREAD_GETMEM(self, p_canceltype) == PTHREAD_CANCEL_ASYNCHRONOUS)
__pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
}
+strong_alias(_pthread_cleanup_pop_restore,__pthread_cleanup_pop_restore)
+
void __pthread_perform_cleanup(char *currentframe)
{
diff --git a/libpthread/linuxthreads.old/condvar.c b/libpthread/linuxthreads.old/condvar.c
index 3d77f781a..23e71393c 100644
--- a/libpthread/linuxthreads.old/condvar.c
+++ b/libpthread/linuxthreads.old/condvar.c
@@ -25,6 +25,16 @@
#include "queue.h"
#include "restart.h"
+libpthread_hidden_proto(pthread_cond_broadcast)
+libpthread_hidden_proto(pthread_cond_destroy)
+libpthread_hidden_proto(pthread_cond_init)
+libpthread_hidden_proto(pthread_cond_signal)
+libpthread_hidden_proto(pthread_cond_wait)
+libpthread_hidden_proto(pthread_cond_timedwait)
+
+libpthread_hidden_proto(pthread_condattr_destroy)
+libpthread_hidden_proto(pthread_condattr_init)
+
int pthread_cond_init(pthread_cond_t *cond,
const pthread_condattr_t *cond_attr attribute_unused)
{
@@ -32,12 +42,14 @@ int pthread_cond_init(pthread_cond_t *cond,
cond->__c_waiting = NULL;
return 0;
}
+libpthread_hidden_def(pthread_cond_init)
int pthread_cond_destroy(pthread_cond_t *cond)
{
if (cond->__c_waiting != NULL) return EBUSY;
return 0;
}
+libpthread_hidden_def(pthread_cond_destroy)
/* Function called by pthread_cancel to remove the thread from
waiting on a condition variable queue. */
@@ -132,6 +144,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
__pthread_mutex_lock(mutex);
return 0;
}
+libpthread_hidden_def(pthread_cond_wait)
static int
pthread_cond_timedwait_relative(pthread_cond_t *cond,
@@ -233,6 +246,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
/* Indirect call through pointer! */
return pthread_cond_timedwait_relative(cond, mutex, abstime);
}
+libpthread_hidden_def(pthread_cond_timedwait)
int pthread_cond_signal(pthread_cond_t *cond)
{
@@ -248,6 +262,7 @@ int pthread_cond_signal(pthread_cond_t *cond)
}
return 0;
}
+libpthread_hidden_def(pthread_cond_signal)
int pthread_cond_broadcast(pthread_cond_t *cond)
{
@@ -266,16 +281,19 @@ int pthread_cond_broadcast(pthread_cond_t *cond)
}
return 0;
}
+libpthread_hidden_def(pthread_cond_broadcast)
int pthread_condattr_init(pthread_condattr_t *attr attribute_unused)
{
return 0;
}
+libpthread_hidden_def(pthread_condattr_init)
int pthread_condattr_destroy(pthread_condattr_t *attr attribute_unused)
{
return 0;
}
+libpthread_hidden_def(pthread_condattr_destroy)
int pthread_condattr_getpshared (const pthread_condattr_t *attr attribute_unused, int *pshared)
{
diff --git a/libpthread/linuxthreads.old/join.c b/libpthread/linuxthreads.old/join.c
index 4bdc77a25..250b47166 100644
--- a/libpthread/linuxthreads.old/join.c
+++ b/libpthread/linuxthreads.old/join.c
@@ -25,10 +25,12 @@
#include "restart.h"
#include "debug.h" /* PDEBUG, added by StS */
+libpthread_hidden_proto (pthread_exit)
void pthread_exit(void * retval)
{
__pthread_do_exit (retval, CURRENT_STACK_FRAME);
}
+libpthread_hidden_def (pthread_exit)
void __pthread_do_exit(void *retval, char *currentframe)
{
diff --git a/libpthread/linuxthreads.old/manager.c b/libpthread/linuxthreads.old/manager.c
index cad2aacdf..fc39b1e25 100644
--- a/libpthread/linuxthreads.old/manager.c
+++ b/libpthread/linuxthreads.old/manager.c
@@ -355,6 +355,13 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
guardaddr = NULL;
guardsize = 0;
__pthread_nonstandard_stacks = 1;
+#ifndef __ARCH_USE_MMU__
+ /* check the initial thread stack boundaries so they don't overlap */
+ NOMMU_INITIAL_THREAD_BOUNDS((char *) new_thread, (char *) new_thread_bottom);
+
+ PDEBUG("initial stack: bos=%p, tos=%p\n", __pthread_initial_thread_bos,
+ __pthread_initial_thread_tos);
+#endif
}
else
{
diff --git a/libpthread/linuxthreads.old/pthread.c b/libpthread/linuxthreads.old/pthread.c
index 19e826515..bdb64fdff 100644
--- a/libpthread/linuxthreads.old/pthread.c
+++ b/libpthread/linuxthreads.old/pthread.c
@@ -284,6 +284,41 @@ int __libc_allocate_rtsig (int high)
static void pthread_initialize(void) __attribute__((constructor));
+libpthread_hidden_proto(pthread_attr_destroy)
+libpthread_hidden_proto(pthread_attr_init)
+libpthread_hidden_proto(pthread_attr_getdetachstate)
+libpthread_hidden_proto(pthread_attr_setdetachstate)
+libpthread_hidden_proto(pthread_attr_getinheritsched)
+libpthread_hidden_proto(pthread_attr_setinheritsched)
+libpthread_hidden_proto(pthread_attr_setschedparam)
+libpthread_hidden_proto(pthread_attr_getschedparam)
+libpthread_hidden_proto(pthread_attr_getschedpolicy)
+libpthread_hidden_proto(pthread_attr_setschedpolicy)
+libpthread_hidden_proto(pthread_attr_getscope)
+libpthread_hidden_proto(pthread_attr_setscope)
+
+libpthread_hidden_proto(pthread_exit)
+
+libpthread_hidden_proto(pthread_equal)
+libpthread_hidden_proto(pthread_self)
+libpthread_hidden_proto(pthread_getschedparam)
+libpthread_hidden_proto(pthread_setschedparam)
+
+libpthread_hidden_proto(pthread_setcancelstate)
+libpthread_hidden_proto(pthread_setcanceltype)
+libpthread_hidden_proto(_pthread_cleanup_push_defer)
+libpthread_hidden_proto(_pthread_cleanup_pop_restore)
+
+libpthread_hidden_proto(pthread_cond_broadcast)
+libpthread_hidden_proto(pthread_cond_destroy)
+libpthread_hidden_proto(pthread_cond_init)
+libpthread_hidden_proto(pthread_cond_signal)
+libpthread_hidden_proto(pthread_cond_wait)
+libpthread_hidden_proto(pthread_cond_timedwait)
+
+libpthread_hidden_proto(pthread_condattr_destroy)
+libpthread_hidden_proto(pthread_condattr_init)
+
struct pthread_functions __pthread_functions =
{
#if !(USE_TLS && HAVE___THREAD)
@@ -638,11 +673,13 @@ pthread_t pthread_self(void)
pthread_descr self = thread_self();
return THREAD_GETMEM(self, p_tid);
}
-
+libpthread_hidden_def (pthread_self)
+
int pthread_equal(pthread_t thread1, pthread_t thread2)
{
return thread1 == thread2;
}
+libpthread_hidden_def (pthread_equal)
/* Helper function for thread_self in the case of user-provided stacks */
@@ -714,6 +751,7 @@ int pthread_setschedparam(pthread_t thread, int policy,
__pthread_manager_adjust_prio(th->p_priority);
return 0;
}
+libpthread_hidden_def(pthread_setschedparam)
int pthread_getschedparam(pthread_t thread, int *policy,
struct sched_param *param)
@@ -734,6 +772,7 @@ int pthread_getschedparam(pthread_t thread, int *policy,
*policy = pol;
return 0;
}
+libpthread_hidden_def(pthread_getschedparam)
/* Process-wide exit() request */
diff --git a/libpthread/linuxthreads.old/sysdeps/alpha/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/alpha/pt-machine.h
index 853ac6f04..97c38394b 100644
--- a/libpthread/linuxthreads.old/sysdeps/alpha/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/alpha/pt-machine.h
@@ -23,8 +23,10 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
+
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
#ifdef __linux__
@@ -33,9 +35,6 @@
# include <machine/pal.h>
#endif
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
/* 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
diff --git a/libpthread/linuxthreads.old/sysdeps/arm/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/arm/pt-machine.h
index 284567970..14eb6f6da 100644
--- a/libpthread/linuxthreads.old/sysdeps/arm/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/arm/pt-machine.h
@@ -22,13 +22,12 @@
#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 int *p, long int oldval, long int newval);
-
/* This will not work on ARM1 or ARM2 because SWP is lacking on those
machines. Unfortunately we have no way to detect this at compile
time; let's hope nobody tries to use one. */
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..c9669f2d3
--- /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>
+
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
+#endif
+
+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;
+}
+
+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.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 */
diff --git a/libpthread/linuxthreads.old/sysdeps/cris/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/cris/pt-machine.h
index a287e866a..6d626fb4b 100644
--- a/libpthread/linuxthreads.old/sysdeps/cris/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/cris/pt-machine.h
@@ -17,9 +17,13 @@
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#include <features.h>
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
PT_EI long int
@@ -62,3 +66,5 @@ testandset (int *spinlock)
I don't trust register variables, so let's do this the safe way. */
#define CURRENT_STACK_FRAME \
({ char *sp; __asm__ ("move.d $sp,%0" : "=rm" (sp)); sp; })
+
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/frv/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/frv/pt-machine.h
index 64df5ffdb..2317b65a0 100644
--- a/libpthread/linuxthreads.old/sysdeps/frv/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/frv/pt-machine.h
@@ -22,10 +22,12 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
+
#ifndef __ASSEMBLER__
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
/* Spinlock implementation; required. */
diff --git a/libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h
index ad83147cb..121f496d7 100644
--- a/libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h
@@ -22,12 +22,12 @@
#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);
-
/* Spinlock implementation; required. */
PT_EI long int
testandset (int *spinlock)
diff --git a/libpthread/linuxthreads.old/sysdeps/i386/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/i386/pt-machine.h
index af1818d7b..989641439 100644
--- a/libpthread/linuxthreads.old/sysdeps/i386/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/i386/pt-machine.h
@@ -22,13 +22,17 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
+
#ifndef __ASSEMBLER__
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
+/*
extern long int testandset (int *spinlock);
extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+*/
/* Get some notion of the current stack. Need not be exactly the top
of the stack, just something somewhere in the current frame. */
diff --git a/libpthread/linuxthreads.old/sysdeps/ia64/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/ia64/pt-machine.h
index a5ffec48d..668057a2a 100644
--- a/libpthread/linuxthreads.old/sysdeps/ia64/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/ia64/pt-machine.h
@@ -21,6 +21,7 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
#include <ia64intrin.h>
#include <sys/types.h>
@@ -28,12 +29,9 @@ extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
size_t __child_stack_size, int __flags, void *__arg, ...);
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
/* Make sure gcc doesn't try to be clever and move things around on
us. We need to use _exactly_ the address the user gave us, not some
alias that contains the same information. */
diff --git a/libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h
index 4670ae3c4..295495baf 100644
--- a/libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h
@@ -22,13 +22,12 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
+
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_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)
diff --git a/libpthread/linuxthreads.old/sysdeps/mips/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/mips/pt-machine.h
index 0bf7fc5b0..638952846 100644
--- a/libpthread/linuxthreads.old/sysdeps/mips/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/mips/pt-machine.h
@@ -26,6 +26,10 @@
#include <features.h>
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
+#endif
+
/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Maciej W. Rozycki <macro@ds2.pg.gda.pl>, 2000. */
@@ -55,14 +59,6 @@ __NTH (_test_and_set (int *p, int v))
}
-#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_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
diff --git a/libpthread/linuxthreads.old/sysdeps/nios/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/nios/pt-machine.h
index 5d82b8d16..140455013 100644
--- a/libpthread/linuxthreads.old/sysdeps/nios/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/nios/pt-machine.h
@@ -22,11 +22,12 @@
#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);
/* Spinlock implementation; required. */
/* it is weird and dangerous to disable interrupt in userspace, but for nios
what else we can do before we have a swap like instruction? This is better
diff --git a/libpthread/linuxthreads.old/sysdeps/nios2/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/nios2/pt-machine.h
index 484a77e14..061fa735e 100644
--- a/libpthread/linuxthreads.old/sysdeps/nios2/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/nios2/pt-machine.h
@@ -21,12 +21,12 @@
#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);
-
/* Spinlock implementation; required. */
PT_EI long int
testandset (int *spinlock)
diff --git a/libpthread/linuxthreads.old/sysdeps/powerpc/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/powerpc/pt-machine.h
index 9e6543a26..561f8958e 100644
--- a/libpthread/linuxthreads.old/sysdeps/powerpc/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/powerpc/pt-machine.h
@@ -24,13 +24,12 @@
#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 int *p, long int oldval, long int newval);
-
/* For multiprocessor systems, we want to ensure all memory accesses
are completed before we reset a lock. On other systems, we still
need to make sure that the compiler has flushed everything to memory. */
diff --git a/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h b/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h
index 448636bd9..870e37fa5 100644
--- a/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h
+++ b/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h
@@ -635,6 +635,9 @@ extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffer,
void (*__routine) (void *),
void *__arg) __THROW;
+extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffer,
+ void (*__routine) (void *),
+ void *__arg) __THROW;
/* Remove a cleanup handler as pthread_cleanup_pop does, but also
restores the cancellation type that was in effect when the matching
@@ -645,6 +648,8 @@ extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffe
extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *__buffer,
int __execute) __THROW;
+extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *__buffer,
+ int __execute) __THROW;
#endif
diff --git a/libpthread/linuxthreads.old/sysdeps/sh/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/sh/pt-machine.h
index 02545e6b4..4ec87ad89 100644
--- a/libpthread/linuxthreads.old/sysdeps/sh/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/sh/pt-machine.h
@@ -22,14 +22,13 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
+
#ifndef __ASSEMBLER__
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_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)
diff --git a/libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.h
index 8269a4cb3..b87448a75 100644
--- a/libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.h
@@ -22,15 +22,18 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#ifndef PT_EI
-# define PT_EI extern inline
-#endif
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
-/* Spinlock implementation; required. */
-extern long int testandset (int *spinlock);
+#include <features.h>
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
+#endif
/* 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__ ("r15");
+
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/sparc/sparc32/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/sparc/sparc32/pt-machine.h
index 322a52051..43c05f2a6 100644
--- a/libpthread/linuxthreads.old/sysdeps/sparc/sparc32/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/sparc/sparc32/pt-machine.h
@@ -23,7 +23,7 @@
#define _PT_MACHINE_H 1
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
extern long int testandset (int *spinlock);
diff --git a/libpthread/linuxthreads.old/sysdeps/sparc/sparc64/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/sparc/sparc64/pt-machine.h
index f65c13be1..815d70e8d 100644
--- a/libpthread/linuxthreads.old/sysdeps/sparc/sparc64/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/sparc/sparc64/pt-machine.h
@@ -23,7 +23,7 @@
#define _PT_MACHINE_H 1
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
extern long int testandset (int *spinlock);
diff --git a/libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h
index fb41c41e9..34de63b9f 100644
--- a/libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h
@@ -11,8 +11,13 @@
* 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
+# define PT_EI __extern_always_inline
#endif
/* Get some notion of the current stack. Need not be exactly the top
@@ -44,3 +49,4 @@ __compare_and_swap (long *ptr, long old, long new)
return 0;
}
}
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/x86_64/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/x86_64/pt-machine.h
index 8a2d1a762..ce07bbb03 100644
--- a/libpthread/linuxthreads.old/sysdeps/x86_64/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/x86_64/pt-machine.h
@@ -21,6 +21,8 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
+
#ifndef __ASSEMBLER__
# include <stddef.h> /* For offsetof. */
# include <stdlib.h> /* For abort(). */
@@ -28,12 +30,9 @@
# ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
# endif
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
/* 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
@@ -42,14 +41,14 @@ register char * stack_pointer __asm__ ("%rsp") __attribute_used__;
/* Spinlock implementation; required. */
PT_EI long int
-testandset (int *spinlock)
+testandset (int *__spinlock)
{
long int ret;
__asm__ __volatile__ (
"xchgl %k0, %1"
- : "=r"(ret), "=m"(*spinlock)
- : "0"(1), "m"(*spinlock)
+ : "=r"(ret), "=m"(*__spinlock)
+ : "0"(1), "m"(*__spinlock)
: "memory");
return ret;
@@ -60,14 +59,14 @@ testandset (int *spinlock)
# define HAS_COMPARE_AND_SWAP
PT_EI int
-__compare_and_swap (long int *p, long int oldval, long int newval)
+__compare_and_swap (long int *__p, long int __oldval, long int __newval)
{
char ret;
long int readval;
__asm__ __volatile__ ("lock; cmpxchgq %3, %1; sete %0"
- : "=q" (ret), "=m" (*p), "=a" (readval)
- : "r" (newval), "m" (*p), "a" (oldval)
+ : "=q" (ret), "=m" (*__p), "=a" (readval)
+ : "r" (__newval), "m" (*__p), "a" (__oldval)
: "memory");
return ret;
}
diff --git a/libpthread/linuxthreads.old/sysdeps/xtensa/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/xtensa/pt-machine.h
new file mode 100644
index 000000000..acd4d109f
--- /dev/null
+++ b/libpthread/linuxthreads.old/sysdeps/xtensa/pt-machine.h
@@ -0,0 +1,48 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ Xtensa version.
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#include <sys/syscall.h>
+#include <asm/unistd.h>
+
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
+#endif
+
+/* Memory barrier. */
+#define MEMORY_BARRIER() __asm__ ("memw" : : : "memory")
+
+/* Spinlock implementation; required. */
+PT_EI long int
+testandset (int *spinlock)
+{
+ int unused = 0;
+ return INTERNAL_SYSCALL (xtensa, , 4, SYS_XTENSA_ATOMIC_SET,
+ spinlock, 1, unused);
+}
+
+/* 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 __builtin_frame_address (0)
+
+#endif /* _PT_MACHINE_H */
diff --git a/libpthread/linuxthreads.old/wrapsyscall.c b/libpthread/linuxthreads.old/wrapsyscall.c
index 684989be0..c1ddcb8fe 100644
--- a/libpthread/linuxthreads.old/wrapsyscall.c
+++ b/libpthread/linuxthreads.old/wrapsyscall.c
@@ -98,7 +98,7 @@ CANCELABLE_SYSCALL (off64_t, lseek64, (int fd, off64_t offset, int whence),
#ifdef __NR_msync
/* msync(2). */
-CANCELABLE_SYSCALL (int, msync, (__ptr_t addr, size_t length, int flags),
+CANCELABLE_SYSCALL (int, msync, (void *addr, size_t length, int flags),
(addr, length, flags))
#endif
diff --git a/libpthread/linuxthreads/descr.h b/libpthread/linuxthreads/descr.h
index f99638396..0f50d4deb 100644
--- a/libpthread/linuxthreads/descr.h
+++ b/libpthread/linuxthreads/descr.h
@@ -130,7 +130,7 @@ struct _pthread_descr_struct
void *__padding[16];
} p_header;
# define p_multiple_threads p_header.data.multiple_threads
-#elif TLS_MULTIPLE_THREADS_IN_TCB
+#elif defined TLS_MULTIPLE_THREADS_IN_TCB && TLS_MULTIPLE_THREADS_IN_TCB
int p_multiple_threads;
#endif
diff --git a/libpthread/linuxthreads/internals.h b/libpthread/linuxthreads/internals.h
index c8e4262d6..8e270e37a 100644
--- a/libpthread/linuxthreads/internals.h
+++ b/libpthread/linuxthreads/internals.h
@@ -531,9 +531,9 @@ weak_extern (__pthread_thread_self)
# define __manager_thread __pthread_manager_threadp
#endif
-extern __always_inline pthread_descr
+static __always_inline pthread_descr
check_thread_self (void);
-extern __always_inline pthread_descr
+static __always_inline pthread_descr
check_thread_self (void)
{
pthread_descr self = thread_self ();
diff --git a/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h b/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h
index 853ac6f04..97c38394b 100644
--- a/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h
@@ -23,8 +23,10 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
+
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
#ifdef __linux__
@@ -33,9 +35,6 @@
# include <machine/pal.h>
#endif
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
/* 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
diff --git a/libpthread/linuxthreads/sysdeps/arm/pt-machine.h b/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
index a4c2f314c..9ffc8bdc4 100644
--- a/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
@@ -22,13 +22,12 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
+
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
/* This will not work on ARM1 or ARM2 because SWP is lacking on those
machines. Unfortunately we have no way to detect this at compile
time; let's hope nobody tries to use one. */
diff --git a/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
new file mode 100644
index 000000000..903a7ed54
--- /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>
+
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
+#endif
+
+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;
+}
+
+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 */
diff --git a/libpthread/linuxthreads/sysdeps/cris/pt-machine.h b/libpthread/linuxthreads/sysdeps/cris/pt-machine.h
index 431da7101..33cf57908 100644
--- a/libpthread/linuxthreads/sysdeps/cris/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/cris/pt-machine.h
@@ -21,13 +21,12 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
+
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
PT_EI long int
testandset (int *spinlock)
{
diff --git a/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h b/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h
index abc25c4ca..780af7b96 100644
--- a/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h
@@ -22,15 +22,13 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
#include <bits/initspin.h>
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
/* 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
diff --git a/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h b/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h
index 1c75bf980..222d44a3f 100644
--- a/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h
@@ -23,7 +23,7 @@
#define _PT_MACHINE_H 1
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
#include "kernel-features.h"
diff --git a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h b/libpthread/linuxthreads/sysdeps/i386/pt-machine.h
index 8483d4ef6..f96452599 100644
--- a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/i386/pt-machine.h
@@ -29,12 +29,13 @@
#ifndef __ASSEMBLER__
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
+/*
extern long int testandset (int *spinlock);
extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
+*/
/* 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 __builtin_frame_address (0)
diff --git a/libpthread/linuxthreads/sysdeps/i386/useldt.h b/libpthread/linuxthreads/sysdeps/i386/useldt.h
index a2eb53fed..fa9a2a528 100644
--- a/libpthread/linuxthreads/sysdeps/i386/useldt.h
+++ b/libpthread/linuxthreads/sysdeps/i386/useldt.h
@@ -87,7 +87,7 @@ extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t);
because we inherited the value set up in the main thread by TLS setup.
We need to extract that value and set up the same segment in this
thread. */
-#if USE_TLS
+#if defined (USE_TLS) && USE_TLS
# define DO_SET_THREAD_AREA_REUSE(nr) 1
#else
/* Without TLS, we do the initialization of the main thread, where NR == 0. */
diff --git a/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h b/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h
index be1d37986..e36468a74 100644
--- a/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h
@@ -21,15 +21,13 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
#include <ia64intrin.h>
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
/* Make sure gcc doesn't try to be clever and move things around on
us. We need to use _exactly_ the address the user gave us, not some
alias that contains the same information. */
diff --git a/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h b/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
index ad524d6d2..a13c06946 100644
--- a/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
@@ -22,13 +22,12 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
+
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_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)
diff --git a/libpthread/linuxthreads/sysdeps/mips/pt-machine.h b/libpthread/linuxthreads/sysdeps/mips/pt-machine.h
index 96f7a7f8c..0ab7ac13f 100644
--- a/libpthread/linuxthreads/sysdeps/mips/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/mips/pt-machine.h
@@ -24,17 +24,14 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
#include <sgidefs.h>
#include <sys/tas.h>
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_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
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h
index 8363d16d0..bfb13df67 100644
--- a/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h
@@ -26,7 +26,7 @@
#define _PT_MACHINE_H 1
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
extern long int testandset (int *spinlock);
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h
index 562e69fa1..d7ed84108 100644
--- a/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h
@@ -25,7 +25,7 @@
#define _PT_MACHINE_H 1
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
extern long int testandset (int *spinlock);
diff --git a/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h b/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h
index 398332965..d52d600ad 100644
--- a/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h
@@ -23,7 +23,7 @@
#define _PT_MACHINE_H 1
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
extern long int testandset (int *spinlock);
diff --git a/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h b/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h
index 49f8ae2b9..187e1f872 100644
--- a/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h
@@ -23,7 +23,7 @@
#define _PT_MACHINE_H 1
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
extern long int testandset (int *spinlock);
diff --git a/libpthread/linuxthreads/sysdeps/sh/pt-machine.h b/libpthread/linuxthreads/sysdeps/sh/pt-machine.h
index 02545e6b4..4ec87ad89 100644
--- a/libpthread/linuxthreads/sysdeps/sh/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/sh/pt-machine.h
@@ -22,14 +22,13 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <features.h>
+
#ifndef __ASSEMBLER__
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_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)
diff --git a/libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h b/libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h
index 322a52051..43c05f2a6 100644
--- a/libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h
@@ -23,7 +23,7 @@
#define _PT_MACHINE_H 1
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
extern long int testandset (int *spinlock);
diff --git a/libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h b/libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h
index f65c13be1..815d70e8d 100644
--- a/libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h
@@ -23,7 +23,7 @@
#define _PT_MACHINE_H 1
#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
#endif
extern long int testandset (int *spinlock);
diff --git a/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h b/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h
index b30ab8518..23615dbd8 100644
--- a/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h
@@ -21,6 +21,8 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+# include <features.h>
+
#ifndef __ASSEMBLER__
# include <stddef.h> /* For offsetof. */
# include <stdlib.h> /* For abort(). */
@@ -28,12 +30,9 @@
# ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((always_inline))
+# define PT_EI __extern_always_inline
# endif
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
/* 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