From 63ed0e78ffb72a9f425928344355c2159830b5af Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 23 Jul 1998 17:12:12 +0000 Subject: Fri Jul 24 03:00:25 1998 Ross Johnson * attr.c (pthread_attr_destroy): Fix merge conflicts. (pthread_attr_getdetachstate): Fix merge conflicts. (pthread_attr_setdetachstate): Fix merge conflicts. * pthread.h: Fix merge conflicts. * sync.c (pthread_join): Fix merge conflicts. --- sync.c | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'sync.c') diff --git a/sync.c b/sync.c index 20009ac..c3bd438 100644 --- a/sync.c +++ b/sync.c @@ -12,8 +12,7 @@ int pthread_join(pthread_t thread, void ** valueptr) { LPDWORD exitcode; - _pthread_threads_thread_t * target; - + int detachstate; pthread_t us = pthread_self(); /* First check if we are trying to join to ourselves. */ @@ -22,16 +21,20 @@ pthread_join(pthread_t thread, void ** valueptr) return EDEADLK; } - /* If the thread is detached, then join will return immediately. */ + /* Find the thread. */ + this = _pthread_find_thread_entry(thread); - target = _pthread_find_thread_entry(thread); - if (target < 0) + if (this == -1) { - return EINVAL; + return ESRCH; } - else if (target->detached == PTHREAD_CREATE_DETACHED) + + /* If the thread is detached, then join will return immediately. */ + + if (pthread_attr_getdetachedstate(&(this->attr), &detachstate) != 0 + || detachstate == PTHREAD_CREATE_DETACHED) { - return ESRCH; + return EINVAL; } /* Wait on the kernel thread object. */ @@ -60,3 +63,26 @@ pthread_join(pthread_t thread, void ** valueptr) return &exitcode; } +int +pthread_detach(pthread_t thread) +{ + _pthread_threads_thread_t * this; + int detachstate; + + this = _pthread_find_thread_entry(thread); + + if (this = -1) + { + return ESRCH; + } + + /* Check that we can detach this thread. */ + if (pthread_attr_getdetachedstate(&(this->attr), &detachstate) != 0 + || detachstate == PTHREAD_CREATE_DETACHED) + { + return EINVAL; + } + + /* FIXME: As far as I can determine we just no-op. */ + return 0; +} -- cgit v1.2.3