Loading...
pthreads/pthread_cancelable.c Libc-583 Libc-498.1.1
--- Libc/Libc-583/pthreads/pthread_cancelable.c
+++ Libc/Libc-498.1.1/pthreads/pthread_cancelable.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -73,7 +73,6 @@
 			const struct timespec *abstime,
 			int isRelative,
 			int isconforming);
-extern int __semwait_signal(int cond_sem, int mutex_sem, int timeout, int relative, __int64_t tv_sec, __int32_t tv_nsec);
 extern int __sigwait(const sigset_t *set, int *sig);
 
 /*
@@ -83,13 +82,13 @@
 pthread_join(pthread_t thread, 
 	     void **value_ptr)
 {
+	kern_return_t kern_res;
 	int res = 0;
 	pthread_t self = pthread_self();
+	mach_port_t ignore;
 	mach_port_t kthport;
 	int conforming = 0;
-#if !__DARWIN_UNIX03
-	kern_return_t kern_res;
-#endif
+	task_t tself = mach_task_self();
 
 #if __DARWIN_UNIX03
 	if (__unix_conforming == 0)
@@ -128,7 +127,7 @@
 					/* Wait for it to signal... */ 
 					pthread_cleanup_push(__posix_join_cleanup, (void *)thread);
 					do {
-						res = __semwait_signal(death, 0, 0, 0, (int64_t)0, (int32_t)0);
+						res = __semwait_signal(death, 0, 0, 0, 0, 0);
 					} while ((res < 0) && (errno == EINTR));
 					pthread_cleanup_pop(0);
 
@@ -170,7 +169,7 @@
 		semaphore_t death = SEMAPHORE_NULL; /* in case we need it */
 		semaphore_t joinsem = SEMAPHORE_NULL;
 
-		if (thread->joiner_notify == MACH_PORT_NULL)
+		if (thread->joiner_notify == NULL)
 			 death = new_sem_from_pool();
 
 		LOCK(thread->lock);
@@ -180,9 +179,11 @@
 			assert(thread->kernel_thread == kthport);
 			if (thread != self && (self == NULL || self->joiner != thread))
 			{
-				if (thread->joiner_notify == MACH_PORT_NULL) {
+				int already_exited;
+
+				if (thread->joiner_notify == NULL) {
 					if (death == SEMAPHORE_NULL)
-						LIBC_ABORT("thread %p: death == SEMAPHORE_NULL", thread);
+						abort();
 					thread->joiner_notify = death;
 					death = SEMAPHORE_NULL;
 				} 
@@ -198,7 +199,7 @@
 				/* Wait for it to signal... */ 
 				pthread_cleanup_push(__posix_join_cleanup, (void *)thread);
 				do {
-					res = __semwait_signal(joinsem, 0, 0, 0, (int64_t)0, (int32_t)0);
+					res = __semwait_signal(joinsem, 0, 0, 0, 0, 0);
 				} while ((res < 0) && (errno == EINTR));
 				pthread_cleanup_pop(0);
 #else /* __DARWIN_UNIX03 */
@@ -284,27 +285,10 @@
 
 	if (__sigwait(set, sig) == -1) {
 		err = errno;
-		
-		/* 
-		 * EINTR that isn't a result of pthread_cancel()
-		 * is translated to 0.
-		 */
-		if (err == EINTR) {
-			err = 0;
-		}
 	}
 	return(err);
 #else /* __DARWIN_UNIX03 */
-	if (__sigwait(set, sig) == -1) {
-		/* 
-		 * EINTR that isn't a result of pthread_cancel()
-		 * is translated to 0.
-		 */
-		if (errno != EINTR) {
-			return -1;
-		}
-	}
-
-	return 0;
-#endif /* __DARWIN_UNIX03 */
-}
+	return(__sigwait(set, sig));
+
+#endif /* __DARWIN_UNIX03 */
+}