diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2004-03-18 02:44:20 +0000 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gnu.org> | 2009-04-06 22:16:47 +0200 |
commit | 87bbfdf3b5718544942498f0d980e13a0f4110da (patch) | |
tree | e9693b1d7ee1054b965068fed171be6f1aa0822e /sysdeps | |
parent | 01d0d4c7d07b28326d2de95dd9000f876f661707 (diff) |
2004-03-17 Marcus Brinkmann <marcus@gnu.org>
* libpthread: New directory, populated with Neal H. Walfields
pthread implementation.
Diffstat (limited to 'sysdeps')
40 files changed, 892 insertions, 123 deletions
diff --git a/sysdeps/generic/bits/pthreadtypes.h b/sysdeps/generic/bits/pthreadtypes.h new file mode 100644 index 00000000..e5cbfd2a --- /dev/null +++ b/sysdeps/generic/bits/pthreadtypes.h @@ -0,0 +1,29 @@ +/* + 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. */ + +#if !defined _BITS_TYPES_H && !defined _PTHREAD_H +# error "Never include <bits/pthreadtypes.h> directly; use <sys/types.h> instead." +#endif + +#ifndef _BITS_PTHREADTYPES_H +#define _BITS_PTHREADTYPES_H 1 + +#include <pthread.h> + +#endif /* bits/pthreadtypes.h */ diff --git a/sysdeps/generic/pt-rwlock-rdlock.c b/sysdeps/generic/pt-rwlock-rdlock.c index 22c11204..d060c38f 100644 --- a/sysdeps/generic/pt-rwlock-rdlock.c +++ b/sysdeps/generic/pt-rwlock-rdlock.c @@ -21,7 +21,7 @@ #include <pt-internal.h> /* Implemented in pt-rwlock-timedrdlock.c. */ -extern int __pthread_rwlock_timedrdlock_internal (struct __pthread_mutex *mutex, +extern int __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *mutex, const struct timespec *abstime); /* Acquire RWLOCK for reading, block if we can't get it. */ diff --git a/sysdeps/hurd/pt-destroy-specific.c b/sysdeps/hurd/pt-destroy-specific.c index dbd3314b..2006f2b8 100644 --- a/sysdeps/hurd/pt-destroy-specific.c +++ b/sysdeps/hurd/pt-destroy-specific.c @@ -50,10 +50,10 @@ __pthread_destroy_specific (struct __pthread *thread) if (__pthread_key_destructors[i] == PTHREAD_KEY_INVALID) break; - value = ihash_find (thread->thread_specifics, i); + value = hurd_ihash_find (thread->thread_specifics, i); if (value) { - err = ihash_remove (thread->thread_specifics, i); + err = hurd_ihash_remove (thread->thread_specifics, i); assert (err == 1); if (__pthread_key_destructors[i]) @@ -71,9 +71,10 @@ __pthread_destroy_specific (struct __pthread *thread) /* This may take a very long time. Let those blocking on pthread_key_create or pthread_key_delete make progress. */ - sched_yield (); + /* FIXME what should we do with this one? */ + /* sched_yield (); */ } - - ihash_free (thread->thread_specifics); + + hurd_ihash_free (thread->thread_specifics); thread->thread_specifics = 0; } diff --git a/sysdeps/hurd/pt-getspecific.c b/sysdeps/hurd/pt-getspecific.c index b5b5f5e5..30605984 100644 --- a/sysdeps/hurd/pt-getspecific.c +++ b/sysdeps/hurd/pt-getspecific.c @@ -33,5 +33,5 @@ pthread_getspecific (pthread_key_t key) if (! self->thread_specifics) return 0; - return ihash_find (self->thread_specifics, key); + return hurd_ihash_find (self->thread_specifics, key); } diff --git a/sysdeps/hurd/pt-key.h b/sysdeps/hurd/pt-key.h index 739fbbad..494e01d7 100644 --- a/sysdeps/hurd/pt-key.h +++ b/sysdeps/hurd/pt-key.h @@ -21,7 +21,7 @@ #include <hurd/ihash.h> #define PTHREAD_KEY_MEMBERS \ - ihash_t thread_specifics; + hurd_ihash_t thread_specifics; #define PTHREAD_KEY_INVALID (void *) (-1) diff --git a/sysdeps/i386/bits/atomic.h b/sysdeps/ia32/bits/atomic.h index 0dfc1f60..0dfc1f60 100644 --- a/sysdeps/i386/bits/atomic.h +++ b/sysdeps/ia32/bits/atomic.h diff --git a/sysdeps/i386/bits/memory.h b/sysdeps/ia32/bits/memory.h index 201305b9..201305b9 100644 --- a/sysdeps/i386/bits/memory.h +++ b/sysdeps/ia32/bits/memory.h diff --git a/sysdeps/i386/bits/spin-lock.h b/sysdeps/ia32/bits/spin-lock.h index 175656ef..175656ef 100644 --- a/sysdeps/i386/bits/spin-lock.h +++ b/sysdeps/ia32/bits/spin-lock.h diff --git a/sysdeps/i386/machine-sp.h b/sysdeps/ia32/machine-sp.h index 536f6902..536f6902 100644 --- a/sysdeps/i386/machine-sp.h +++ b/sysdeps/ia32/machine-sp.h diff --git a/sysdeps/i386/pt-machdep.h b/sysdeps/ia32/pt-machdep.h index 6d456367..6d456367 100644 --- a/sysdeps/i386/pt-machdep.h +++ b/sysdeps/ia32/pt-machdep.h diff --git a/sysdeps/l4/bits/pthread-np.h b/sysdeps/l4/bits/pthread-np.h new file mode 100644 index 00000000..b487e6dc --- /dev/null +++ b/sysdeps/l4/bits/pthread-np.h @@ -0,0 +1,38 @@ +/* Non-portable functions. L4 version. + Copyright (C) 2003 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_PTHREAD_NP_H +#define _BITS_PTHREAD_NP_H 1 + +#include <l4.h> + +/* Create a thread with attributes given by ATTR, executing + START_ROUTINE with argument ARG. TID is the provided L4 + kernel thread. */ +extern int pthread_create_from_l4_tid_np (pthread_t *thread, + const pthread_attr_t *attr, + l4_thread_id_t tid, + void *(*start_routine)(void *), + void *arg); + +#endif /* bits/pthread-np.h */ diff --git a/sysdeps/l4/hurd/i386/pt-machdep.c b/sysdeps/l4/hurd/ia32/pt-machdep.c index dbf5cd7e..dbf5cd7e 100644 --- a/sysdeps/l4/hurd/i386/pt-machdep.c +++ b/sysdeps/l4/hurd/ia32/pt-machdep.c diff --git a/sysdeps/l4/hurd/i386/pt-setup.c b/sysdeps/l4/hurd/ia32/pt-setup.c index fe77d533..e244dc16 100644 --- a/sysdeps/l4/hurd/i386/pt-setup.c +++ b/sysdeps/l4/hurd/ia32/pt-setup.c @@ -17,7 +17,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <l4/l4.h> +#include <l4.h> #include <pt-internal.h> @@ -39,16 +39,16 @@ static void * stack_setup (struct __pthread *thread, void *(*start_routine)(void *), void *arg) { - L4_Word_t *top; + l4_word_t *top; /* Calculate top of the new stack. */ - top = (L4_Word_t *) ((L4_Word_t) thread->stackaddr + thread->stacksize); + top = (l4_word_t *) ((l4_word_t) thread->stackaddr + thread->stacksize); if (start_routine) { /* Set up call frame. */ - *--top = (L4_Word_t) arg; /* Argument to START_ROUTINE. */ - *--top = (L4_Word_t) start_routine; + *--top = (l4_word_t) arg; /* Argument to START_ROUTINE. */ + *--top = (l4_word_t) start_routine; *--top = 0; /* Fake return address. */ } @@ -63,10 +63,10 @@ __pthread_setup (struct __pthread *thread, thread->mcontext.pc = entry_point; thread->mcontext.sp = stack_setup (thread, start_routine, arg); - if (L4_SameThreads (thread->threadid, L4_Myself ())) - L4_Set_MyUserDefinedHandle (thread); + if (l4_same_threads (thread->threadid, l4_myself ())) + l4_set_user_defined_handle ((l4_word_t) thread); else - L4_Set_UserDefinedHandle (thread->threadid, thread); - + l4_set_user_defined_handle_of (thread->threadid, + (l4_word_t) thread); return 0; } diff --git a/sysdeps/l4/hurd/powerpc/pt-machdep.c b/sysdeps/l4/hurd/powerpc/pt-machdep.c new file mode 100644 index 00000000..754d203e --- /dev/null +++ b/sysdeps/l4/hurd/powerpc/pt-machdep.c @@ -0,0 +1,20 @@ +/* Machine dependent pthreads code. Hurd/PowerPC version. + Copyright (C) 2003 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. */ + +/* Nothing to do. */ diff --git a/sysdeps/l4/hurd/powerpc/pt-setup.c b/sysdeps/l4/hurd/powerpc/pt-setup.c new file mode 100644 index 00000000..d3cf4ec3 --- /dev/null +++ b/sysdeps/l4/hurd/powerpc/pt-setup.c @@ -0,0 +1,93 @@ +/* Setup thread stack. Hurd/PowerPC version. + Copyright (C) 2003 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 <l4.h> + +#include <pt-internal.h> + +/* Arguments is passed in registers on the PowerPC. But the + exchange registers syscall only allows us to set the PC and the + stack pointer so we put the entry point and start function on + the stack. */ +struct start_info +{ + void (*entry_point) (void *(*)(void *), void *); + void *(*start_routine) (void *); + void *arg; +}; + +void first_entry_1 (void); + +/* Stage 1 entry function. The start_info structure is inlined on the + stack. Put values into registers and call entry function. */ +asm (" ;\ +first_entry_1: ;\ + lwz 0, 0(1) ;\ + lwz 3, 4(1) ;\ + lwz 4, 8(1) ;\ + mtctr 0 ;\ + bctrl ;\ +"); + +/* 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. We also take the + opportunity to install THREAD in our utcb. */ +static void * +stack_setup (struct __pthread *thread, + void (*entry_point)(void *(*)(void *), void *), + void *(*start_routine)(void *), void *arg) +{ + l4_word_t *top; + + /* Calculate top of the new stack. */ + top = (l4_word_t *) ((l4_word_t) thread->stackaddr + thread->stacksize); + + /* Initial stack frame. */ + top[-4] = 0; + top = top - 4; + + if (start_routine) + { + struct start_info *info = ((struct start_info *) top) - 1; + + info->entry_point = entry_point; + info->start_routine = start_routine; + info->arg = arg; + return (void *) info; + } + return top; +} + +int +__pthread_setup (struct __pthread *thread, + void (*entry_point)(void *(*)(void *), void *), + void *(*start_routine)(void *), void *arg) +{ + thread->mcontext.pc = first_entry_1; + thread->mcontext.sp = stack_setup (thread, entry_point, + start_routine, arg); + + if (l4_same_threads (thread->threadid, l4_myself ())) + l4_set_user_defined_handle ((l4_word_t) thread); + else + l4_set_user_defined_handle_of (thread->threadid, + (l4_word_t) thread); + return 0; +} diff --git a/sysdeps/l4/hurd/pt-kill.c b/sysdeps/l4/hurd/pt-kill.c new file mode 100644 index 00000000..1e64af49 --- /dev/null +++ b/sysdeps/l4/hurd/pt-kill.c @@ -0,0 +1,30 @@ +/* pthread_kill. Hurd version. + Copyright (C) 2002 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 <pthread.h> +#include <assert.h> +#include <signal.h> + +#include <pt-internal.h> + +int +pthread_kill (pthread_t thread, int sig) +{ + return ESRCH; +} diff --git a/sysdeps/l4/hurd/pt-sigstate-destroy.c b/sysdeps/l4/hurd/pt-sigstate-destroy.c new file mode 100644 index 00000000..997a0369 --- /dev/null +++ b/sysdeps/l4/hurd/pt-sigstate-destroy.c @@ -0,0 +1,28 @@ +/* Destroy the signal state. Hurd on L4 version. + Copyright (C) 2002 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 <pthread.h> + +#include <pt-internal.h> + +void +__pthread_sigstate_destroy (struct __pthread *thread) +{ + /* Nothing to do. */ +} diff --git a/sysdeps/l4/hurd/pt-sigstate-init.c b/sysdeps/l4/hurd/pt-sigstate-init.c new file mode 100644 index 00000000..25a3920c --- /dev/null +++ b/sysdeps/l4/hurd/pt-sigstate-init.c @@ -0,0 +1,28 @@ +/* Initialize the signal state. Hurd on L4 version. + Copyright (C) 2003 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 <pthread.h> + +#include <pt-internal.h> + +error_t +__pthread_sigstate_init (struct __pthread *thread) +{ + return 0; +} diff --git a/sysdeps/l4/hurd/pt-sigstate.c b/sysdeps/l4/hurd/pt-sigstate.c new file mode 100644 index 00000000..490c95fe --- /dev/null +++ b/sysdeps/l4/hurd/pt-sigstate.c @@ -0,0 +1,32 @@ +/* Set a thread's signal state. Hurd on L4 version. + Copyright (C) 2002 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 <pthread.h> +#include <assert.h> +#include <signal.h> + +#include <pt-internal.h> + +error_t +__pthread_sigstate (struct __pthread *thread, int how, + const sigset_t *set, sigset_t *oset, + int clear_pending) +{ + return EINVAL; +} diff --git a/sysdeps/l4/hurd/pt-sysdep.c b/sysdeps/l4/hurd/pt-sysdep.c index 265592ca..f23a137a 100644 --- a/sysdeps/l4/hurd/pt-sysdep.c +++ b/sysdeps/l4/hurd/pt-sysdep.c @@ -43,7 +43,7 @@ init_routine (void) __pthread_initialize (); /* Create the pthread structure for the main thread (i.e. us). */ - err = __pthread_create_internal (&thread, 0, 0, 0); + err = __pthread_create_internal (&thread, 0, 0, 0, 0); assert_perror (err); __pthread_initialize (); diff --git a/sysdeps/l4/hurd/pt-sysdep.h b/sysdeps/l4/hurd/pt-sysdep.h index e37beefa..7e69d709 100644 --- a/sysdeps/l4/hurd/pt-sysdep.h +++ b/sysdeps/l4/hurd/pt-sysdep.h @@ -20,24 +20,22 @@ #ifndef _PT_SYSDEP_H #define _PT_SYSDEP_H 1 -#include <l4/l4.h> -#include <task_client.h> -#include <machine/vmparam.h> +#include <l4.h> /* XXX */ #define _POSIX_THREAD_THREADS_MAX 64 /* The default stack size. */ -#define PTHREAD_STACK_DEFAULT (PAGE_SIZE) +#define PTHREAD_STACK_DEFAULT 4096 #define PTHREAD_SYSDEP_MEMBERS \ - L4_ThreadId_t threadid; \ - L4_Word_t my_errno; + l4_thread_id_t threadid; \ + l4_word_t my_errno; extern inline struct __pthread * _pthread_self (void) { - return (struct __pthread *) L4_MyUserDefinedHandle (); + return (struct __pthread *) l4_user_defined_handle (); } extern inline void diff --git a/sysdeps/l4/pt-block.c b/sysdeps/l4/pt-block.c index 050c6947..5992dc14 100644 --- a/sysdeps/l4/pt-block.c +++ b/sysdeps/l4/pt-block.c @@ -17,7 +17,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <l4/l4.h> +#include <l4.h> #include <pt-internal.h> @@ -25,5 +25,5 @@ void __pthread_block (struct __pthread *thread) { - L4_Receive (L4_anylocalthread); + l4_receive (l4_anylocalthread); } diff --git a/sysdeps/l4/pt-create-np.c b/sysdeps/l4/pt-create-np.c new file mode 100644 index 00000000..d5a23668 --- /dev/null +++ b/sysdeps/l4/pt-create-np.c @@ -0,0 +1,47 @@ +/* Thread creation from provided L4 thread. + Copyright (C) 2003 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 <assert.h> +#include <errno.h> +#include <pthread.h> +#include <signal.h> + +#include <bits/atomic.h> + +#include <pt-internal.h> + +/* Create a thread with attributes given by ATTR, executing + START_ROUTINE with argument ARG. TID is the provided L4 + kernel thread. */ +int +pthread_create_from_l4_tid_np (pthread_t *thread, + const pthread_attr_t *attr, + l4_thread_id_t tid, + void *(*start_routine)(void *), void *arg) +{ + int err; + struct __pthread *pthread; + + err = __pthread_create_internal (&pthread, attr, (void *) &tid, + start_routine, arg); + if (! err) + *thread = pthread->thread; + + return err; +} diff --git a/sysdeps/l4/pt-docancel.c b/sysdeps/l4/pt-docancel.c index 9a3bb26c..e832e26e 100644 --- a/sysdeps/l4/pt-docancel.c +++ b/sysdeps/l4/pt-docancel.c @@ -30,6 +30,7 @@ call_exit (void) int __pthread_do_cancel (struct __pthread *p) { +#if 0 assert (p->cancel_pending = 1); assert (p->cancel_state == PTHREAD_CANCEL_ENABLE); @@ -46,6 +47,6 @@ __pthread_do_cancel (struct __pthread *p) &dummy, &dummy, &dummy, &dummy, &dummy, &dummy_id); } - +#endif return 0; } diff --git a/sysdeps/l4/pt-spin.c b/sysdeps/l4/pt-spin.c new file mode 100644 index 00000000..355253ee --- /dev/null +++ b/sysdeps/l4/pt-spin.c @@ -0,0 +1,60 @@ +/* Spin locks. L4 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 <l4.h> + +#include <pthread.h> +#include <sched.h> + +/* The default for single processor machines; don't spin, it's + pointless. */ +#ifndef __PTHREAD_SPIN_COUNT +# define __PTHREAD_SPIN_COUNT 1 +#endif + +/* The number of times to spin while trying to lock a spin lock object + before yielding the processor. */ +int __pthread_spin_count = __PTHREAD_SPIN_COUNT; + + +/* Lock the spin lock object LOCK. If the lock is held by another + thread spin until it becomes available. */ +int +_pthread_spin_lock (__pthread_spinlock_t *lock) +{ + l4_time_t timeout; + int i; + + timeout.period.m = 1; + timeout.period.e = 1; + + while (1) + { + for (i = 0; i < __pthread_spin_count; i++) + { + if (__pthread_spin_trylock (lock) == 0) + return 0; + } + /* FIXME verify this */ + l4_receive_timeout (l4_nilthread, timeout); + timeout.period.e++; + } +} + +weak_alias (_pthread_spin_lock, pthread_spin_lock); diff --git a/sysdeps/l4/pt-stack-alloc.c b/sysdeps/l4/pt-stack-alloc.c index e28d5310..9a254141 100644 --- a/sysdeps/l4/pt-stack-alloc.c +++ b/sysdeps/l4/pt-stack-alloc.c @@ -17,37 +17,20 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <l4/l4.h> +#include <l4.h> #include <errno.h> +#include <sys/mman.h> #include <pt-internal.h> #define __pthread_stacksize __pthread_default_attr.stacksize -#include <l4/sigma0.h> -#include <hurd/debug.h> static void * allocate_page (void) { - L4_Fpage_t p; - /* The Kernel Interface page. */ - static L4_KernelInterfacePage_t *kip; - - if (! kip) - kip = L4_GetKernelInterface (); - -#define sigma0_tid() (L4_GlobalId (kip->ThreadInfo.X.UserBase, 1)) - p = L4_Sigma0_GetPage (sigma0_tid (), - L4_Fpage_Set_Attrs (L4_FpageLog2 (-1UL << 10, - PAGE_SHIFT), - L4_FullyAccessible)); - p.raw &= ~0x3ff; - - printf ("%s: Allocated page %x\n", - __FUNCTION__, p.raw); - - return (void *) p.raw; + return mmap + (NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); } diff --git a/sysdeps/l4/pt-thread-alloc.c b/sysdeps/l4/pt-thread-alloc.c index a9d5e212..00e99ff9 100644 --- a/sysdeps/l4/pt-thread-alloc.c +++ b/sysdeps/l4/pt-thread-alloc.c @@ -1,5 +1,5 @@ -/* Start thread. L4 version. - Copyright (C) 2002 Free Software Foundation, Inc. +/* Allocate kernel thread. L4 version. + Copyright (C) 2003 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 @@ -23,9 +23,8 @@ #include <pt-internal.h> -/* Start THREAD. Get the kernel thread scheduled and running. */ int -__pthread_thread_start (struct __pthread *thread) +__pthread_thread_alloc (struct __pthread *thread) { error_t err; @@ -33,10 +32,11 @@ __pthread_thread_start (struct __pthread *thread) if (__pthread_num_threads == 1) { assert (__pthread_total == 1); - thread->thread_id = L4_Myself (); + thread->threadid = l4_myself (); } else { +#if 0 CORBA_Environment env; env = idl4_default_environment; @@ -45,8 +45,8 @@ __pthread_thread_start (struct __pthread *thread) * (L4_Word_t *) &__system_pager, (L4_Word_t *) &thread->threadid, &env); if (err) +#endif return EAGAIN; } - return 0; } diff --git a/sysdeps/l4/pt-thread-halt.c b/sysdeps/l4/pt-thread-halt.c index 04d622f4..ea97eea0 100644 --- a/sysdeps/l4/pt-thread-halt.c +++ b/sysdeps/l4/pt-thread-halt.c @@ -19,20 +19,13 @@ #include <assert.h> #include <errno.h> -#include <mach.h> #include <pt-internal.h> -extern L4_ThreadId_t __task_server; - /* Deallocate the kernel thread resources associated with THREAD. */ void __pthread_thread_halt (struct __pthread *thread) { - CORBA_Environment env = idl4_default_environment; - L4_Word_t *t = (L4_Word_t *) &thread->threadid; - - assert (*t); - assert (thread_terminate (__task_server, *t, &env)); - *t = 0; + /* FIXME reuse thread somehow */ + l4_stop (thread->threadid); } diff --git a/sysdeps/l4/pt-thread-init.c b/sysdeps/l4/pt-thread-init.c new file mode 100644 index 00000000..ac50d58d --- /dev/null +++ b/sysdeps/l4/pt-thread-init.c @@ -0,0 +1,34 @@ +/* Start thread. L4 version. + Copyright (C) 2003 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 <assert.h> +#include <errno.h> +#include <string.h> + +#include <pt-internal.h> + +/* Initialize provided kernel thread. */ +int +__pthread_init_provided_thread (struct __pthread *thread, + void *p) +{ + l4_thread_id_t *tid = (l4_thread_id_t *) p; + thread->threadid = *tid; + return 0; +} diff --git a/sysdeps/l4/pt-thread-start.c b/sysdeps/l4/pt-thread-start.c index c428d290..36770703 100644 --- a/sysdeps/l4/pt-thread-start.c +++ b/sysdeps/l4/pt-thread-start.c @@ -1,5 +1,5 @@ /* Start thread. L4 version. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2003 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 @@ -23,70 +23,24 @@ #include <pt-internal.h> -#include "task_client.h" - -extern L4_ThreadId_t __system_pager; -extern L4_ThreadId_t __task_server; - -#ifndef WORKING_EXREGS -static void -send_startup_ipc (L4_ThreadId_t id, L4_Word_t ip, L4_Word_t sp) -{ - L4_Msg_t msg; - - printf ("%s: Sending startup message to %x, " - "(ip=%x, sp=%x)\n", - __FUNCTION__, * (L4_Word_t *) &id, ip, sp); - - L4_Clear (&msg); -#ifdef HAVE_PROPAGATION - L4_Set_VirtualSender (pager_tid); - L4_Set_Propagation (&msg.tag); -#endif - L4_Append_Word (&msg, ip); - L4_Append_Word (&msg, sp); -#ifndef HAVE_PROPAGATION - L4_Append_Word (&msg, *(L4_Word_t *) &id); - id = __system_pager; -#if 0 - DODEBUG (2, printf ("%s: Redirecting start request to pager (%x).\n", - __FUNCTION__, * (L4_Word_t *) &id)); -#endif -#endif - L4_LoadMsg (&msg); - L4_Send (id); -} -#endif - /* Start THREAD. Get the kernel thread scheduled and running. */ int __pthread_thread_start (struct __pthread *thread) { - error_t err; - /* The main thread is already running of course. */ if (__pthread_num_threads == 1) - { - assert (__pthread_total == 1); - assert (thread->thread_id == L4_Myself ()); - } + assert (__pthread_total == 1); else { - env = idl4_default_environment; - err = thread_resume (__task_server, - * (L4_Word_t *) &thread->threadid, - &env); - assert (! err); - -#ifndef WORKING_EXREGS - L4_AbortIpc_and_stop (thread->threadid); - L4_Start_SpIp (thread->threadid, (L4_Word_t) thread->mcontext.sp, - (L4_Word_t) thread->mcontext.pc); -#endif - send_startup_ipc (thread->threadid, (L4_Word_t) thread->mcontext.pc, - (L4_Word_t) thread->mcontext.sp); - + l4_thread_id_t dest = thread->threadid; + l4_word_t control = (L4_XCHG_REGS_SET_HALT | L4_XCHG_REGS_SET_SP + | L4_XCHG_REGS_SET_IP | L4_XCHG_REGS_SET_PAGER); + l4_word_t sp = (l4_word_t) thread->mcontext.sp; + l4_word_t ip = (l4_word_t) thread->mcontext.pc; + l4_word_t dummy = 0; + l4_thread_id_t pager = l4_pager (); + + l4_exchange_registers (&dest, &control, &sp, &ip, &dummy, &dummy, &pager); } - return 0; } diff --git a/sysdeps/l4/pt-timedblock.c b/sysdeps/l4/pt-timedblock.c new file mode 100644 index 00000000..fda14401 --- /dev/null +++ b/sysdeps/l4/pt-timedblock.c @@ -0,0 +1,34 @@ +/* Block a thread with a timeout. L4 version. + Copyright (C) 2000,02 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 <assert.h> +#include <errno.h> +#include <time.h> +#include <sys/time.h> + +#include <pt-internal.h> + +/* Block THREAD. */ +error_t +__pthread_timedblock (struct __pthread *thread, + const struct timespec *abstime) +{ + __pthread_block (thread); + return 0; +} diff --git a/sysdeps/l4/pt-wakeup.c b/sysdeps/l4/pt-wakeup.c index 7b00e4f6..342a2204 100644 --- a/sysdeps/l4/pt-wakeup.c +++ b/sysdeps/l4/pt-wakeup.c @@ -17,7 +17,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <l4/l4.h> +#include <l4.h> #include <pt-internal.h> @@ -25,5 +25,5 @@ void __pthread_wakeup (struct __pthread *thread) { - L4_Send (thread->threadid); + l4_send (thread->threadid); } diff --git a/sysdeps/mach/hurd/i386/pt-machdep.c b/sysdeps/mach/hurd/ia32/pt-machdep.c index face46c5..face46c5 100644 --- a/sysdeps/mach/hurd/i386/pt-machdep.c +++ b/sysdeps/mach/hurd/ia32/pt-machdep.c diff --git a/sysdeps/mach/hurd/i386/pt-setup.c b/sysdeps/mach/hurd/ia32/pt-setup.c index 9a855847..9a855847 100644 --- a/sysdeps/mach/hurd/i386/pt-setup.c +++ b/sysdeps/mach/hurd/ia32/pt-setup.c diff --git a/sysdeps/powerpc/bits/atomic.h b/sysdeps/powerpc/bits/atomic.h new file mode 100644 index 00000000..5ba19cd0 --- /dev/null +++ b/sysdeps/powerpc/bits/atomic.h @@ -0,0 +1,84 @@ +/* Atomic operations. PowerPC version. + Copyright (C) 2003 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) +{ + int tmp; + __asm__ ("\n\ +0: lwarx %0,0,%1 \n\ + add%I2 %0,%0,%2 \n\ + stwcx. %0,0,%1 \n\ + bne- 0b \n\ +" : "=&b"(tmp) : "r" (__var), "Ir"(1) : "cr0", "memory"); +} + +static inline void +__atomic_dec (__atomic_t *__var) +{ + int tmp; + __asm__ ("\n\ +0: lwarx %0,0,%1 \n\ + add%I2 %0,%0,%2 \n\ + stwcx. %0,0,%1 \n\ + bne- 0b \n\ +" : "=&b"(tmp) : "r" (__var), "Ir"(-1) : "cr0", "memory"); +} + +static inline int +__atomic_dec_and_test (__atomic_t *__var) +{ + unsigned char __ret; + +#if 0 + __asm__ __volatile ("lock; decl %0; sete %1" + : "=m" (*__var), "=qm" (__ret) : "m" (*__var)); +#endif + 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) +{ + int __ret; + __asm__ ("\n\ +0: lwarx %0,0,%1 \n\ + sub%I2c. %0,%0,%2 \n\ + cntlzw %0,%0 \n\ + bne- 1f \n\ + stwcx. %3,0,%1 \n\ + bne- 0b \n\ +1: \n\ +" : "=&b"(__ret) : "r"(__ptr), "Ir"(__oldval), "r"(__newval) : "cr0", "memory"); + return __ret >> 5; +} + +#endif diff --git a/sysdeps/powerpc/bits/machine-lock.h b/sysdeps/powerpc/bits/machine-lock.h new file mode 100644 index 00000000..cba6b0a6 --- /dev/null +++ b/sysdeps/powerpc/bits/machine-lock.h @@ -0,0 +1,78 @@ +/* Machine-specific definition for spin locks. PowerPC version. + Copyright (C) 1994,97,2002 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_LOCK_H +#define _MACHINE_LOCK_H + +/* The type of a spin lock variable. */ + +typedef __volatile long int __spin_lock_t; + +/* Value to initialize `__spin_lock_t' variables to. */ + +#define __SPIN_LOCK_INITIALIZER 0L + + +#ifndef _EXTERN_INLINE +#define _EXTERN_INLINE extern __inline +#endif + +/* Unlock LOCK. */ + +_EXTERN_INLINE void +__spin_unlock (__spin_lock_t *__lock) +{ + long int __locked; + __asm__ __volatile__ ("\ +0: lwarx %0,0,%1\n\ + stwcx. %2,0,%1\n\ + bne- 0b\n\ +" : "=&r" (__locked) : "r" (__lock), "r" (0) : "cr0"); +} + +/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */ + +_EXTERN_INLINE int +__spin_try_lock (register __spin_lock_t *__lock) +{ + long int __rtn; + __asm__ __volatile__ ("\ +0: lwarx %0,0,%1\n\ + stwcx. %2,0,%1\n\ + bne- 0b\n\ +" : "=&r" (__rtn) : "r" (__lock), "r" (1) : "cr0"); + return !__rtn; +} + +/* Return nonzero if LOCK is locked. */ + +_EXTERN_INLINE int +__spin_lock_locked (__spin_lock_t *__lock) +{ + long int __rtn; + __asm__ __volatile__ ("\ +0: lwarx %0,0,%1\n\ + stwcx. %0,0,%1\n\ + bne- 0b\n\ +" : "=&r" (__rtn) : "r" (__lock) : "cr0"); + return __rtn; +} + + +#endif /* machine-lock.h */ diff --git a/sysdeps/powerpc/bits/memory.h b/sysdeps/powerpc/bits/memory.h new file mode 100644 index 00000000..96624c3e --- /dev/null +++ b/sysdeps/powerpc/bits/memory.h @@ -0,0 +1,36 @@ +/* Memory barrier operations. PowerPC version. + Copyright (C) 2003 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. */ +inline void +__memory_barrier (void) +{ + asm ("sync" ::: "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/powerpc/bits/spin-lock.h b/sysdeps/powerpc/bits/spin-lock.h new file mode 100644 index 00000000..1dc25710 --- /dev/null +++ b/sysdeps/powerpc/bits/spin-lock.h @@ -0,0 +1,108 @@ +/* Machine-specific definitions for spin locks. PowerPC version. + Copyright (C) 2003 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 ((__pthread_spinlock_t) 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) +{ + long int __rtn; + __asm__ __volatile__ ("\ +0: lwarx %0,0,%1\n\ + stwcx. %2,0,%1\n\ + bne- 0b\n\ +" : "=&r" (__rtn) : "r" (__lock), "r" (1) : "cr0"); + return __rtn ? __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) +{ + long int __locked; + __asm__ __volatile__ ("\ +0: lwarx %0,0,%1\n\ + stwcx. %2,0,%1\n\ + bne- 0b\n\ +" : "=&r" (__locked) : "r" (__lock), "r" (0) : "cr0"); +} + +#endif /* Use extern inlines or force inlines. */ + +__END_DECLS + +#endif /* bits/spin-lock.h */ diff --git a/sysdeps/powerpc/machine-sp.h b/sysdeps/powerpc/machine-sp.h new file mode 100644 index 00000000..aa787c59 --- /dev/null +++ b/sysdeps/powerpc/machine-sp.h @@ -0,0 +1,31 @@ +/* Machine-specific function to return the stack pointer. i386 version. + Copyright (C) 1994,97,2001 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() ({ \ + void *__sp__; \ + __asm__ ("mr %0, 1" : "=r" (__sp__)); \ + __sp__; \ +}) + +#endif /* machine-sp.h */ diff --git a/sysdeps/powerpc/pt-machdep.h b/sysdeps/powerpc/pt-machdep.h new file mode 100644 index 00000000..6d456367 --- /dev/null +++ b/sysdeps/powerpc/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 */ |