diff options
| author | Samuel Thibault <samy@hurd.youpi.perso.aquilenet.fr> | 2012-05-20 13:37:32 +0000 |
|---|---|---|
| committer | Samuel Thibault <samy@hurd.youpi.perso.aquilenet.fr> | 2012-05-20 13:37:32 +0000 |
| commit | ca35f7a6e428a95d1ff0aa40d6545820b580df1d (patch) | |
| tree | 27027c7aabca1f4bbe7fb684e4f0f1a7d3b24051 /libpthread/sysdeps/hurd | |
| parent | c490cb9d4c1df1adcb2e76679e1969e7fe062560 (diff) | |
| parent | 756a64304b61a94b9b57ae88c4af5654152f5b8e (diff) | |
Merge branch 'upstream-merged'
Diffstat (limited to 'libpthread/sysdeps/hurd')
| -rw-r--r-- | libpthread/sysdeps/hurd/pt-destroy-specific.c | 79 | ||||
| -rw-r--r-- | libpthread/sysdeps/hurd/pt-getspecific.c | 39 | ||||
| -rw-r--r-- | libpthread/sysdeps/hurd/pt-init-specific.c | 30 | ||||
| -rw-r--r-- | libpthread/sysdeps/hurd/pt-key-create.c | 109 | ||||
| -rw-r--r-- | libpthread/sysdeps/hurd/pt-key-delete.c | 64 | ||||
| -rw-r--r-- | libpthread/sysdeps/hurd/pt-key.h | 76 | ||||
| -rw-r--r-- | libpthread/sysdeps/hurd/pt-kill.c | 52 | ||||
| -rw-r--r-- | libpthread/sysdeps/hurd/pt-setspecific.c | 47 |
8 files changed, 0 insertions, 496 deletions
diff --git a/libpthread/sysdeps/hurd/pt-destroy-specific.c b/libpthread/sysdeps/hurd/pt-destroy-specific.c deleted file mode 100644 index f7896e5e..00000000 --- a/libpthread/sysdeps/hurd/pt-destroy-specific.c +++ /dev/null @@ -1,79 +0,0 @@ -/* __pthread_destory_specific. 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 <stdlib.h> -#include <hurd/ihash.h> - -#include <pt-internal.h> - -void -__pthread_destroy_specific (struct __pthread *thread) -{ - error_t err; - int i; - int seen_one; - - /* Check if there is any thread specific data. */ - if (! thread->thread_specifics) - return; - - __pthread_key_lock_ready (); - - /* Iterate and call the destructors on any thread specific data. */ - for (;;) - { - seen_one = 0; - - __pthread_mutex_lock (&__pthread_key_lock); - - for (i = 0; i < __pthread_key_count; i ++) - { - void *value; - - if (__pthread_key_destructors[i] == PTHREAD_KEY_INVALID) - continue; - - value = hurd_ihash_find (thread->thread_specifics, i); - if (value) - { - err = hurd_ihash_remove (thread->thread_specifics, i); - assert (err == 1); - - if (__pthread_key_destructors[i]) - { - seen_one = 1; - __pthread_key_destructors[i] (value); - } - } - } - - __pthread_mutex_unlock (&__pthread_key_lock); - - if (! seen_one) - break; - - /* This may take a very long time. Let those blocking on - pthread_key_create or pthread_key_delete make progress. */ - sched_yield (); - } - - hurd_ihash_free (thread->thread_specifics); - thread->thread_specifics = 0; -} diff --git a/libpthread/sysdeps/hurd/pt-getspecific.c b/libpthread/sysdeps/hurd/pt-getspecific.c deleted file mode 100644 index 71ec63c6..00000000 --- a/libpthread/sysdeps/hurd/pt-getspecific.c +++ /dev/null @@ -1,39 +0,0 @@ -/* pthread_getspecific. 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 <hurd/ihash.h> - -#include <pt-internal.h> - -void * -pthread_getspecific (pthread_key_t key) -{ - struct __pthread *self; - - if (key < 0 || key >= __pthread_key_count - || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID) - return NULL; - - self = _pthread_self (); - if (! self->thread_specifics) - return 0; - - return hurd_ihash_find (self->thread_specifics, key); -} diff --git a/libpthread/sysdeps/hurd/pt-init-specific.c b/libpthread/sysdeps/hurd/pt-init-specific.c deleted file mode 100644 index c1bacbcb..00000000 --- a/libpthread/sysdeps/hurd/pt-init-specific.c +++ /dev/null @@ -1,30 +0,0 @@ -/* __pthread_init_specific. 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 <stdlib.h> - -#include <pt-internal.h> - -error_t -__pthread_init_specific (struct __pthread *thread) -{ - thread->thread_specifics = 0; - return 0; -} diff --git a/libpthread/sysdeps/hurd/pt-key-create.c b/libpthread/sysdeps/hurd/pt-key-create.c deleted file mode 100644 index b3e01412..00000000 --- a/libpthread/sysdeps/hurd/pt-key-create.c +++ /dev/null @@ -1,109 +0,0 @@ -/* pthread_key_create. 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 <stdlib.h> -#include <assert.h> - -#include <pt-internal.h> - -pthread_mutex_t __pthread_key_lock; - -void (**__pthread_key_destructors) (void *arg); -int __pthread_key_size; -int __pthread_key_count; -int __pthread_key_invalid_count; - -int -pthread_key_create (pthread_key_t *key, void (*destructor) (void *)) -{ - /* Where to look for the next key slot. */ - static int index; - - __pthread_key_lock_ready (); - - __pthread_mutex_lock (&__pthread_key_lock); - - do_search: - /* Use the search hint and try to find a free slot. */ - for (; index < __pthread_key_count - && __pthread_key_destructors[index] != PTHREAD_KEY_INVALID; - index ++) - ; - - /* See if we actually found a free element. */ - if (index < __pthread_key_count) - { - assert (__pthread_key_destructors[index] == PTHREAD_KEY_INVALID); - assert (__pthread_key_invalid_count > 0); - - __pthread_key_invalid_count --; - __pthread_key_destructors[index] = destructor; - *key = index ++; - - __pthread_mutex_unlock (&__pthread_key_lock); - return 0; - } - - assert (index == __pthread_key_count); - - /* No space at the end. */ - if (__pthread_key_size == __pthread_key_count) - { - /* See if it is worth looking for a free element. */ - if (__pthread_key_invalid_count > 4 - && __pthread_key_invalid_count > __pthread_key_size / 8) - { - index = 0; - goto do_search; - } - - - /* Resize the array. */ - { - void *t; - int newsize; - - if (__pthread_key_size == 0) - newsize = 8; - else - newsize = __pthread_key_size * 2; - - t = realloc (__pthread_key_destructors, - newsize * sizeof (*__pthread_key_destructors)); - if (! t) - { - __pthread_mutex_unlock (&__pthread_key_lock); - return ENOMEM; - } - - __pthread_key_size = newsize; - __pthread_key_destructors = t; - } - } - - __pthread_key_destructors[index] = destructor; - *key = index; - - index ++; - __pthread_key_count ++; - - __pthread_mutex_unlock (&__pthread_key_lock); - return 0; -} diff --git a/libpthread/sysdeps/hurd/pt-key-delete.c b/libpthread/sysdeps/hurd/pt-key-delete.c deleted file mode 100644 index 9d88647e..00000000 --- a/libpthread/sysdeps/hurd/pt-key-delete.c +++ /dev/null @@ -1,64 +0,0 @@ -/* pthread_key_delete. 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 <pt-internal.h> - -int -pthread_key_delete (pthread_key_t key) -{ - error_t err = 0; - - __pthread_key_lock_ready (); - - __pthread_mutex_lock (&__pthread_key_lock); - - if (key < 0 || key >= __pthread_key_count - || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID) - err = EINVAL; - else - { - int i; - - __pthread_key_destructors[key] = PTHREAD_KEY_INVALID; - __pthread_key_invalid_count ++; - - pthread_rwlock_rdlock (&__pthread_threads_lock); - for (i = 0; i < __pthread_num_threads; ++i) - { - struct __pthread *t; - - t = __pthread_threads[i]; - - if (t == NULL) - continue; - - /* Just remove the key, no need to care whether it was - already there. */ - if (t->thread_specifics) - hurd_ihash_remove (t->thread_specifics, key); - } - pthread_rwlock_unlock (&__pthread_threads_lock); - } - - __pthread_mutex_unlock (&__pthread_key_lock); - - return err; -} diff --git a/libpthread/sysdeps/hurd/pt-key.h b/libpthread/sysdeps/hurd/pt-key.h deleted file mode 100644 index 494e01d7..00000000 --- a/libpthread/sysdeps/hurd/pt-key.h +++ /dev/null @@ -1,76 +0,0 @@ -/* pthread_key internal declatations for the 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 <hurd/ihash.h> - -#define PTHREAD_KEY_MEMBERS \ - hurd_ihash_t thread_specifics; - -#define PTHREAD_KEY_INVALID (void *) (-1) - - -/* __PTHREAD_KEY_DESTRUCTORS is an array of destructors with - __PTHREAD_KEY_SIZE elements. If an element with index less than - __PTHREAD_KEY_COUNT is invalid, it shall contain the value - PTHREAD_KEY_INVALID which shall be distinct from NULL. - - Normally, we just add new keys to the end of the array and realloc - it as necessary. The pthread_key_create routine may decide to - rescan the array if __PTHREAD_KEY_FREE is large. */ -extern void (**__pthread_key_destructors) (void *arg); -extern int __pthread_key_size; -extern int __pthread_key_count; -/* Number of invalid elements in the array. Does not include elements - for which memory has been allocated but which have not yet been - used (i.e. those elements with indexes greater than - __PTHREAD_KEY_COUNT). */ -extern int __pthread_key_invalid_count; - -/* Protects the above variables. This must be a recursive lock: the - destructors may call pthread_key_delete. */ -extern pthread_mutex_t __pthread_key_lock; - -#include <assert.h> - -static inline void -__pthread_key_lock_ready (void) -{ - static pthread_once_t o = PTHREAD_ONCE_INIT; - - void do_init (void) - { - int err; - pthread_mutexattr_t attr; - - err = pthread_mutexattr_init (&attr); - assert_perror (err); - - err = pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); - assert_perror (err); - - err = pthread_mutex_init (&__pthread_key_lock, &attr); - assert_perror (err); - - err = pthread_mutexattr_destroy (&attr); - assert_perror (err); - } - - pthread_once (&o, do_init); -} diff --git a/libpthread/sysdeps/hurd/pt-kill.c b/libpthread/sysdeps/hurd/pt-kill.c deleted file mode 100644 index d204e3f6..00000000 --- a/libpthread/sysdeps/hurd/pt-kill.c +++ /dev/null @@ -1,52 +0,0 @@ -/* 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 <hurd/signal.h> - -#include <pt-internal.h> - -int -pthread_kill (pthread_t thread, int sig) -{ - struct __pthread *pthread; - struct hurd_signal_detail detail; - struct hurd_sigstate *ss; - - /* Lookup the thread structure for THREAD. */ - pthread = __pthread_getid (thread); - if (pthread == NULL) - return ESRCH; - - ss = _hurd_thread_sigstate (pthread->kernel_thread); - assert (ss); - - if (!sig) - return 0; - - detail.exc = 0; - detail.code = sig; - detail.error = 0; - - _hurd_raise_signal (ss, sig, &detail); - - return 0; -} diff --git a/libpthread/sysdeps/hurd/pt-setspecific.c b/libpthread/sysdeps/hurd/pt-setspecific.c deleted file mode 100644 index d0b7302f..00000000 --- a/libpthread/sysdeps/hurd/pt-setspecific.c +++ /dev/null @@ -1,47 +0,0 @@ -/* pthread_setspecific. Generic 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 <hurd/ihash.h> - -#include <pt-internal.h> - -int -pthread_setspecific (pthread_key_t key, const void *value) -{ - error_t err; - struct __pthread *self = _pthread_self (); - - if (key < 0 || key >= __pthread_key_count - || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID) - return EINVAL; - - if (! self->thread_specifics) - { - err = hurd_ihash_create (&self->thread_specifics, HURD_IHASH_NO_LOCP); - if (err) - return ENOMEM; - } - - err = hurd_ihash_add (self->thread_specifics, key, (void *) value); - if (err) - return ENOMEM; - - return 0; -} |
