From ada00b30cf36beecdf4b900b67ffb602fd0b89ca Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 6 Jan 2018 03:03:30 +0100 Subject: Move key management to sysdeps/generic Now that it does not use libihash any more, it is not hurd-dependent any more. * sysdeps/hurd/pt-destroy-specific.c: Move to sysdeps/generic/pt-destroy-specific.c * sysdeps/hurd/pt-key-create.c: Move to sysdeps/generic/pt-key-create.c. * sysdeps/hurd/pt-key-delete.c: Move to sysdeps/generic/pt-key-delete.c. * sysdeps/hurd/pt-key.h: Move to sysdeps/generic/pt-key.h. * sysdeps/hurd/pt-getspecific.c: Move to sysdeps/generic/pt-getspecific.c. * sysdeps/hurd/pt-init-specific.c: Move to sysdeps/generic/pt-init-specific.c. * sysdeps/hurd/pt-setspecific.c: Move to sysdeps/generic/pt-setspecific.c. --- sysdeps/generic/pt-key-delete.c | 43 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'sysdeps/generic/pt-key-delete.c') diff --git a/sysdeps/generic/pt-key-delete.c b/sysdeps/generic/pt-key-delete.c index 7b4ff63..499e9f3 100644 --- a/sysdeps/generic/pt-key-delete.c +++ b/sysdeps/generic/pt-key-delete.c @@ -1,4 +1,4 @@ -/* pthread_key_delete. Generic version. +/* pthread_key_delete. Hurd version. Copyright (C) 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -18,12 +18,47 @@ Boston, MA 02111-1307, USA. */ #include + #include int pthread_key_delete (pthread_key_t key) { - return ENOSYS; -} + 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 ++; -stub_warning (pthread_key_delete) + __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 (key < t->thread_specifics_size) + t->thread_specifics[key] = 0; + } + __pthread_rwlock_unlock (&__pthread_threads_lock); + } + + __pthread_mutex_unlock (&__pthread_key_lock); + + return err; +} -- cgit v1.2.3