linuxthreads for hppa (3/3)
PATCH 1/1 linuxthreads for hppa (3/3)
libc-alpha,
3. Linuxthreads changes for HPPA.
The following are the architecture specific changes to implement linuxthreads on hppa. These patches have been thoroughly tested in 2.3.1 and forward ported to the current cvs tree. NTPL and TLS are next on the plate for HPPA.
Cheers,
Carlos.
===
linuxthreads/sysdeps/hppa/pspinlock.c | 29 ++++------ linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h | 22 +++++-- 2 files changed, 30 insertions(+), 21 deletions(-)
===
2003-10-04 Carlos O'Donell <[email protected]>
* linuxthreads/sysdeps/hppa/pspinlock.c (__pthread_spin_lock): Use __ldcw_align and __ldcw. (__pthread_spin_trylock): Likewise. (__pthread_spin_unlock): Use __ldcw_align. (__pthread_spin_init): Likewise. * linuxthreads/sysdeps/hppa/pt-machine.h (THREAD_SELF): New. (INIT_THREAD_SELF): New. (__ldcw): New. (__ldcw_align): New. (__load_and_clear): New. (testandset): New. (lock_held): New. * linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h: New file. * linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h: Defined changed to match struct __atomic_lock_t.
linuxthreads/sysdeps/hppa/pspinlock.c +13 -16
@@ -24,15 +24,12 @@int __pthread_spin_lock (pthread_spinlock_t *lock) { -unsigned int val; +volatile unsigned int *addr =__ldcw_align (lock); + +while (__ldcw (addr) ==0 ) +while (*addr ==0 ) ; -do - asmvolatile ("ldcw %1,%0" - :"=r" (val),"=m" (*lock) - :"m" (*lock)); -while (!val); - -return 0 ; +return 0 ; }weak_alias (__pthread_spin_lock, pthread_spin_lock)
@@ -40,13 +37,9 @@int __pthread_spin_trylock (pthread_spinlock_t *lock) { -unsigned int val; - - asmvolatile ("ldcw %1,%0" - :"=r" (val),"=m" (*lock) - :"m" (*lock)); +volatile unsigned int *a =__ldcw_align (lock); -return val ?0 :EBUSY ; +return __ldcw (a) ?0 :EBUSY ; }weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
@@ -54,7 +47,9 @@int __pthread_spin_unlock (pthread_spinlock_t *lock) { - *lock =1 ; +volatile unsigned int *a =__ldcw_align (lock); + + *a =1 ;return 0 ; }weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
@@ -66,7 +61,9 @@/* 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 ; +volatile unsigned int *a =__ldcw_align (lock); + + *a =1 ;return 0 ; }weak_alias (__pthread_spin_init, pthread_spin_init)
linuxthreads/sysdeps/hppa/pt-machine.h +71 -15
112 lines not on this page · raw message
linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h renamed from linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h.orig +160 -0
160 lines not on this page · raw message
linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h +17 -5
@@ -17,11 +17,23 @@write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Initialize global spinlocks without cast, generally macro wrapped */ +#define __LT_SPINLOCK_ALT_INIT { { 1, 1, 1, 1, } } +/* Initial value of a spinlock. PA-RISC only implements atomic load and clear so this must be non-zero. */ -#define __LT_SPINLOCK_INIT 1 +#define __LT_SPINLOCK_INIT ((__atomic_lock_t) __LT_SPINLOCK_ALT_INIT) + +/* Macros for lock initializers, not using the above definition. +The above definition is not used in the case that static initializers +use this value. */ +#define __LOCK_INITIALIZER { 0, __LT_SPINLOCK_ALT_INIT } +#define __ATOMIC_INITIALIZER { 0, __LT_SPINLOCK_ALT_INIT } + +/* Used to initialize _pthread_fastlock's in non-static case */ +#define __LOCK_ALT_INITIALIZER ((struct _pthread_fastlock){ 0, __LT_SPINLOCK_INIT }) + +/* Tell the rest of the code that the initializer is non-zero without +explaining it's internal structure */ +#define __LT_INITIALIZER_NOT_ZERO -/* 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 }
PATCH 1/1 linuxthreads for hppa (3/3, Round 2)
libc-alpha,
Changes:
a. Fixed formatting.
b. Fixed Changelog entry.
---
3. Linuxthreads changes for HPPA.
The following are the architecture specific changes to implement linuxthreads on hppa. These patches have been thoroughly tested in 2.3.1 and forward ported to the current cvs tree. NTPL and TLS are next on the plate for HPPA.
Cheers,
Carlos.
===
sysdeps/hppa/pspinlock.c | 25 - sysdeps/hppa/pt-machine.h | 86 ++++- sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h | 160 ++++++++++ sysdeps/unix/sysv/linux/hppa/bits/initspin.h | 22 + 4 files changed, 259 insertions(+), 34 deletions(-)
===
2003-10-12 Carlos O'Donell <[email protected]>
* sysdeps/hppa/pspinlock.c (__pthread_spin_lock): Use __ldcw_align and __ldcw. (__pthread_spin_trylock): Likewise. (__pthread_spin_unlock): Use __ldcw_align. (__pthread_spin_init): Likewise. * sysdeps/hppa/pt-machine.h (THREAD_SELF): New. (INIT_THREAD_SELF): New. (__ldcw): New. (__ldcw_align): New. (__load_and_clear): New. (testandset): New. (lock_held): New. * sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h: New file. * sysdeps/unix/sysv/linux/hppa/bits/initspin.h: Define changed to match struct __atomic_lock_t.
linuxthreads/sysdeps/hppa/pspinlock.c +11 -14
@@ -24,13 +24,10 @@int __pthread_spin_lock (pthread_spinlock_t *lock) { -unsigned int val; +volatile unsigned int *addr =__ldcw_align (lock); -do - asmvolatile ("ldcw %1,%0" - :"=r" (val),"=m" (*lock) - :"m" (*lock)); -while (!val); +while (__ldcw (addr) ==0 ) +while (*addr ==0 ) ;return 0 ; }
@@ -40,13 +37,9 @@ weak_alias (__pthread_spin_lock, pthreadint __pthread_spin_trylock (pthread_spinlock_t *lock) { -unsigned int val; +volatile unsigned int *a =__ldcw_align (lock); - asmvolatile ("ldcw %1,%0" - :"=r" (val),"=m" (*lock) - :"m" (*lock)); - -return val ?0 :EBUSY ; +return __ldcw (a) ?0 :EBUSY ; }weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
@@ -54,7 +47,9 @@ weak_alias (__pthread_spin_trylock, pthrint __pthread_spin_unlock (pthread_spinlock_t *lock) { - *lock =1 ; +volatile unsigned int *a =__ldcw_align (lock); + + *a =1 ;return 0 ; }weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
@@ -66,7 +61,9 @@ __pthread_spin_init (pthread_spinlock_t/* 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 ; +volatile unsigned int *a =__ldcw_align (lock); + + *a =1 ;return 0 ; }weak_alias (__pthread_spin_init, pthread_spin_init)
linuxthreads/sysdeps/hppa/pt-machine.h +71 -15
112 lines not on this page · raw message
linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h renamed from linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h.orig +160 -0
160 lines not on this page · raw message
linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h +17 -5
@@ -17,11 +17,23 @@write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Initialize global spinlocks without cast, generally macro wrapped */ +#define __LT_SPINLOCK_ALT_INIT { { 1, 1, 1, 1, } } +/* Initial value of a spinlock. PA-RISC only implements atomic load and clear so this must be non-zero. */ -#define __LT_SPINLOCK_INIT 1 +#define __LT_SPINLOCK_INIT ((__atomic_lock_t) __LT_SPINLOCK_ALT_INIT) + +/* Macros for lock initializers, not using the above definition. +The above definition is not used in the case that static initializers +use this value. */ +#define __LOCK_INITIALIZER { 0, __LT_SPINLOCK_ALT_INIT } +#define __ATOMIC_INITIALIZER { 0, __LT_SPINLOCK_ALT_INIT } + +/* Used to initialize _pthread_fastlock's in non-static case */ +#define __LOCK_ALT_INITIALIZER ((struct _pthread_fastlock){ 0, __LT_SPINLOCK_INIT }) + +/* Tell the rest of the code that the initializer is non-zero without +explaining it's internal structure */ +#define __LT_INITIALIZER_NOT_ZERO -/* 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 }
PATCH 1/1 linuxthreads for hppa (3/3, Round 2)
In reply to Carlos O'Donelllibc-alpha,
Changes:
a. Fixed formatting.
b. Fixed Changelog entry.
---
3. Linuxthreads changes for HPPA.
The following are the architecture specific changes to implement linuxthreads on hppa. These patches have been thoroughly tested in 2.3.1 and forward ported to the current cvs tree. NTPL and TLS are next on the plate for HPPA.
Cheers,
Carlos.
===
sysdeps/hppa/pspinlock.c | 25 - sysdeps/hppa/pt-machine.h | 86 ++++- sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h | 160 ++++++++++ sysdeps/unix/sysv/linux/hppa/bits/initspin.h | 22 + 4 files changed, 259 insertions(+), 34 deletions(-)
===
2003-10-12 Carlos O'Donell <[email protected]>
* sysdeps/hppa/pspinlock.c (__pthread_spin_lock): Use __ldcw_align and __ldcw. (__pthread_spin_trylock): Likewise. (__pthread_spin_unlock): Use __ldcw_align. (__pthread_spin_init): Likewise. * sysdeps/hppa/pt-machine.h (THREAD_SELF): New. (INIT_THREAD_SELF): New. (__ldcw): New. (__ldcw_align): New. (__load_and_clear): New. (testandset): New. (lock_held): New. * sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h: New file. * sysdeps/unix/sysv/linux/hppa/bits/initspin.h: Define changed to match struct __atomic_lock_t.
linuxthreads/sysdeps/hppa/pspinlock.c +11 -14
@@ -24,13 +24,10 @@int __pthread_spin_lock (pthread_spinlock_t *lock) { -unsigned int val; +volatile unsigned int *addr =__ldcw_align (lock); -do - asmvolatile ("ldcw %1,%0" - :"=r" (val),"=m" (*lock) - :"m" (*lock)); -while (!val); +while (__ldcw (addr) ==0 ) +while (*addr ==0 ) ;return 0 ; }
@@ -40,13 +37,9 @@ weak_alias (__pthread_spin_lock, pthreadint __pthread_spin_trylock (pthread_spinlock_t *lock) { -unsigned int val; +volatile unsigned int *a =__ldcw_align (lock); - asmvolatile ("ldcw %1,%0" - :"=r" (val),"=m" (*lock) - :"m" (*lock)); - -return val ?0 :EBUSY ; +return __ldcw (a) ?0 :EBUSY ; }weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
@@ -54,7 +47,9 @@ weak_alias (__pthread_spin_trylock, pthrint __pthread_spin_unlock (pthread_spinlock_t *lock) { - *lock =1 ; +volatile unsigned int *a =__ldcw_align (lock); + + *a =1 ;return 0 ; }weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
@@ -66,7 +61,9 @@ __pthread_spin_init (pthread_spinlock_t/* 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 ; +volatile unsigned int *a =__ldcw_align (lock); + + *a =1 ;return 0 ; }weak_alias (__pthread_spin_init, pthread_spin_init)
linuxthreads/sysdeps/hppa/pt-machine.h +71 -15
112 lines not on this page · raw message
linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h renamed from linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h.orig +160 -0
160 lines not on this page · raw message
linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h +17 -5
@@ -17,11 +17,23 @@write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Initialize global spinlocks without cast, generally macro wrapped */ +#define __LT_SPINLOCK_ALT_INIT { { 1, 1, 1, 1, } } +/* Initial value of a spinlock. PA-RISC only implements atomic load and clear so this must be non-zero. */ -#define __LT_SPINLOCK_INIT 1 +#define __LT_SPINLOCK_INIT ((__atomic_lock_t) __LT_SPINLOCK_ALT_INIT) + +/* Macros for lock initializers, not using the above definition. +The above definition is not used in the case that static initializers +use this value. */ +#define __LOCK_INITIALIZER { 0, __LT_SPINLOCK_ALT_INIT } +#define __ATOMIC_INITIALIZER { 0, __LT_SPINLOCK_ALT_INIT } + +/* Used to initialize _pthread_fastlock's in non-static case */ +#define __LOCK_ALT_INITIALIZER ((struct _pthread_fastlock){ 0, __LT_SPINLOCK_INIT }) + +/* Tell the rest of the code that the initializer is non-zero without +explaining it's internal structure */ +#define __LT_INITIALIZER_NOT_ZERO -/* 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 }