summaryrefslogtreecommitdiff
path: root/sync.c
diff options
context:
space:
mode:
authorrpj <rpj>1998-07-23 17:12:12 +0000
committerrpj <rpj>1998-07-23 17:12:12 +0000
commit63ed0e78ffb72a9f425928344355c2159830b5af (patch)
tree391078160e36b786d62c3505fd2c410607924f79 /sync.c
parent5b4731d25e148347d190d8ceb5f3f7aa2a7dac86 (diff)
Fri Jul 24 03:00:25 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* 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.
Diffstat (limited to 'sync.c')
-rw-r--r--sync.c42
1 files changed, 34 insertions, 8 deletions
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;
+}