diff options
author | Neal H. Walfield <neal@gnu.org> | 2007-11-20 17:39:57 +0000 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gnu.org> | 2009-04-07 23:09:57 +0200 |
commit | 961d71afd49f55395e6dbfe203d6b968e4105ee0 (patch) | |
tree | 97f99e363a54786ad2323f6b1c5a5e004d5965e8 /sysdeps/l4 | |
parent | 43e3246eb6a26162ef931dadcd4a8a649c57289b (diff) |
2007-11-20 Neal H. Walfield <neal@gnu.org>
* Makefile.am (libpthread_a_SOURCES): Remove pt-create-np.c.
* sysdeps/l4/pt-create-np.c: Remove file.
* sysdeps/l4/pt-pool-np.c (pthread_pool_add_np): Change tid from
an _L4_thread_id_t to an l4_thread_id_t.
(pthread_pool_get_np): Return an l4_thread_id_t, not a
_L4_thread_id_t.
* sysdeps/l4/bits/pthread-np.h (pthread_create_from_l4_tid_np):
Remove declaration.
(pthread_pool_add_np): Change tid from an _L4_thread_id_t to an
l4_thread_id_t.
(pthread_pool_get_np): Return an l4_thread_id_t, not a
_L4_thread_id_t.
* sysdeps/l4/pt-docancel.c (__pthread_do_cancel): Implement for
the case that the target thread is not the executing thread.
* sysdeps/l4/pt-thread-alloc.c (__pthread_thread_alloc): Return
EAGAIN if pthread_pool_get_np does not return a thread. Update
comments.
* sysdeps/l4/pt-thread-start.c (__pthread_thread_start): Don't set
the thread's pager. Assert that if this is the first thread, then
THREAD->THREADID is designates the running thread.
* sysdeps/l4/pt-timedblock.c (__pthread_timedblock): Add warning
about incomplete implementation.
* Makefile.am (libpthread_a_SOURCES): Remove pt-thread-init.c.
* sysdeps/l4/pt-thread-init.c: Remove dead file.
* sysdeps/l4/pt-start.c: Remove dead file.
Diffstat (limited to 'sysdeps/l4')
-rw-r--r-- | sysdeps/l4/bits/pthread-np.h | 13 | ||||
-rw-r--r-- | sysdeps/l4/pt-create-np.c | 46 | ||||
-rw-r--r-- | sysdeps/l4/pt-docancel.c | 20 | ||||
-rw-r--r-- | sysdeps/l4/pt-pool-np.c | 4 | ||||
-rw-r--r-- | sysdeps/l4/pt-start.c | 103 | ||||
-rw-r--r-- | sysdeps/l4/pt-thread-alloc.c | 23 | ||||
-rw-r--r-- | sysdeps/l4/pt-thread-init.c | 34 | ||||
-rw-r--r-- | sysdeps/l4/pt-thread-start.c | 12 | ||||
-rw-r--r-- | sysdeps/l4/pt-timedblock.c | 1 |
9 files changed, 18 insertions, 238 deletions
diff --git a/sysdeps/l4/bits/pthread-np.h b/sysdeps/l4/bits/pthread-np.h index 3a98cd3f..6a02bdc0 100644 --- a/sysdeps/l4/bits/pthread-np.h +++ b/sysdeps/l4/bits/pthread-np.h @@ -26,19 +26,10 @@ #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); - /* Add the thread TID to the internal kernel thread pool. */ -extern int pthread_pool_add_np (_L4_thread_id_t tid); +extern int pthread_pool_add_np (l4_thread_id_t tid); /* Get the first thread from the pool. */ -extern _L4_thread_id_t pthread_pool_get_np (void); +extern l4_thread_id_t pthread_pool_get_np (void); #endif /* bits/pthread-np.h */ diff --git a/sysdeps/l4/pt-create-np.c b/sysdeps/l4/pt-create-np.c deleted file mode 100644 index 68b8b004..00000000 --- a/sysdeps/l4/pt-create-np.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Thread creation from provided L4 thread. - Copyright (C) 2003, 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 <assert.h> -#include <errno.h> -#include <pthread.h> -#include <signal.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; - -#warning Does not use TID. - err = __pthread_create_internal (&pthread, attr, - 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 e832e26e..a3965d0d 100644 --- a/sysdeps/l4/pt-docancel.c +++ b/sysdeps/l4/pt-docancel.c @@ -1,5 +1,5 @@ /* Cancel a thread. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 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 @@ -30,23 +30,13 @@ call_exit (void) int __pthread_do_cancel (struct __pthread *p) { -#if 0 - assert (p->cancel_pending = 1); + assert (p->cancel_pending == 1); assert (p->cancel_state == PTHREAD_CANCEL_ENABLE); - if (L4_SameThreads (L4_Myself (), p->threadid)) + if (l4_is_thread_equal (l4_myself (), p->threadid)) call_exit (); else - { - L4_Word_t dummy; - L4_ThreadId_t dummy_id; - - /* Change the ip of the target thread to make it exit. */ - L4_ExchangeRegisters (p->threadid, (1 << 4), 0, call_exit, - 0, 0, L4_nilthread, - &dummy, &dummy, &dummy, &dummy, &dummy, - &dummy_id); - } -#endif + l4_start_sp_ip (p->threadid, (l4_word_t) p->mcontext.sp, + (l4_word_t) call_exit); return 0; } diff --git a/sysdeps/l4/pt-pool-np.c b/sysdeps/l4/pt-pool-np.c index f59a3e2b..e83022ba 100644 --- a/sysdeps/l4/pt-pool-np.c +++ b/sysdeps/l4/pt-pool-np.c @@ -26,7 +26,7 @@ _L4_thread_id_t pool_list = l4_nilthread; /* Add the thread TID to the pthread kernel thread pool. */ int -pthread_pool_add_np (_L4_thread_id_t tid, bool stop) +pthread_pool_add_np (l4_thread_id_t tid) { __pthread_mutex_lock (&pool_lock); /* FIXME: Do error checking. */ @@ -39,7 +39,7 @@ pthread_pool_add_np (_L4_thread_id_t tid, bool stop) /* Get the first thread from the pool. */ -_L4_thread_id_t +l4_thread_id_t pthread_pool_get_np (void) { _L4_thread_id_t tid; diff --git a/sysdeps/l4/pt-start.c b/sysdeps/l4/pt-start.c deleted file mode 100644 index fb4e27be..00000000 --- a/sysdeps/l4/pt-start.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Start thread. L4 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 <assert.h> -#include <errno.h> -#include <string.h> - -#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. We allocate all system-specific resources, including - a kernel thread, set it up, and get it running. */ -int -__pthread_start (struct __pthread *thread) -{ - error_t err; - - if (__pthread_num_threads == 1) - /* The main thread is already running: do nothing. */ - { - assert (__pthread_total == 1); - thread->threadid = L4_Myself (); - } - else - { - CORBA_Environment env; - - env = idl4_default_environment; - err = thread_create (__task_server, - L4_Version (L4_Myself ()), - * (L4_Word_t *) &__system_pager, - (L4_Word_t *) &thread->threadid, &env); - if (err) - return EAGAIN; - - 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); - - } - - return 0; -} diff --git a/sysdeps/l4/pt-thread-alloc.c b/sysdeps/l4/pt-thread-alloc.c index fc2f43b4..ec69afb5 100644 --- a/sysdeps/l4/pt-thread-alloc.c +++ b/sysdeps/l4/pt-thread-alloc.c @@ -30,33 +30,14 @@ __pthread_thread_alloc (struct __pthread *thread) /* The main thread is already running of course. */ if (__pthread_num_threads == 1) - { - /* XXX: The initialization code needs to make this consistent. - Right now, we have none and this whole library is a hack - anyways. */ -#warning __pthread_total is inconsistent. -#if 0 - assert (__pthread_total == 1); -#endif - thread->threadid = l4_myself (); - } + thread->threadid = l4_myself (); else { thread->threadid = pthread_pool_get_np (); if (thread->threadid != l4_nilthread) return 0; -#if 0 - CORBA_Environment env; - - env = idl4_default_environment; - err = thread_create (__task_server, - L4_Version (L4_Myself ()), - * (L4_Word_t *) &__system_pager, - (L4_Word_t *) &thread->threadid, &env); - if (err) -#endif - return EAGAIN; + return EAGAIN; } return 0; } diff --git a/sysdeps/l4/pt-thread-init.c b/sysdeps/l4/pt-thread-init.c deleted file mode 100644 index ac50d58d..00000000 --- a/sysdeps/l4/pt-thread-init.c +++ /dev/null @@ -1,34 +0,0 @@ -/* 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 10996e1c..538d0444 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) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 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 @@ -29,12 +29,12 @@ __pthread_thread_start (struct __pthread *thread) { /* The main thread is already running of course. */ if (__pthread_num_threads == 1) - assert (__pthread_total == 1); - else { - l4_set_pager_of (thread->threadid, l4_pager ()); - l4_start_sp_ip (thread->threadid, (l4_word_t) thread->mcontext.sp, - (l4_word_t) thread->mcontext.pc); + assert (__pthread_total == 1); + assert (l4_is_thread_equal (l4_myself (), thread->threadid)); } + else + l4_start_sp_ip (thread->threadid, (l4_word_t) thread->mcontext.sp, + (l4_word_t) thread->mcontext.pc); return 0; } diff --git a/sysdeps/l4/pt-timedblock.c b/sysdeps/l4/pt-timedblock.c index fda14401..ce7972bd 100644 --- a/sysdeps/l4/pt-timedblock.c +++ b/sysdeps/l4/pt-timedblock.c @@ -29,6 +29,7 @@ error_t __pthread_timedblock (struct __pthread *thread, const struct timespec *abstime) { +#warning Need gettimeofday to implement properly. __pthread_block (thread); return 0; } |