Deleted Added
full compact
thr_join.c (13546) thr_join.c (22315)
1/*
2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 26 unchanged lines hidden (view full) ---

35#include <pthread.h>
36#include "pthread_private.h"
37
38int
39pthread_join(pthread_t pthread, void **thread_return)
40{
41 int rval = 0;
42 int status;
1/*
2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 26 unchanged lines hidden (view full) ---

35#include <pthread.h>
36#include "pthread_private.h"
37
38int
39pthread_join(pthread_t pthread, void **thread_return)
40{
41 int rval = 0;
42 int status;
43 pthread_t pthread1;
43
44 /* Block signals: */
45 _thread_kern_sig_block(&status);
46
44
45 /* Block signals: */
46 _thread_kern_sig_block(&status);
47
48 /* Point to the first thread in the list: */
49 pthread1 = _thread_link_list;
50
51 /* Search for the thread to join to: */
52 while (pthread1 != NULL && pthread1 != pthread) {
53 /* Point to the next thread: */
54 pthread1 = pthread1->nxt;
55 }
56
57 if (pthread1 == NULL) {
58 /* Point to the first thread in the dead thread list: */
59 pthread1 = _thread_dead;
60
61 /* Search for the thread to join to: */
62 while (pthread1 != NULL && pthread1 != pthread) {
63 /* Point to the next thread: */
64 pthread1 = pthread1->nxt;
65 }
66 }
67
68 if (pthread1 == NULL) {
69 /* Return an error: */
70 errno = ESRCH;
71 rval = -1;
72
47 /* Check if this thread has been detached: */
73 /* Check if this thread has been detached: */
48 if ((pthread->attr.flags & PTHREAD_DETACHED) != 0) {
74 } else if ((pthread->attr.flags & PTHREAD_DETACHED) != 0) {
49 /* Return an error: */
75 /* Return an error: */
50 _thread_seterrno(_thread_run, ESRCH);
76 errno = ESRCH;
51 rval = -1;
52 }
53 /* Check if the thread is not dead: */
54 else if (pthread->state != PS_DEAD) {
55 /* Add the running thread to the join queue: */
56 _thread_queue_enq(&(pthread->join_queue), _thread_run);
57
58 /* Schedule the next thread: */

--- 6 unchanged lines hidden (view full) ---

65 if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) {
66 /* Check if the return value is required: */
67 if (thread_return) {
68 /* Return the thread's return value: */
69 *thread_return = pthread->ret;
70 }
71 } else {
72 /* Return an error: */
77 rval = -1;
78 }
79 /* Check if the thread is not dead: */
80 else if (pthread->state != PS_DEAD) {
81 /* Add the running thread to the join queue: */
82 _thread_queue_enq(&(pthread->join_queue), _thread_run);
83
84 /* Schedule the next thread: */

--- 6 unchanged lines hidden (view full) ---

91 if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) {
92 /* Check if the return value is required: */
93 if (thread_return) {
94 /* Return the thread's return value: */
95 *thread_return = pthread->ret;
96 }
97 } else {
98 /* Return an error: */
73 _thread_seterrno(_thread_run, ESRCH);
99 errno = ESRCH;
74 rval = -1;
75 }
76 } else {
77 /* Check if the return value is required: */
78 if (thread_return != NULL) {
79 /* Return the thread's return value: */
80 *thread_return = pthread->ret;
81 }
82 }
83
84 /* Unblock signals: */
85 _thread_kern_sig_unblock(status);
86
87 /* Return the completion status: */
88 return (rval);
89}
90#endif
100 rval = -1;
101 }
102 } else {
103 /* Check if the return value is required: */
104 if (thread_return != NULL) {
105 /* Return the thread's return value: */
106 *thread_return = pthread->ret;
107 }
108 }
109
110 /* Unblock signals: */
111 _thread_kern_sig_unblock(status);
112
113 /* Return the completion status: */
114 return (rval);
115}
116#endif