pthread_setcancelstate(st, 0);
}
+static void cleanup(void *p)
+{
+ pthread_t self = p;
+ __syscall(SYS_timer_delete, self->result);
+}
+
static void *start(void *arg)
{
pthread_t self = __pthread_self();
self->start_arg = args->sev->sigev_value.sival_ptr;
self->result = (void *)-1;
+ pthread_cleanup_push(cleanup, self);
pthread_barrier_wait(&args->b);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
/* Loop on async-signal-safe cancellation point */
for (;;) sleep(1);
+ pthread_cleanup_pop(0);
return 0;
}
int timer_delete(timer_t t)
{
- pthread_t td = 0;
- int r;
- if ((uintptr_t)t & 1) t = (void *)((unsigned long)t / 2);
- else td = t, t = td->result;
- r = __syscall(SYS_timer_delete, (long)t);
- if (td) pthread_cancel(td);
- return r;
+ if ((uintptr_t)t & 1)
+ return __syscall(SYS_timer_delete, ((unsigned long)t / 2));
+ return pthread_cancel(t);
}