This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
PA-RISC diffs, part 3: arch-specific additions to LinuxThreads
- To: Ulrich Drepper <drepper at cygnus dot com>
- Subject: PA-RISC diffs, part 3: arch-specific additions to LinuxThreads
- From: David Huggins-Daines <dhd at linuxcare dot com>
- Date: 12 Oct 2000 16:28:49 -0400
- Cc: libc-alpha at sourceware dot cygnus dot com
- Organization: Linuxcare, Inc.
This patch contains changes and additions to hppa-specific files in
LinuxThreads. Note that this patch depends on the patches in part 4
(spinlock initializers) in order to be functional.
Note also that
linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h should
actually be linuxthreads/sysdeps/hppa/bits/initspin.h.
The reason it is not is that, because LinuxThreads uses the Implies
file in linuxthreads/sysdeps/unix/sysv/linux to select
sysdeps/pthread, the configure script inserts
linuxthreads/sysdeps/pthread immediately after
linuxthreads/sysdeps/unix/sysv/linux in the include path.
Because the OS-specific sysdeps directories
(e.g. linuxthreads/sysdeps/unix/sysv/linux) come before the
machine-specific ones (e.g. linuxthreads/sysdeps/hppa), this means
that sysdeps/pthread gets included before sysdeps/hppa.
This is not what we want, because it means that <bits/initspin.h>
would point to sysdeps/pthread/bits/initspin.h instead of
sysdeps/hppa/bits/initspin.h, thus defeating the whole point of having
<bits/initspin.h> in the first place.
So I've put initspin.h in the OS-dependent directory in order to work
around this misfeature.
2000-10-12 David Huggins-Daines <dhd@linuxcare.com>
* linuxthreads/shlib-versions: Add version definitions for
hppa-linux.
2000-10-12 Alan Modra <alan@linuxcare.com.au>
* linuxthreads/sysdeps/hppa/pspinlock.c: New file.
* linuxthreads/sysdeps/hppa/pt-machine.h: New file.
* linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h: New
file (this should be in linuxthreads/sysdeps/hppa, but the
top-level configure script gets the include order wrong).
diff -urN --exclude=configure --exclude=.cvsignore --exclude=CVS --exclude=*.texi --exclude=texis --exclude=*.info* --exclude=*~ glibc-2.1.95/linuxthreads/shlib-versions glibc/linuxthreads/shlib-versions
--- glibc-2.1.95/linuxthreads/shlib-versions Wed Aug 2 17:52:12 2000
+++ glibc/linuxthreads/shlib-versions Tue Oct 3 18:44:06 2000
@@ -3,4 +3,5 @@
sparc64-.*-linux.* libpthread=0 GLIBC_2.2
sh.*-.*-linux.* libpthread=0 GLIBC_2.2
ia64.*-.*-linux.* libpthread=0 GLIBC_2.2
+hppa.*-.*-linux.* libpthread=0 GLIBC_2.2
.*-.*-linux.* libpthread=0
diff -urN --exclude=configure --exclude=.cvsignore --exclude=CVS --exclude=*.texi --exclude=texis --exclude=*.info* --exclude=*~ glibc-2.1.95/linuxthreads/sysdeps/hppa/pspinlock.c glibc/linuxthreads/sysdeps/hppa/pspinlock.c
--- glibc-2.1.95/linuxthreads/sysdeps/hppa/pspinlock.c Wed Dec 31 19:00:00 1969
+++ glibc/linuxthreads/sysdeps/hppa/pspinlock.c Tue Oct 3 13:11:02 2000
@@ -0,0 +1,81 @@
+/* POSIX spinlock implementation. hppa 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. */
+
+#include <errno.h>
+#include <pthread.h>
+
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ do
+ asm volatile ("ldcw %1,%0"
+ : "=r" (val), "=m" (*lock)
+ : "m" (*lock));
+ while (!val);
+
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ asm volatile ("ldcw %1,%0"
+ : "=r" (val), "=m" (*lock)
+ : "m" (*lock));
+
+ return val ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ *lock = 1;
+ return 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ *lock = 1;
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff -urN --exclude=configure --exclude=.cvsignore --exclude=CVS --exclude=*.texi --exclude=texis --exclude=*.info* --exclude=*~ glibc-2.1.95/linuxthreads/sysdeps/hppa/pt-machine.h glibc/linuxthreads/sysdeps/hppa/pt-machine.h
--- glibc-2.1.95/linuxthreads/sysdeps/hppa/pt-machine.h Wed Dec 31 19:00:00 1969
+++ glibc/linuxthreads/sysdeps/hppa/pt-machine.h Tue Oct 3 13:11:02 2000
@@ -0,0 +1,54 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ hppa version.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>.
+
+ 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. */
+
+#include <bits/initspin.h>
+
+#ifndef PT_EI
+# define PT_EI extern 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__ ("%r30");
+
+
+/* The hppa only has one atomic read and modify memory operation,
+ load and clear, so hppa spinlocks must use zero to signify that
+ someone is holding the lock. */
+
+#define xstr(s) str(s)
+#define str(s) #s
+/* Spinlock implementation; required. */
+PT_EI int
+testandset (int *spinlock)
+{
+ int ret;
+
+ __asm__ __volatile__(
+ "ldcw 0(%2),%0"
+ : "=r"(ret), "=m"(*spinlock)
+ : "r"(spinlock));
+
+ return ret == 0;
+}
+#undef str
+#undef xstr
diff -urN --exclude=configure --exclude=.cvsignore --exclude=CVS --exclude=*.texi --exclude=texis --exclude=*.info* --exclude=*~ glibc-2.1.95/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h glibc/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h
--- glibc-2.1.95/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h Wed Dec 31 19:00:00 1969
+++ glibc/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h Thu Oct 12 15:05:29 2000
@@ -0,0 +1,27 @@
+/* PA-RISC specific definitions for spinlock initializers.
+ 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. */
+
+/* Initial value of a spinlock. PA-RISC only implements atomic load
+ and clear so this must be non-zero. */
+#define LT_SPINLOCK_INIT 1
+
+/* Macros for lock initializers, using the above definition. */
+#define LOCK_INITIALIZER { 0, LT_SPINLOCK_INIT }
+#define ALT_LOCK_INITIALIZER { 0, LT_SPINLOCK_INIT }
+#define ATOMIC_INITIALIZER { 0, LT_SPINLOCK_INIT }
--
dhd@linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.