Loading...
--- Libc/Libc-825.26/pthreads/pthread_cancelable.c
+++ Libc/Libc-498/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@
*
@@ -75,12 +75,6 @@
int isconforming);
extern int __sigwait(const sigset_t *set, int *sig);
-#ifdef VARIANT_CANCELABLE
-extern int __semwait_signal(int cond_sem, int mutex_sem, int timeout, int relative, __int64_t tv_sec, __int32_t tv_nsec);
-#else
-extern int __semwait_signal(int cond_sem, int mutex_sem, int timeout, int relative, __int64_t tv_sec, __int32_t tv_nsec) __asm__("___semwait_signal_nocancel");
-#endif
-
/*
* Wait for a thread to terminate and obtain its exit value.
*/
@@ -88,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)
@@ -133,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);
@@ -175,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);
@@ -185,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;
}
@@ -203,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 */
@@ -289,31 +285,10 @@
if (__sigwait(set, sig) == -1) {
err = errno;
-
-#ifdef VARIANT_CANCELABLE
- _pthread_testcancel(pthread_self(), 1);
-#endif /* VARIANT_CANCELABLE */
-
- /*
- * 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 */
+}