From af7d78e726cb0d3248c461cfee27fe15121dacd1 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 7 Aug 2012 22:36:56 +0200 Subject: Rename ia32 sysdep directories to i386. * sysdeps/i386/Implies: Remove file. * sysdeps/mach/hurd/i386/Implies: Likewise. * sysdeps/ia32/bits/memory.h: Rename to sysdeps/i386/bits/memory.h. * sysdeps/ia32/bits/pt-atomic.h: Rename to sysdeps/i386/bits/pt-atomic.h. * sysdeps/ia32/bits/spin-lock-inline.h: Rename to sysdeps/i386/bits/spin-lock-inline.h. * sysdeps/ia32/bits/spin-lock.h: Rename to sysdeps/i386/bits/spin-lock.h. * sysdeps/ia32/machine-sp.h: Rename to sysdeps/i386/machine-sp.h. * sysdeps/ia32/pt-machdep.h: Rename to sysdeps/i386/pt-machdep.h. * sysdeps/mach/hurd/ia32/pt-machdep.c: Rename to sysdeps/mach/hurd/i386/pt-machdep.c. * sysdeps/mach/hurd/ia32/pt-setup.c: Rename to sysdeps/mach/hurd/i386/pt-setup.c. * Makefile (SYSDEP_PATH): Adapt to that. --- Makefile | 6 +- sysdeps/i386/Implies | 1 - sysdeps/i386/bits/memory.h | 40 +++++++++++++ sysdeps/i386/bits/pt-atomic.h | 66 ++++++++++++++++++++++ sysdeps/i386/bits/spin-lock-inline.h | 98 ++++++++++++++++++++++++++++++++ sysdeps/i386/bits/spin-lock.h | 39 +++++++++++++ sysdeps/i386/machine-sp.h | 30 ++++++++++ sysdeps/i386/pt-machdep.h | 29 ++++++++++ sysdeps/ia32/bits/memory.h | 40 ------------- sysdeps/ia32/bits/pt-atomic.h | 66 ---------------------- sysdeps/ia32/bits/spin-lock-inline.h | 98 -------------------------------- sysdeps/ia32/bits/spin-lock.h | 39 ------------- sysdeps/ia32/machine-sp.h | 30 ---------- sysdeps/ia32/pt-machdep.h | 29 ---------- sysdeps/mach/hurd/i386/Implies | 1 - sysdeps/mach/hurd/i386/pt-machdep.c | 83 +++++++++++++++++++++++++++ sysdeps/mach/hurd/i386/pt-setup.c | 106 +++++++++++++++++++++++++++++++++++ sysdeps/mach/hurd/ia32/pt-machdep.c | 83 --------------------------- sysdeps/mach/hurd/ia32/pt-setup.c | 106 ----------------------------------- 19 files changed, 494 insertions(+), 496 deletions(-) delete mode 100644 sysdeps/i386/Implies create mode 100644 sysdeps/i386/bits/memory.h create mode 100644 sysdeps/i386/bits/pt-atomic.h create mode 100644 sysdeps/i386/bits/spin-lock-inline.h create mode 100644 sysdeps/i386/bits/spin-lock.h create mode 100644 sysdeps/i386/machine-sp.h create mode 100644 sysdeps/i386/pt-machdep.h delete mode 100644 sysdeps/ia32/bits/memory.h delete mode 100644 sysdeps/ia32/bits/pt-atomic.h delete mode 100644 sysdeps/ia32/bits/spin-lock-inline.h delete mode 100644 sysdeps/ia32/bits/spin-lock.h delete mode 100644 sysdeps/ia32/machine-sp.h delete mode 100644 sysdeps/ia32/pt-machdep.h delete mode 100644 sysdeps/mach/hurd/i386/Implies create mode 100644 sysdeps/mach/hurd/i386/pt-machdep.c create mode 100644 sysdeps/mach/hurd/i386/pt-setup.c delete mode 100644 sysdeps/mach/hurd/ia32/pt-machdep.c delete mode 100644 sysdeps/mach/hurd/ia32/pt-setup.c diff --git a/Makefile b/Makefile index b6e5602..fdfe3ae 100644 --- a/Makefile +++ b/Makefile @@ -196,9 +196,9 @@ install-lib-ldscripts := libpthread.so include ../Makeconfig endif -SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/ia32 \ - $(srcdir)/sysdeps/$(MICROKERNEL)/ia32 \ - $(srcdir)/sysdeps/ia32 \ +SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/i386 \ + $(srcdir)/sysdeps/$(MICROKERNEL)/i386 \ + $(srcdir)/sysdeps/i386 \ $(srcdir)/sysdeps/$(MICROKERNEL)/hurd \ $(srcdir)/sysdeps/$(MICROKERNEL) \ $(srcdir)/sysdeps/hurd \ diff --git a/sysdeps/i386/Implies b/sysdeps/i386/Implies deleted file mode 100644 index d799fa1..0000000 --- a/sysdeps/i386/Implies +++ /dev/null @@ -1 +0,0 @@ -ia32 diff --git a/sysdeps/i386/bits/memory.h b/sysdeps/i386/bits/memory.h new file mode 100644 index 0000000..932c408 --- /dev/null +++ b/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) : "memory"); +} + +/* 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/sysdeps/i386/bits/pt-atomic.h b/sysdeps/i386/bits/pt-atomic.h new file mode 100644 index 0000000..0dfc1f6 --- /dev/null +++ b/sysdeps/i386/bits/pt-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/sysdeps/i386/bits/spin-lock-inline.h b/sysdeps/i386/bits/spin-lock-inline.h new file mode 100644 index 0000000..e5ed3de --- /dev/null +++ b/sysdeps/i386/bits/spin-lock-inline.h @@ -0,0 +1,98 @@ +/* Machine-specific definitions for spin locks. i386 version. + Copyright (C) 2000, 2005, 2008, 2009 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 or instead. + */ + +#ifndef _BITS_SPIN_LOCK_INLINE_H +#define _BITS_SPIN_LOCK_INLINE_H 1 + +#include +#include + +__BEGIN_DECLS + +#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES + +# ifndef __EBUSY +# include +# 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 = __PTHREAD_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) : "memory"); + 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) : "memory"); + return 0; +} + +#endif /* Use extern inlines or force inlines. */ + +__END_DECLS + +#endif /* bits/spin-lock.h */ diff --git a/sysdeps/i386/bits/spin-lock.h b/sysdeps/i386/bits/spin-lock.h new file mode 100644 index 0000000..5ae81e1 --- /dev/null +++ b/sysdeps/i386/bits/spin-lock.h @@ -0,0 +1,39 @@ +/* Machine-specific definitions for spin locks. i386 version. + Copyright (C) 2000, 2005, 2008, 2009 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 or instead. + */ + +#ifndef _BITS_SPIN_LOCK_H +#define _BITS_SPIN_LOCK_H 1 + +#include + +__BEGIN_DECLS + +/* The type of a spin lock object. */ +typedef __volatile int __pthread_spinlock_t; + +/* Initializer for a spin lock object. */ +# define __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0) + +__END_DECLS + +#endif /* bits/spin-lock.h */ diff --git a/sysdeps/i386/machine-sp.h b/sysdeps/i386/machine-sp.h new file mode 100644 index 0000000..cef6ab7 --- /dev/null +++ b/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/sysdeps/i386/pt-machdep.h b/sysdeps/i386/pt-machdep.h new file mode 100644 index 0000000..6d45636 --- /dev/null +++ b/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 */ diff --git a/sysdeps/ia32/bits/memory.h b/sysdeps/ia32/bits/memory.h deleted file mode 100644 index 932c408..0000000 --- a/sysdeps/ia32/bits/memory.h +++ /dev/null @@ -1,40 +0,0 @@ -/* 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) : "memory"); -} - -/* 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/sysdeps/ia32/bits/pt-atomic.h b/sysdeps/ia32/bits/pt-atomic.h deleted file mode 100644 index 0dfc1f6..0000000 --- a/sysdeps/ia32/bits/pt-atomic.h +++ /dev/null @@ -1,66 +0,0 @@ -/* 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/sysdeps/ia32/bits/spin-lock-inline.h b/sysdeps/ia32/bits/spin-lock-inline.h deleted file mode 100644 index e5ed3de..0000000 --- a/sysdeps/ia32/bits/spin-lock-inline.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Machine-specific definitions for spin locks. i386 version. - Copyright (C) 2000, 2005, 2008, 2009 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 or instead. - */ - -#ifndef _BITS_SPIN_LOCK_INLINE_H -#define _BITS_SPIN_LOCK_INLINE_H 1 - -#include -#include - -__BEGIN_DECLS - -#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES - -# ifndef __EBUSY -# include -# 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 = __PTHREAD_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) : "memory"); - 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) : "memory"); - return 0; -} - -#endif /* Use extern inlines or force inlines. */ - -__END_DECLS - -#endif /* bits/spin-lock.h */ diff --git a/sysdeps/ia32/bits/spin-lock.h b/sysdeps/ia32/bits/spin-lock.h deleted file mode 100644 index 5ae81e1..0000000 --- a/sysdeps/ia32/bits/spin-lock.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Machine-specific definitions for spin locks. i386 version. - Copyright (C) 2000, 2005, 2008, 2009 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 or instead. - */ - -#ifndef _BITS_SPIN_LOCK_H -#define _BITS_SPIN_LOCK_H 1 - -#include - -__BEGIN_DECLS - -/* The type of a spin lock object. */ -typedef __volatile int __pthread_spinlock_t; - -/* Initializer for a spin lock object. */ -# define __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0) - -__END_DECLS - -#endif /* bits/spin-lock.h */ diff --git a/sysdeps/ia32/machine-sp.h b/sysdeps/ia32/machine-sp.h deleted file mode 100644 index cef6ab7..0000000 --- a/sysdeps/ia32/machine-sp.h +++ /dev/null @@ -1,30 +0,0 @@ -/* 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/sysdeps/ia32/pt-machdep.h b/sysdeps/ia32/pt-machdep.h deleted file mode 100644 index 6d45636..0000000 --- a/sysdeps/ia32/pt-machdep.h +++ /dev/null @@ -1,29 +0,0 @@ -/* 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 */ diff --git a/sysdeps/mach/hurd/i386/Implies b/sysdeps/mach/hurd/i386/Implies deleted file mode 100644 index d799fa1..0000000 --- a/sysdeps/mach/hurd/i386/Implies +++ /dev/null @@ -1 +0,0 @@ -ia32 diff --git a/sysdeps/mach/hurd/i386/pt-machdep.c b/sysdeps/mach/hurd/i386/pt-machdep.c new file mode 100644 index 0000000..f3c8cf5 --- /dev/null +++ b/sysdeps/mach/hurd/i386/pt-machdep.c @@ -0,0 +1,83 @@ +/* Machine dependent pthreads code. Hurd/i386 version. + Copyright (C) 2000, 2002, 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 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 + +#include +#include +#include +#include +#include + +#define HURD_TLS_DESC_DECL(desc, tcb) \ + struct descriptor desc = \ + { /* low word: */ \ + 0xffff /* limit 0..15 */ \ + | (((unsigned int) (tcb)) << 16) /* base 0..15 */ \ + , /* high word: */ \ + ((((unsigned int) (tcb)) >> 16) & 0xff) /* base 16..23 */ \ + | ((0x12 | 0x60 | 0x80) << 8) /* access = ACC_DATA_W|ACC_PL_U|ACC_P */ \ + | (0xf << 16) /* limit 16..19 */ \ + | ((4 | 8) << 20) /* granularity = SZ_32|SZ_G */ \ + | (((unsigned int) (tcb)) & 0xff000000) /* base 24..31 */ \ + } + +int +__thread_set_pcsptp (thread_t thread, + int set_ip, void *ip, + int set_sp, void *sp, + int set_tp, void *tp) +{ + error_t err; + struct i386_thread_state state; + mach_msg_type_number_t state_count; + + state_count = i386_THREAD_STATE_COUNT; + + err = __thread_get_state (thread, i386_REGS_SEGS_STATE, + (thread_state_t) &state, &state_count); + if (err) + return err; + + if (set_sp) + state.uesp = (unsigned int) sp; + if (set_ip) + state.eip = (unsigned int) ip; + if (set_tp) { + HURD_TLS_DESC_DECL(desc, tp); + int sel; + + asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0)); + if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ + err = __i386_set_ldt (thread, sel, &desc, 1); + else + err = __i386_set_gdt (thread, &sel, desc); + if (err) + return err; + state.gs = sel; + } + + err = __thread_set_state (thread, i386_REGS_SEGS_STATE, + (thread_state_t) &state, + i386_THREAD_STATE_COUNT); + if (err) + return err; + + return 0; +} diff --git a/sysdeps/mach/hurd/i386/pt-setup.c b/sysdeps/mach/hurd/i386/pt-setup.c new file mode 100644 index 0000000..73fd43d --- /dev/null +++ b/sysdeps/mach/hurd/i386/pt-setup.c @@ -0,0 +1,106 @@ +/* Setup thread stack. Hurd/i386 version. + Copyright (C) 2000, 2002, 2005, 2007, 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. */ + +#include +#include +#include + +#include + +/* The stack layout used on the i386 is: + + ----------------- + | ARG | + ----------------- + | START_ROUTINE | + ----------------- + | 0 | + ----------------- + | | + | Fast TSD | + | | + ----------------- + + We need to reserve __hurd_threadvar_max `unsigned long int's' of + (fast) thread-specific data (TSD) for the Hurd. */ + +/* Set up the stack for THREAD, such that it appears as if + START_ROUTINE and ARG were passed to the new thread's entry-point. + Return the stack pointer for the new thread. */ +static void * +stack_setup (struct __pthread *thread, + void *(*start_routine)(void *), void *arg) +{ + error_t err; + uintptr_t *bottom, *top; + + /* Calculate the top of the new stack. */ + bottom = thread->stackaddr; + top = (uintptr_t *) ((uintptr_t) bottom + thread->stacksize); + + /* Next, make room for the TSDs. */ + top -= __hurd_threadvar_max; + + if (start_routine) + { + /* And then the call frame. */ + top -= 3; + top = (uintptr_t *) ((uintptr_t) top & ~0xf); + top[2] = (uintptr_t) arg; /* Argument to START_ROUTINE. */ + top[1] = (uintptr_t) start_routine; + top[0] = (uintptr_t) thread; + *--top = 0; /* Fake return address. */ + } + + if (thread->guardsize) + { + err = __vm_protect (__mach_task_self (), (vm_address_t) bottom, + thread->guardsize, 0, 0); + assert_perror (err); + } + + return top; +} + +int +__pthread_setup (struct __pthread *thread, + void (*entry_point)(struct __pthread *, void *(*)(void *), void *), + void *(*start_routine)(void *), void *arg) +{ + error_t err; + mach_port_t ktid; + + thread->mcontext.pc = entry_point; + thread->mcontext.sp = stack_setup (thread, start_routine, arg); + + thread->tcb->self = thread->kernel_thread; + + ktid = __mach_thread_self (); + if (thread->kernel_thread != ktid) + { + err = __thread_set_pcsptp (thread->kernel_thread, + 1, thread->mcontext.pc, + 1, thread->mcontext.sp, + 1, thread->tcb); + assert_perror (err); + } + __mach_port_deallocate (__mach_task_self (), ktid); + + return 0; +} diff --git a/sysdeps/mach/hurd/ia32/pt-machdep.c b/sysdeps/mach/hurd/ia32/pt-machdep.c deleted file mode 100644 index f3c8cf5..0000000 --- a/sysdeps/mach/hurd/ia32/pt-machdep.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Machine dependent pthreads code. Hurd/i386 version. - Copyright (C) 2000, 2002, 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 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 - -#include -#include -#include -#include -#include - -#define HURD_TLS_DESC_DECL(desc, tcb) \ - struct descriptor desc = \ - { /* low word: */ \ - 0xffff /* limit 0..15 */ \ - | (((unsigned int) (tcb)) << 16) /* base 0..15 */ \ - , /* high word: */ \ - ((((unsigned int) (tcb)) >> 16) & 0xff) /* base 16..23 */ \ - | ((0x12 | 0x60 | 0x80) << 8) /* access = ACC_DATA_W|ACC_PL_U|ACC_P */ \ - | (0xf << 16) /* limit 16..19 */ \ - | ((4 | 8) << 20) /* granularity = SZ_32|SZ_G */ \ - | (((unsigned int) (tcb)) & 0xff000000) /* base 24..31 */ \ - } - -int -__thread_set_pcsptp (thread_t thread, - int set_ip, void *ip, - int set_sp, void *sp, - int set_tp, void *tp) -{ - error_t err; - struct i386_thread_state state; - mach_msg_type_number_t state_count; - - state_count = i386_THREAD_STATE_COUNT; - - err = __thread_get_state (thread, i386_REGS_SEGS_STATE, - (thread_state_t) &state, &state_count); - if (err) - return err; - - if (set_sp) - state.uesp = (unsigned int) sp; - if (set_ip) - state.eip = (unsigned int) ip; - if (set_tp) { - HURD_TLS_DESC_DECL(desc, tp); - int sel; - - asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0)); - if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ - err = __i386_set_ldt (thread, sel, &desc, 1); - else - err = __i386_set_gdt (thread, &sel, desc); - if (err) - return err; - state.gs = sel; - } - - err = __thread_set_state (thread, i386_REGS_SEGS_STATE, - (thread_state_t) &state, - i386_THREAD_STATE_COUNT); - if (err) - return err; - - return 0; -} diff --git a/sysdeps/mach/hurd/ia32/pt-setup.c b/sysdeps/mach/hurd/ia32/pt-setup.c deleted file mode 100644 index 73fd43d..0000000 --- a/sysdeps/mach/hurd/ia32/pt-setup.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Setup thread stack. Hurd/i386 version. - Copyright (C) 2000, 2002, 2005, 2007, 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. */ - -#include -#include -#include - -#include - -/* The stack layout used on the i386 is: - - ----------------- - | ARG | - ----------------- - | START_ROUTINE | - ----------------- - | 0 | - ----------------- - | | - | Fast TSD | - | | - ----------------- - - We need to reserve __hurd_threadvar_max `unsigned long int's' of - (fast) thread-specific data (TSD) for the Hurd. */ - -/* Set up the stack for THREAD, such that it appears as if - START_ROUTINE and ARG were passed to the new thread's entry-point. - Return the stack pointer for the new thread. */ -static void * -stack_setup (struct __pthread *thread, - void *(*start_routine)(void *), void *arg) -{ - error_t err; - uintptr_t *bottom, *top; - - /* Calculate the top of the new stack. */ - bottom = thread->stackaddr; - top = (uintptr_t *) ((uintptr_t) bottom + thread->stacksize); - - /* Next, make room for the TSDs. */ - top -= __hurd_threadvar_max; - - if (start_routine) - { - /* And then the call frame. */ - top -= 3; - top = (uintptr_t *) ((uintptr_t) top & ~0xf); - top[2] = (uintptr_t) arg; /* Argument to START_ROUTINE. */ - top[1] = (uintptr_t) start_routine; - top[0] = (uintptr_t) thread; - *--top = 0; /* Fake return address. */ - } - - if (thread->guardsize) - { - err = __vm_protect (__mach_task_self (), (vm_address_t) bottom, - thread->guardsize, 0, 0); - assert_perror (err); - } - - return top; -} - -int -__pthread_setup (struct __pthread *thread, - void (*entry_point)(struct __pthread *, void *(*)(void *), void *), - void *(*start_routine)(void *), void *arg) -{ - error_t err; - mach_port_t ktid; - - thread->mcontext.pc = entry_point; - thread->mcontext.sp = stack_setup (thread, start_routine, arg); - - thread->tcb->self = thread->kernel_thread; - - ktid = __mach_thread_self (); - if (thread->kernel_thread != ktid) - { - err = __thread_set_pcsptp (thread->kernel_thread, - 1, thread->mcontext.pc, - 1, thread->mcontext.sp, - 1, thread->tcb); - assert_perror (err); - } - __mach_port_deallocate (__mach_task_self (), ktid); - - return 0; -} -- cgit v1.2.3