pthread_exit(PTHREAD_CANCELED);
__pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
int pthread_join(pthread_t thread_id, void ** thread_return){  volatile pthread_descr self = thread_self();  struct pthread_request request;  pthread_handle handle = thread_handle(thread_id);  pthread_descr th;  pthread_extricate_if extr;  int already_canceled = 0;  /* Set up extrication interface */  extr.pu_object = handle;  extr.pu_extricate_func = join_extricate_func;  __pthread_lock(&handle->h_lock, self);  if (nonexisting_handle(handle, thread_id)) {    __pthread_unlock(&handle->h_lock);    return ESRCH;  }  th = handle->h_descr;  if (th == self) {    __pthread_unlock(&handle->h_lock);    return EDEADLK;  }  /* If detached or already joined, error */  if (th->p_detached || th->p_joining != NULL) {    __pthread_unlock(&handle->h_lock);    return EINVAL;  }  /* If not terminated yet, suspend ourselves. */  if (! th->p_terminated) {    /* Register extrication interface */    __pthread_set_own_extricate_if(self, &extr);    if (!(THREAD_GETMEM(self, p_canceled)	&& THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE))      th->p_joining = self;    else      already_canceled = 1;    __pthread_unlock(&handle->h_lock);    if (already_canceled) {      __pthread_set_own_extricate_if(self, 0);      pthread_exit(PTHREAD_CANCELED);    }    suspend(self);    /* Deregister extrication interface */    __pthread_set_own_extricate_if(self, 0);    /* This is a cancellation point */    if (THREAD_GETMEM(self, p_woken_by_cancel)	&& THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE) {      THREAD_SETMEM(self, p_woken_by_cancel, 0);      pthread_exit(PTHREAD_CANCELED);    }    __pthread_lock(&handle->h_lock, self);  }  /* Get return value */  if (thread_return != NULL) *thread_return = th->p_retval;  __pthread_unlock(&handle->h_lock);  /* Send notification to thread manager */  if (__pthread_manager_request >= 0) {    request.req_thread = self;    request.req_kind = REQ_FREE;    request.req_args.free.thread_id = thread_id;    __libc_write(__pthread_manager_request,		 (char *) &request, sizeof(request));  }  return 0;}