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:
authorRobert Collins <rbtcollins@hotmail.com>2001-04-14 11:06:02 +0400
committerRobert Collins <rbtcollins@hotmail.com>2001-04-14 11:06:02 +0400
commite6b98fc8d6539f40aa34ce4964ae40305a5a52ca (patch)
tree6e50f9626b1caf2ff2c9110b68f0566a9da58b35
parenta25b8414aca039dd067de92a30eec17995deaff9 (diff)
Sat Apr 14 17:04:00 2001 Robert Collins <rbtcollins@hotmail.com>
* thread.h (MTinterface): Add threadcount. * thread.cc (MTinterface::Init): Set threadcount to 1. (__pthread_create): Increment threadcount. (__pthread_exit): Decrement threadcount and call exit() from the last thread.
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/thread.cc8
-rw-r--r--winsup/cygwin/thread.h3
3 files changed, 15 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index c90420b53..19d1e3a17 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+Sat Apr 14 17:04:00 2001 Robert Collins <rbtcollins@hotmail.com>
+
+ * thread.h (MTinterface): Add threadcount.
+ * thread.cc (MTinterface::Init): Set threadcount to 1.
+ (__pthread_create): Increment threadcount.
+ (__pthread_exit): Decrement threadcount and call exit() from the last thread.
+
Fri Apr 13 11:34:24 2001 Robert Collins <rbtcollins@hotmail.com>
* fork.cc (fork_child): Call the __pthread_atforkchild function.
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 1bcfd4e4d..e179a1bb2 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -291,6 +291,7 @@ MTinterface::Init (int forked)
}
concurrency = 0;
+ threadcount = 1; /* 1 current thread when Init occurs.*/
if (forked)
return;
@@ -664,6 +665,7 @@ __pthread_create (pthread_t * thread, const pthread_attr_t * attr,
*thread = NULL;
return EAGAIN;
}
+ InterlockedIncrement(&MT_INTERFACE->threadcount);
return 0;
}
@@ -1214,10 +1216,12 @@ __pthread_exit (void *value_ptr)
class pthread *thread = __pthread_self ();
MT_INTERFACE->destructors.IterateNull ();
-// FIXME: run the destructors of thread_key items here
thread->return_ptr = value_ptr;
- ExitThread (0);
+ if (InterlockedDecrement(&MT_INTERFACE->threadcount) == 0)
+ exit (0);
+ else
+ ExitThread (0);
}
int
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h
index 2b6e7d7e7..6065f9d9c 100644
--- a/winsup/cygwin/thread.h
+++ b/winsup/cygwin/thread.h
@@ -333,6 +333,7 @@ public:
/* we may get 0 for the Tls index.. grrr */
int indexallocated;
int concurrency;
+ long int threadcount;
// Used for main thread data, and sigproc thread
struct __reent_t reents;
@@ -346,7 +347,7 @@ public:
void Init (int);
- MTinterface ():reent_index (0), indexallocated (0)
+ MTinterface ():reent_index (0), indexallocated (0), threadcount (1)
{
pthread_prepare = NULL;
pthread_child = NULL;