123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- #include "pthread.h"
- #include "implement.h"
- int
- pthread_setcancelstate (int state, int *oldstate)
- {
- int result = 0;
- pthread_t self = pthread_self ();
- pte_thread_t * sp = (pte_thread_t *) self;
- if (sp == NULL
- || (state != PTHREAD_CANCEL_ENABLE && state != PTHREAD_CANCEL_DISABLE))
- {
- return EINVAL;
- }
-
- (void) pthread_mutex_lock (&sp->cancelLock);
- if (oldstate != NULL)
- {
- *oldstate = sp->cancelState;
- }
- sp->cancelState = state;
-
- if (state == PTHREAD_CANCEL_ENABLE
- && (sp->cancelType == PTHREAD_CANCEL_ASYNCHRONOUS)
- && (pte_osThreadCheckCancel(sp->threadId) == PTE_OS_INTERRUPTED) )
- {
- sp->state = PThreadStateCanceling;
- sp->cancelState = PTHREAD_CANCEL_DISABLE;
- (void) pthread_mutex_unlock (&sp->cancelLock);
- pte_throw (PTE_EPS_CANCEL);
-
- }
- (void) pthread_mutex_unlock (&sp->cancelLock);
- return (result);
- }
|