From d288c1c78caa40281a1ef6ea515c0b900155e5bc Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Thu, 4 Jul 2002 14:17:30 +0000 Subject: 2002-06-25 Thomas Pfaff * include/pthread.h (PTHREAD_CANCELED): Defined a reasonable value. * pthread.cc (pthread_exit): Call method instead of function. (pthread_setcancelstate): Ditto. (pthread_setcanceltype): Ditto. (pthread_testcancel): Ditto. * thread.h (pthread::cancel_event): New member. (__pthread_cancel_self): New prototype. (pthread::exit): New Method. (pthread::cancel): Ditto. (pthread::testcancel): Ditto. (pthread::cancel_self): Ditto. (pthread::static_cancel_self): Ditto. (pthread::setcancelstate): Ditto. (pthread::setcanceltype): Ditto. (__pthread_cancel): Give c++ linkage. (__pthread_exit): Remove. (__pthread_setcancelstate): Ditto. (__pthread_setcanceltype): Ditto. (__pthread_testcancel): Ditto. * thread.cc (pthread::pthread): Inititialize cancel_event. (pthread::~pthread): Close cancel_event if needed. (pthread::create): Create cancel_event. (pthread::exit): New method. Replacement for __pthread_exit. (pthread::cancel): New method. (pthread::testcancel): Ditto. (pthread::static_cancel_self); New static method. (pthread::setcancelstate): New method. Replacement for __pthread_setcancelstate. (pthread::setcanceltype): New method. Replacement for __pthread_setcanceltype. (pthread::pop_cleanup_handler): Added lock for async cancel safe cancellation. (pthread::thread_init_wrapper): Change __pthread_exit to thread->exit(). (__pthread_cancel): Call method thread->cancel(). (__pthread_exit): Remove. (__pthread_setcancelstate): Ditto. (__pthread_setcanceltype): Ditto. (__pthread_testcancel): Ditto. --- winsup/cygwin/thread.h | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'winsup/cygwin/thread.h') diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index f926a3abd..a00ad903d 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -266,6 +266,7 @@ public: void *return_ptr; bool suspended; int cancelstate, canceltype; + HANDLE cancel_event; pthread_t joiner; // int joinable; @@ -287,6 +288,19 @@ public: pthread (); ~pthread (); + void exit (void *value_ptr); + + int cancel (); + void testcancel (); + void cancel_self () + { + exit (PTHREAD_CANCELED); + } + static void static_cancel_self (); + + int setcancelstate (int state, int *oldstate); + int setcanceltype (int type, int *oldtype); + void push_cleanup_handler (__pthread_cleanup_handler *handler); void pop_cleanup_handler (int const execute); @@ -298,7 +312,6 @@ private: __pthread_cleanup_handler *cleanup_stack; pthread_mutex mutex; - friend void __pthread_exit (void *value_ptr); friend int __pthread_join (pthread_t * thread, void **return_val); friend int __pthread_detach (pthread_t * thread); @@ -406,8 +419,10 @@ void __pthread_atforkprepare(void); void __pthread_atforkparent(void); void __pthread_atforkchild(void); +/* Cancellation */ +int __pthread_cancel (pthread_t thread); + /* Thread Exit */ -void __pthread_exit (void *value_ptr); int __pthread_join (pthread_t * thread, void **return_val); int __pthread_detach (pthread_t * thread); @@ -504,10 +519,6 @@ int __pthread_setschedparam (pthread_t thread, int policy, const struct sched_param *param); /* cancelability states */ -int __pthread_cancel (pthread_t thread); -int __pthread_setcancelstate (int state, int *oldstate); -int __pthread_setcanceltype (int type, int *oldtype); -void __pthread_testcancel (void); /* Semaphores */ int __sem_init (sem_t * sem, int pshared, unsigned int value); -- cgit v1.2.3