cheap trick to further optimize locking normal mutexes
[musl] / src / thread / pthread_create.c
index ec329f5..a722a2d 100644 (file)
@@ -10,7 +10,6 @@ static void dummy_1(pthread_t self)
 {
 }
 weak_alias(dummy_1, __pthread_tsd_run_dtors);
-weak_alias(dummy_1, __sigtimer_handler);
 
 #ifdef __pthread_unwind_next
 #undef __pthread_unwind_next
@@ -36,7 +35,7 @@ void __pthread_unwind_next(struct __ptcb *cb)
                exit(0);
 
        if (self->detached && self->map_base) {
-               __syscall(__NR_rt_sigprocmask, SIG_BLOCK, (long)(uint64_t[1]){-1},0,8);
+               __syscall(SYS_rt_sigprocmask, SIG_BLOCK, (long)(uint64_t[1]){-1},0,8);
                __unmapself(self->map_base, self->map_size);
        }
 
@@ -54,7 +53,6 @@ static void docancel(struct pthread *self)
 static void cancel_handler(int sig, siginfo_t *si, void *ctx)
 {
        struct pthread *self = __pthread_self();
-       if (si->si_code == SI_TIMER) __sigtimer_handler(self);
        if (self->cancel && !self->canceldisable &&
            (self->cancelasync || (self->cancelpoint==1 && PC_AT_SYS(ctx))))
                docancel(self);
@@ -63,19 +61,8 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx)
 static void cancelpt(int x)
 {
        struct pthread *self = __pthread_self();
-       switch (x) {
-       case 1:
-               self->cancelpoint++;
-       case 0:
-               if (self->cancel && self->cancelpoint==1 && !self->canceldisable)
-                       docancel(self);
-               break;
-       case -1:
-               self->cancelpoint--;
-               break;
-       default:
-               self->canceldisable += x;
-       }
+       if ((self->cancelpoint+=x)==1 && self->cancel
+               && x<2U && !self->canceldisable) docancel(self);
 }
 
 static void init_threads()