summaryrefslogtreecommitdiff
path: root/libpthread/sysdeps/i386
diff options
context:
space:
mode:
authorroot <root@(null).(none)>2009-05-03 17:20:00 +0200
committerroot <root@(null).(none)>2009-05-03 17:20:00 +0200
commite0faf22f31c48fb27b43c1825897d26e58feafc4 (patch)
tree65a09372b31e08a3a865bd0a88cd2718bafcd643 /libpthread/sysdeps/i386
This is my initial working version.
There is a bug in boot in this version: subhurd sometimes cannot boot.
Diffstat (limited to 'libpthread/sysdeps/i386')
-rw-r--r--libpthread/sysdeps/i386/CVS/Entries3
-rw-r--r--libpthread/sysdeps/i386/CVS/Repository1
-rw-r--r--libpthread/sysdeps/i386/CVS/Root1
-rw-r--r--libpthread/sysdeps/i386/CVS/Tag1
-rw-r--r--libpthread/sysdeps/i386/bits/CVS/Entries4
-rw-r--r--libpthread/sysdeps/i386/bits/CVS/Repository1
-rw-r--r--libpthread/sysdeps/i386/bits/CVS/Root1
-rw-r--r--libpthread/sysdeps/i386/bits/CVS/Tag1
-rw-r--r--libpthread/sysdeps/i386/bits/atomic.h66
-rw-r--r--libpthread/sysdeps/i386/bits/memory.h40
-rw-r--r--libpthread/sysdeps/i386/bits/spin-lock.h103
-rw-r--r--libpthread/sysdeps/i386/machine-sp.h30
-rw-r--r--libpthread/sysdeps/i386/pt-machdep.h29
13 files changed, 281 insertions, 0 deletions
diff --git a/libpthread/sysdeps/i386/CVS/Entries b/libpthread/sysdeps/i386/CVS/Entries
new file mode 100644
index 00000000..2f9b7418
--- /dev/null
+++ b/libpthread/sysdeps/i386/CVS/Entries
@@ -0,0 +1,3 @@
+/machine-sp.h/1.3/Tue Jul 1 11:43:17 2008//Tzhengda-soc2008-virt-branch
+/pt-machdep.h/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+D/bits////
diff --git a/libpthread/sysdeps/i386/CVS/Repository b/libpthread/sysdeps/i386/CVS/Repository
new file mode 100644
index 00000000..61a58d3a
--- /dev/null
+++ b/libpthread/sysdeps/i386/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/i386
diff --git a/libpthread/sysdeps/i386/CVS/Root b/libpthread/sysdeps/i386/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/i386/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/i386/CVS/Tag b/libpthread/sysdeps/i386/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/i386/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/i386/bits/CVS/Entries b/libpthread/sysdeps/i386/bits/CVS/Entries
new file mode 100644
index 00000000..500bd95c
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/CVS/Entries
@@ -0,0 +1,4 @@
+/atomic.h/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/memory.h/1.3/Tue Jul 1 11:43:17 2008//Tzhengda-soc2008-virt-branch
+/spin-lock.h/1.5/Tue Jul 1 11:43:17 2008//Tzhengda-soc2008-virt-branch
+D
diff --git a/libpthread/sysdeps/i386/bits/CVS/Repository b/libpthread/sysdeps/i386/bits/CVS/Repository
new file mode 100644
index 00000000..9ddbe855
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/i386/bits
diff --git a/libpthread/sysdeps/i386/bits/CVS/Root b/libpthread/sysdeps/i386/bits/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/i386/bits/CVS/Tag b/libpthread/sysdeps/i386/bits/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/i386/bits/atomic.h b/libpthread/sysdeps/i386/bits/atomic.h
new file mode 100644
index 00000000..0dfc1f60
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/atomic.h
@@ -0,0 +1,66 @@
+/* Atomic operations. i386 version.
+ Copyright (C) 2000 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ 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 _BITS_ATOMIC_H
+#define _BITS_ATOMIC_H 1
+
+typedef __volatile int __atomic_t;
+
+static inline void
+__atomic_inc (__atomic_t *__var)
+{
+ __asm__ __volatile ("lock; incl %0" : "=m" (*__var) : "m" (*__var));
+}
+
+static inline void
+__atomic_dec (__atomic_t *__var)
+{
+ __asm__ __volatile ("lock; decl %0" : "=m" (*__var) : "m" (*__var));
+}
+
+static inline int
+__atomic_dec_and_test (__atomic_t *__var)
+{
+ unsigned char __ret;
+
+ __asm__ __volatile ("lock; decl %0; sete %1"
+ : "=m" (*__var), "=qm" (__ret) : "m" (*__var));
+ return __ret != 0;
+}
+
+/* We assume that an __atomicptr_t is only used for pointers to
+ word-aligned objects, and use the lowest bit for a simple lock. */
+typedef __volatile int * __atomicptr_t;
+
+/* Actually we don't implement that yet, and assume that we run on
+ something that has the i486 instruction set. */
+static inline int
+__atomicptr_compare_and_swap (__atomicptr_t *__ptr, void *__oldval,
+ void * __newval)
+{
+ char __ret;
+ int __dummy;
+
+ __asm__ __volatile ("lock; cmpxchgl %3, %1; sete %0"
+ : "=q" (__ret), "=m" (*__ptr), "=a" (__dummy)
+ : "r" (__newval), "m" (*__ptr), "a" (__oldval));
+ return __ret;
+}
+
+#endif
diff --git a/libpthread/sysdeps/i386/bits/memory.h b/libpthread/sysdeps/i386/bits/memory.h
new file mode 100644
index 00000000..e47a8e2d
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/memory.h
@@ -0,0 +1,40 @@
+/* Memory barrier operations. i386 version.
+ Copyright (C) 2002, 2008 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ 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 _BITS_MEMORY_H
+#define _BITS_MEMORY_H 1
+
+/* Prevent read and write reordering across this function. */
+static inline void
+__memory_barrier (void)
+{
+ int i;
+
+ /* Any lock'ed instruction will do. We just do a simple
+ increment. */
+ __asm__ __volatile ("lock; incl %0" : "=m" (i) : "m" (i));
+}
+
+/* Prevent read reordering across this function. */
+#define __memory_read_barrier __memory_barrier
+
+/* Prevent write reordering across this function. */
+#define __memory_write_barrier __memory_barrier
+
+#endif
diff --git a/libpthread/sysdeps/i386/bits/spin-lock.h b/libpthread/sysdeps/i386/bits/spin-lock.h
new file mode 100644
index 00000000..30b0c64b
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/spin-lock.h
@@ -0,0 +1,103 @@
+/* Machine-specific definitions for spin locks. i386 version.
+ Copyright (C) 2000, 2005, 2008 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ 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. */
+
+/*
+ * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
+ */
+
+#ifndef _BITS_SPIN_LOCK_H
+#define _BITS_SPIN_LOCK_H 1
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* The type of a spin lock object. */
+typedef __volatile int __pthread_spinlock_t;
+
+/* Initializer for a spin lock object. */
+# define __SPIN_LOCK_INITIALIZER (0)
+
+#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES
+
+# ifndef __EBUSY
+# include <errno.h>
+# define __EBUSY EBUSY
+# endif
+
+# ifndef __PT_SPIN_INLINE
+# define __PT_SPIN_INLINE __extern_inline
+# endif
+
+__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock);
+
+__PT_SPIN_INLINE int
+__pthread_spin_destroy (__pthread_spinlock_t *__lock)
+{
+ return 0;
+}
+
+__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock,
+ int __pshared);
+
+__PT_SPIN_INLINE int
+__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared)
+{
+ *__lock = __SPIN_LOCK_INITIALIZER;
+ return 0;
+}
+
+__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock);
+
+__PT_SPIN_INLINE int
+__pthread_spin_trylock (__pthread_spinlock_t *__lock)
+{
+ int __locked;
+ __asm__ __volatile ("xchgl %0, %1"
+ : "=&r" (__locked), "=m" (*__lock) : "0" (1));
+ return __locked ? __EBUSY : 0;
+}
+
+__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock);
+extern int _pthread_spin_lock (__pthread_spinlock_t *__lock);
+
+__extern_inline int
+__pthread_spin_lock (__pthread_spinlock_t *__lock)
+{
+ if (__pthread_spin_trylock (__lock))
+ return _pthread_spin_lock (__lock);
+ return 0;
+}
+
+__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock);
+
+__PT_SPIN_INLINE int
+__pthread_spin_unlock (__pthread_spinlock_t *__lock)
+{
+ int __unlocked;
+ __asm__ __volatile ("xchgl %0, %1"
+ : "=&r" (__unlocked), "=m" (*__lock) : "0" (0));
+ return 0;
+}
+
+#endif /* Use extern inlines or force inlines. */
+
+__END_DECLS
+
+#endif /* bits/spin-lock.h */
diff --git a/libpthread/sysdeps/i386/machine-sp.h b/libpthread/sysdeps/i386/machine-sp.h
new file mode 100644
index 00000000..cef6ab72
--- /dev/null
+++ b/libpthread/sysdeps/i386/machine-sp.h
@@ -0,0 +1,30 @@
+/* Machine-specific function to return the stack pointer. i386 version.
+ Copyright (C) 1994, 1997, 2001, 2006 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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MACHINE_SP_H
+#define _MACHINE_SP_H
+
+/* Return the current stack pointer. */
+
+#define __thread_stack_pointer() ({ \
+ register void *__sp__ asm("esp"); \
+ __sp__; \
+})
+
+#endif /* machine-sp.h */
diff --git a/libpthread/sysdeps/i386/pt-machdep.h b/libpthread/sysdeps/i386/pt-machdep.h
new file mode 100644
index 00000000..6d456367
--- /dev/null
+++ b/libpthread/sysdeps/i386/pt-machdep.h
@@ -0,0 +1,29 @@
+/* Machine dependent pthreads internal defenitions. i386 version.
+ Copyright (C) 2000 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ 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_MACHDEP_H
+#define _PT_MACHDEP_H 1
+
+struct pthread_mcontext
+{
+ void *pc;
+ void *sp;
+};
+
+#endif /* pt-machdep.h */