Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConrad Scott <conrad.scott@dsl.pipex.com>2002-07-05 00:09:50 +0400
committerConrad Scott <conrad.scott@dsl.pipex.com>2002-07-05 00:09:50 +0400
commitd5ff70186fffda2f4200cb93b8fddbc1fa42f5ac (patch)
tree2c5f66f08c23feeec2c318758b38d052cbb8540f /winsup/cygwin
parenta515b72d9dfa276433cd95f676ca283c94dd2cbc (diff)
Merged changes from HEAD
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog27
-rw-r--r--winsup/cygwin/dtable.cc2
-rw-r--r--winsup/cygwin/fhandler.cc2
-rw-r--r--winsup/cygwin/fhandler_socket.cc6
-rw-r--r--winsup/cygwin/include/cygwin/version.h2
-rw-r--r--winsup/cygwin/include/pthread.h2
-rw-r--r--winsup/cygwin/path.cc1
-rw-r--r--winsup/cygwin/pthread.cc10
-rw-r--r--winsup/cygwin/thread.cc588
-rw-r--r--winsup/cygwin/thread.h23
10 files changed, 376 insertions, 287 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index ac1bc6116..c073b409d 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,30 @@
+2002-07-04 Corinna Vinschen <corinna@vinschen.de>
+
+ * fhandler_socket.cc (fhandler_socket::set_sun_path): Don't free
+ memory here. Allow NULL parameter.
+
+2002-07-04 Corinna Vinschen <corinna@vinschen.de>
+
+ * fhandler_socket.cc (fhandler_socket::dup): Add missing copy operation
+ on sun_path.
+
+2002-07-03 Christopher Faylor <cgf@redhat.com>
+
+ * include/cygwin/version.h: Bump DLL minor number.
+
+2002-07-03 Christopher Faylor <cgf@redhat.com>
+
+ * include/sys/statfs.h: New header file.
+
+2002-07-03 Christopher Faylor <cgf@redhat.com>
+
+ * dtable.cc (cygwin_attach_handle_to_fd): Default to implicit bin mode
+ if none specified.
+ * fhandler.cc (fhandler_base::init): Make bin argument a guarantee
+ rather than a suggestion.
+ * path.cc (path_conv::check): Load flag returned from
+ cygwin_conv_to_win32_path into path_flags.
+
2002-07-03 Conrad Scott <conrad.scott@dsl.pipex.com>
* tty.cc (tty::common_init): Reverse logic of cygserver check in
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index bb9db8a4a..4e8c6f792 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -206,7 +206,7 @@ cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin,
path_conv pc;
fhandler_base *res = cygheap->fdtab.build_fhandler_from_name (fd, name, handle,
pc);
- res->init (handle, myaccess, bin);
+ res->init (handle, myaccess, bin ?: pc.binmode ());
return fd;
}
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 1b8d4583e..96da497a0 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -866,7 +866,7 @@ fhandler_base::init (HANDLE f, DWORD a, mode_t bin)
flags = O_WRONLY;
else if (a == (GENERIC_READ | GENERIC_WRITE))
flags = O_RDWR;
- set_flags (flags, bin);
+ set_flags (flags | bin);
set_open_status ();
debug_printf ("created new fhandler_base for handle %p, bin %d", f, get_r_binary ());
}
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index ffae6b1b8..7970e4b63 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -286,6 +286,8 @@ fhandler_socket::dup (fhandler_base *child)
fhandler_socket *fhs = (fhandler_socket *) child;
fhs->addr_family = addr_family;
fhs->set_io_handle (get_io_handle ());
+ if (get_addr_family () == AF_LOCAL)
+ fhs->set_sun_path (get_sun_path ());
fhs->fixup_before_fork_exec (GetCurrentProcessId ());
if (winsock2_active)
@@ -1139,7 +1141,5 @@ fhandler_socket::set_close_on_exec (int val)
void
fhandler_socket::set_sun_path (const char *path)
{
- if (sun_path)
- cfree (sun_path);
- sun_path = cstrdup (path);
+ sun_path = path ? cstrdup (path) : NULL;
}
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 5b9cf44d6..58bed4321 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -44,7 +44,7 @@ details. */
/* The current cygwin version is 1.3.6 */
#define CYGWIN_VERSION_DLL_MAJOR 1003
-#define CYGWIN_VERSION_DLL_MINOR 12
+#define CYGWIN_VERSION_DLL_MINOR 13
/* Major numbers before CYGWIN_VERSION_DLL_EPOCH are
incompatible. */
diff --git a/winsup/cygwin/include/pthread.h b/winsup/cygwin/include/pthread.h
index acdde4fc3..96aa4deea 100644
--- a/winsup/cygwin/include/pthread.h
+++ b/winsup/cygwin/include/pthread.h
@@ -42,7 +42,7 @@ extern "C"
#define PTHREAD_CANCEL_ENABLE 0
#define PTHREAD_CANCEL_DEFERRED 0
#define PTHREAD_CANCEL_DISABLE 1
-#define PTHREAD_CANCELED
+#define PTHREAD_CANCELED ((void *)-1)
/* this should be a value that can never be a valid address */
#define PTHREAD_COND_INITIALIZER (void *)21
#define PTHREAD_CREATE_DETACHED 1
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 2e8626b2d..ed76f941e 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -549,6 +549,7 @@ path_conv::check (const char *src, unsigned opt,
else if (devn != FH_BAD)
{
fileattr = 0;
+ path_flags = sym.pflags;
if (component)
{
error = ENOTDIR;
diff --git a/winsup/cygwin/pthread.cc b/winsup/cygwin/pthread.cc
index ab7fd1fbe..0484f0412 100644
--- a/winsup/cygwin/pthread.cc
+++ b/winsup/cygwin/pthread.cc
@@ -140,7 +140,7 @@ pthread_attr_getstackaddr (const pthread_attr_t * attr, void **stackaddr)
void
pthread_exit (void *value_ptr)
{
- return __pthread_exit (value_ptr);
+ return pthread::self()->exit (value_ptr);
}
int
@@ -428,25 +428,25 @@ pthread_cancel (pthread_t thread)
int
pthread_setcancelstate (int state, int *oldstate)
{
- return __pthread_setcancelstate (state, oldstate);
+ return pthread::self()->setcancelstate (state, oldstate);
}
int
pthread_setcanceltype (int type, int *oldtype)
{
- return __pthread_setcanceltype (type, oldtype);
+ return pthread::self()->setcanceltype (type, oldtype);
}
void
pthread_testcancel (void)
{
- __pthread_testcancel ();
+ pthread::self()->testcancel ();
}
void
_pthread_cleanup_push (__pthread_cleanup_handler *handler)
{
- pthread::self()->push_cleanup_handler(handler);
+ pthread::self()->push_cleanup_handler (handler);
}
void
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 39fad36b4..618fa7a9d 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -355,7 +355,8 @@ pthread::self ()
/* member methods */
pthread::pthread ():verifyable_object (PTHREAD_MAGIC), win32_obj_id (0),
- cancelstate (0), canceltype (0), joiner (NULL), cleanup_stack(NULL)
+ cancelstate (0), canceltype (0), cancel_event(0),
+ joiner (NULL), cleanup_stack(NULL)
{
}
@@ -363,6 +364,8 @@ pthread::~pthread ()
{
if (win32_obj_id)
CloseHandle (win32_obj_id);
+ if (cancel_event)
+ CloseHandle (cancel_event);
}
@@ -394,6 +397,15 @@ pthread::create (void *(*func) (void *), pthread_attr *newattr,
return;
}
+ cancel_event = ::CreateEvent (NULL,TRUE,FALSE,NULL);
+ if (!cancel_event)
+ {
+ system_printf ("couldn't create cancel event, this %p LastError %d", this, GetLastError () );
+ /*we need the event for correct behaviour */
+ magic = 0;
+ return;
+ }
+
win32_obj_id = ::CreateThread (&sec_none_nih, attr.stacksize,
(LPTHREAD_START_ROUTINE) thread_init_wrapper,
this, CREATE_SUSPENDED, &thread_id);
@@ -417,6 +429,304 @@ pthread::create (void *(*func) (void *), pthread_attr *newattr,
}
void
+pthread::exit (void *value_ptr)
+{
+ class pthread *thread = this;
+
+ // run cleanup handlers
+ pop_all_cleanup_handlers ();
+
+ MT_INTERFACE->destructors.IterateNull ();
+
+ mutex.Lock ();
+ // cleanup if thread is in detached state and not joined
+ if( __pthread_equal(&joiner, &thread ) )
+ delete this;
+ else
+ {
+ return_ptr = value_ptr;
+ mutex.UnLock ();
+ }
+
+ if (InterlockedDecrement (&MT_INTERFACE->threadcount) == 0)
+ ::exit (0);
+ else
+ ExitThread (0);
+}
+
+int
+pthread::cancel (void)
+{
+ class pthread *thread = this;
+ class pthread *self = pthread::self ();
+
+ mutex.Lock ();
+
+ if (canceltype == PTHREAD_CANCEL_DEFERRED ||
+ cancelstate == PTHREAD_CANCEL_DISABLE)
+ {
+ // cancel deferred
+ mutex.UnLock ();
+ SetEvent (cancel_event);
+ return 0;
+ }
+
+ else if (__pthread_equal(&thread, &self))
+ {
+ mutex.UnLock ();
+ cancel_self ();
+ return 0; // Never reached
+ }
+
+ // cancel asynchronous
+ SuspendThread (win32_obj_id);
+ if (WaitForSingleObject (win32_obj_id, 0) == WAIT_TIMEOUT)
+ {
+ CONTEXT context;
+ context.ContextFlags = CONTEXT_CONTROL;
+ GetThreadContext (win32_obj_id, &context);
+ context.Eip = (DWORD) pthread::static_cancel_self;
+ SetThreadContext (win32_obj_id, &context);
+ }
+ mutex.UnLock ();
+ ResumeThread (win32_obj_id);
+
+ return 0;
+/*
+ TODO: insert pthread_testcancel into the required functions
+ the required function list is: *indicates done, X indicates not present in cygwin.
+aio_suspend ()
+*close ()
+*creat ()
+fcntl ()
+fsync ()
+getmsg ()
+getpmsg ()
+lockf ()
+mq_receive ()
+mq_send ()
+msgrcv ()
+msgsnd ()
+msync ()
+nanosleep ()
+open ()
+pause ()
+poll ()
+pread ()
+pthread_cond_timedwait ()
+pthread_cond_wait ()
+*pthread_join ()
+pthread_testcancel ()
+putmsg ()
+putpmsg ()
+pwrite ()
+read ()
+readv ()
+select ()
+sem_wait ()
+sigpause ()
+sigsuspend ()
+sigtimedwait ()
+sigwait ()
+sigwaitinfo ()
+*sleep ()
+system ()
+tcdrain ()
+*usleep ()
+wait ()
+wait3()
+waitid ()
+waitpid ()
+write ()
+writev ()
+
+the optional list is:
+catclose ()
+catgets ()
+catopen ()
+closedir ()
+closelog ()
+ctermid ()
+dbm_close ()
+dbm_delete ()
+dbm_fetch ()
+dbm_nextkey ()
+dbm_open ()
+dbm_store ()
+dlclose ()
+dlopen ()
+endgrent ()
+endpwent ()
+endutxent ()
+fclose ()
+fcntl ()
+fflush ()
+fgetc ()
+fgetpos ()
+fgets ()
+fgetwc ()
+fgetws ()
+fopen ()
+fprintf ()
+fputc ()
+fputs ()
+fputwc ()
+fputws ()
+fread ()
+freopen ()
+fscanf ()
+fseek ()
+fseeko ()
+fsetpos ()
+ftell ()
+ftello ()
+ftw ()
+fwprintf ()
+fwrite ()
+fwscanf ()
+getc ()
+getc_unlocked ()
+getchar ()
+getchar_unlocked ()
+getcwd ()
+getdate ()
+getgrent ()
+getgrgid ()
+getgrgid_r ()
+getgrnam ()
+getgrnam_r ()
+getlogin ()
+getlogin_r ()
+getpwent ()
+*getpwnam ()
+*getpwnam_r ()
+*getpwuid ()
+*getpwuid_r ()
+gets ()
+getutxent ()
+getutxid ()
+getutxline ()
+getw ()
+getwc ()
+getwchar ()
+getwd ()
+glob ()
+iconv_close ()
+iconv_open ()
+ioctl ()
+lseek ()
+mkstemp ()
+nftw ()
+opendir ()
+openlog ()
+pclose ()
+perror ()
+popen ()
+printf ()
+putc ()
+putc_unlocked ()
+putchar ()
+putchar_unlocked ()
+puts ()
+pututxline ()
+putw ()
+putwc ()
+putwchar ()
+readdir ()
+readdir_r ()
+remove ()
+rename ()
+rewind ()
+rewinddir ()
+scanf ()
+seekdir ()
+semop ()
+setgrent ()
+setpwent ()
+setutxent ()
+strerror ()
+syslog ()
+tmpfile ()
+tmpnam ()
+ttyname ()
+ttyname_r ()
+ungetc ()
+ungetwc ()
+unlink ()
+vfprintf ()
+vfwprintf ()
+vprintf ()
+vwprintf ()
+wprintf ()
+wscanf ()
+
+Note, that for fcntl (), for any value of the cmd argument.
+
+And we must not introduce cancellation points anywhere else that's part of the posix or
+opengroup specs.
+ */
+}
+
+void
+pthread::testcancel (void)
+{
+ if (cancelstate == PTHREAD_CANCEL_DISABLE)
+ return;
+
+ if( WAIT_OBJECT_0 == WaitForSingleObject (cancel_event, 0 ) )
+ cancel_self ();
+}
+
+void
+pthread::static_cancel_self (void)
+{
+ pthread::self()->cancel_self ();
+}
+
+
+int
+pthread::setcancelstate (int state, int *oldstate)
+{
+ int result = 0;
+
+ mutex.Lock ();
+
+ if (state != PTHREAD_CANCEL_ENABLE && state != PTHREAD_CANCEL_DISABLE)
+ result = EINVAL;
+ else
+ {
+ if (oldstate)
+ *oldstate = cancelstate;
+ cancelstate = state;
+ }
+
+ mutex.UnLock ();
+
+ return result;
+}
+
+int
+pthread::setcanceltype (int type, int *oldtype)
+{
+ int result = 0;
+
+ mutex.Lock ();
+
+ if (type != PTHREAD_CANCEL_DEFERRED && type != PTHREAD_CANCEL_ASYNCHRONOUS)
+ result = EINVAL;
+ else
+ {
+ if (oldtype)
+ *oldtype = canceltype;
+ canceltype = type;
+ }
+
+ mutex.UnLock ();
+
+ return result;
+}
+
+void
pthread::push_cleanup_handler (__pthread_cleanup_handler *handler)
{
if (this != self ())
@@ -433,6 +743,8 @@ pthread::pop_cleanup_handler (int const execute)
// TODO: send a signal or something to the thread ?
api_fatal ("Attempt to execute a cleanup handler across threads");
+ mutex.Lock ();
+
if (cleanup_stack != NULL)
{
__pthread_cleanup_handler *handler = cleanup_stack;
@@ -441,6 +753,8 @@ pthread::pop_cleanup_handler (int const execute)
(*handler->function) (handler->arg);
cleanup_stack = handler->next;
}
+
+ mutex.UnLock ();
}
void
@@ -967,11 +1281,11 @@ pthread::thread_init_wrapper (void *_arg)
/*the OS doesn't check this for <= 64 Tls entries (pre win2k) */
TlsSetValue (MT_INTERFACE->thread_self_dwTlsIndex, thread);
- thread->mutex.Lock();
+ thread->mutex.Lock ();
// if thread is detached force cleanup on exit
if (thread->attr.joinable == PTHREAD_CREATE_DETACHED && thread->joiner == NULL)
thread->joiner = pthread::self ();
- thread->mutex.UnLock();
+ thread->mutex.UnLock ();
#ifdef _CYG_THREAD_FAILSAFE
if (_REENT == _impure_ptr)
@@ -984,7 +1298,7 @@ pthread::thread_init_wrapper (void *_arg)
// call the user's thread
void *ret = thread->function (thread->arg);
- __pthread_exit (ret);
+ thread->exit (ret);
#if 0
// ??? This code only runs if the thread exits by returning.
@@ -1038,251 +1352,13 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
return 0;
}
-/*Cancelability states */
-
-
-/*Perform the actual cancel */
-void
-__pthread_cleanup (pthread_t thread)
-{
-}
-
-
int
__pthread_cancel (pthread_t thread)
{
if (verifyable_object_isvalid (&thread, PTHREAD_MAGIC) != VALID_OBJECT)
return ESRCH;
- if (thread->cancelstate == PTHREAD_CANCEL_ENABLE)
- {
-#if 0
- /*once all the functions call testcancel (), we will do this */
- if (thread->canceltype == PTHREAD_CANCEL_DEFERRED)
- {
- }
- else
- {
- /*possible FIXME: this function is meant to return asynchronously
- *from the cancellation routine actually firing. So we may need some sort
- *of signal to be sent that is immediately recieved and acted on.
- */
- __pthread_cleanup (thread);
- }
-#endif
- }
-/* return 0;
-*/
-
- return ESRCH;
-/*
- we return ESRCH until all the required functions call testcancel ();
- this will give applications predictable behaviour.
-
- the required function list is: *indicates done, X indicates not present in cygwin.
-aio_suspend ()
-*close ()
-*creat ()
-fcntl ()
-fsync ()
-getmsg ()
-getpmsg ()
-lockf ()
-mq_receive ()
-mq_send ()
-msgrcv ()
-msgsnd ()
-msync ()
-nanosleep ()
-open ()
-pause ()
-poll ()
-pread ()
-pthread_cond_timedwait ()
-pthread_cond_wait ()
-*pthread_join ()
-pthread_testcancel ()
-putmsg ()
-putpmsg ()
-pwrite ()
-read ()
-readv ()
-select ()
-sem_wait ()
-sigpause ()
-sigsuspend ()
-sigtimedwait ()
-sigwait ()
-sigwaitinfo ()
-*sleep ()
-system ()
-tcdrain ()
-*usleep ()
-wait ()
-wait3()
-waitid ()
-waitpid ()
-write ()
-writev ()
-
-the optional list is:
-catclose ()
-catgets ()
-catopen ()
-closedir ()
-closelog ()
-ctermid ()
-dbm_close ()
-dbm_delete ()
-dbm_fetch ()
-dbm_nextkey ()
-dbm_open ()
-dbm_store ()
-dlclose ()
-dlopen ()
-endgrent ()
-endpwent ()
-endutxent ()
-fclose ()
-fcntl ()
-fflush ()
-fgetc ()
-fgetpos ()
-fgets ()
-fgetwc ()
-fgetws ()
-fopen ()
-fprintf ()
-fputc ()
-fputs ()
-fputwc ()
-fputws ()
-fread ()
-freopen ()
-fscanf ()
-fseek ()
-fseeko ()
-fsetpos ()
-ftell ()
-ftello ()
-ftw ()
-fwprintf ()
-fwrite ()
-fwscanf ()
-getc ()
-getc_unlocked ()
-getchar ()
-getchar_unlocked ()
-getcwd ()
-getdate ()
-getgrent ()
-getgrgid ()
-getgrgid_r ()
-getgrnam ()
-getgrnam_r ()
-getlogin ()
-getlogin_r ()
-getpwent ()
-*getpwnam ()
-*getpwnam_r ()
-*getpwuid ()
-*getpwuid_r ()
-gets ()
-getutxent ()
-getutxid ()
-getutxline ()
-getw ()
-getwc ()
-getwchar ()
-getwd ()
-glob ()
-iconv_close ()
-iconv_open ()
-ioctl ()
-lseek ()
-mkstemp ()
-nftw ()
-opendir ()
-openlog ()
-pclose ()
-perror ()
-popen ()
-printf ()
-putc ()
-putc_unlocked ()
-putchar ()
-putchar_unlocked ()
-puts ()
-pututxline ()
-putw ()
-putwc ()
-putwchar ()
-readdir ()
-readdir_r ()
-remove ()
-rename ()
-rewind ()
-rewinddir ()
-scanf ()
-seekdir ()
-semop ()
-setgrent ()
-setpwent ()
-setutxent ()
-strerror ()
-syslog ()
-tmpfile ()
-tmpnam ()
-ttyname ()
-ttyname_r ()
-ungetc ()
-ungetwc ()
-unlink ()
-vfprintf ()
-vfwprintf ()
-vprintf ()
-vwprintf ()
-wprintf ()
-wscanf ()
-
-Note, that for fcntl (), for any value of the cmd argument.
-And we must not introduce cancellation points anywhere else that's part of the posix or
-opengroup specs.
- */
-}
-
-/*no races in these three functions: they are all current-thread-only */
-int
-__pthread_setcancelstate (int state, int *oldstate)
-{
- class pthread *thread = pthread::self ();
- if (state != PTHREAD_CANCEL_ENABLE && state != PTHREAD_CANCEL_DISABLE)
- return EINVAL;
- *oldstate = thread->cancelstate;
- thread->cancelstate = state;
- return 0;
-}
-
-int
-__pthread_setcanceltype (int type, int *oldtype)
-{
- class pthread *thread = pthread::self ();
- if (type != PTHREAD_CANCEL_DEFERRED && type != PTHREAD_CANCEL_ASYNCHRONOUS)
- return EINVAL;
- *oldtype = thread->canceltype;
- thread->canceltype = type;
- return 0;
-}
-
-/*deferred cancellation request handler */
-void
-__pthread_testcancel (void)
-{
- class pthread *thread = pthread::self ();
- if (thread->cancelstate == PTHREAD_CANCEL_DISABLE)
- return;
- /*check the cancellation event object here - not neededuntil pthread_cancel actually
- *does something*/
+ return thread->cancel ();
}
/*
@@ -1556,32 +1632,6 @@ __pthread_attr_destroy (pthread_attr_t *attr)
return 0;
}
-void
-__pthread_exit (void *value_ptr)
-{
- pthread * thread = pthread::self ();
-
- // run cleanup handlers
- thread->pop_all_cleanup_handlers ();
-
- MT_INTERFACE->destructors.IterateNull ();
-
- thread->mutex.Lock();
- // cleanup if thread is in detached state and not joined
- if( __pthread_equal(&thread->joiner, &thread ) )
- delete thread;
- else
- {
- thread->return_ptr = value_ptr;
- thread->mutex.UnLock();
- }
-
- if (InterlockedDecrement (&MT_INTERFACE->threadcount) == 0)
- exit (0);
- else
- ExitThread (0);
-}
-
int
__pthread_join (pthread_t *thread, void **return_val)
{
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);