fix multiple issues in legacy function getpass
[musl] / src / thread / cancel_impl.c
index a164898..069b279 100644 (file)
@@ -1,4 +1,5 @@
 #include "pthread_impl.h"
+#include "syscall.h"
 
 void __cancel()
 {
@@ -8,14 +9,18 @@ void __cancel()
        pthread_exit(PTHREAD_CANCELED);
 }
 
-long __syscall_cp_asm(volatile void *, long, long, long, long, long, long, long);
+long __syscall_cp_asm(volatile void *, syscall_arg_t,
+                      syscall_arg_t, syscall_arg_t, syscall_arg_t,
+                      syscall_arg_t, syscall_arg_t, syscall_arg_t);
 
-long (__syscall_cp)(long nr, long u, long v, long w, long x, long y, long z)
+long (__syscall_cp)(syscall_arg_t nr,
+                    syscall_arg_t u, syscall_arg_t v, syscall_arg_t w,
+                    syscall_arg_t x, syscall_arg_t y, syscall_arg_t z)
 {
        pthread_t self;
        long r;
 
-       if (!libc.main_thread || (self = __pthread_self())->canceldisable)
+       if (!libc.has_thread_pointer || (self = __pthread_self())->canceldisable)
                return __syscall(nr, u, v, w, x, y, z);
 
        r = __syscall_cp_asm(&self->cancel, nr, u, v, w, x, y, z);
@@ -47,12 +52,13 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx)
                __cancel();
        }
 
-       __syscall(SYS_tgkill, self->pid, self->tid, SIGCANCEL);
+       __syscall(SYS_tkill, self->tid, SIGCANCEL);
 }
 
 void __testcancel()
 {
-       pthread_t self = pthread_self();
+       if (!libc.has_thread_pointer) return;
+       pthread_t self = __pthread_self();
        if (self->cancel && !self->canceldisable)
                __cancel();
 }