Browse Source

Implement pthread_testcancel replacement for BIONIC

Luke Dashjr 12 years ago
parent
commit
f4c5f2db67
2 changed files with 8 additions and 0 deletions
  1. 1 0
      compat.h
  2. 7 0
      util.c

+ 1 - 0
compat.h

@@ -150,6 +150,7 @@ typedef long suseconds_t;
 #include <pthread.h>
 #include <pthread.h>
 #include <signal.h>
 #include <signal.h>
 #define pthread_cancel(pth)  pthread_kill(pth, SIGTERM)
 #define pthread_cancel(pth)  pthread_kill(pth, SIGTERM)
+extern void pthread_testcancel(void);
 #ifndef PTHREAD_CANCEL_ENABLE
 #ifndef PTHREAD_CANCEL_ENABLE
 #define PTHREAD_CANCEL_ENABLE  0
 #define PTHREAD_CANCEL_ENABLE  0
 #define PTHREAD_CANCEL_DISABLE 1
 #define PTHREAD_CANCEL_DISABLE 1

+ 7 - 0
util.c

@@ -1004,6 +1004,13 @@ void sighandler_pthread_cancel(int sig)
 	do_pthread_cancel_exit(flags);
 	do_pthread_cancel_exit(flags);
 }
 }
 
 
+void pthread_testcancel(void)
+{
+	int flags = (int)pthread_getspecific(key_pcwm);
+	if (flags & PCWM_CANCELLED && !(flags & PCWM_DISABLED))
+		do_pthread_cancel_exit(flags);
+}
+
 int pthread_setcancelstate(int state, int *oldstate)
 int pthread_setcancelstate(int state, int *oldstate)
 {
 {
 	int flags = (int)pthread_getspecific(key_pcwm);
 	int flags = (int)pthread_getspecific(key_pcwm);