From d04cf16c52c845c683c901b2aa201445f6d9e1c4 Mon Sep 17 00:00:00 2001
From: Christopher Faylor <me@cgf.cx>
Date: Mon, 16 Sep 2002 16:09:54 +0000
Subject: [PATCH] * init.cc: Cleanup slightly and remove obsolete code.

---
 winsup/cygwin/ChangeLog  | 12 ++++++++----
 winsup/cygwin/init.cc    | 17 ++---------------
 winsup/cygwin/pthread.cc |  2 +-
 winsup/cygwin/thread.cc  | 18 +++++++++---------
 winsup/cygwin/thread.h   |  2 +-
 5 files changed, 21 insertions(+), 30 deletions(-)

diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index e7afe6214..bbbfad9cb 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,11 +1,15 @@
+2002-09-16  Christopher Faylor  <cgf@redhat.com>
+
+	* init.cc: Cleanup slightly and remove obsolete code.
+
 2002-09-11  Robert Collins  <rbtcollins@hotmail.com>
 
 	* init.cc (dll_entry): On thread detach, if the thread hasn't
 	exit()ed, do so.
-	* pthread.cc (pthread_getsequence_np): Remove the 
+	* pthread.cc (pthread_getsequence_np): Remove the
 	__pthread_getsequence_np wrapper. This requires errno.h.
-	* thread.cc (pthread::self): Instantiate a new pthread object 
-	when called and none exists. return a NULL object if instantiation 
+	* thread.cc (pthread::self): Instantiate a new pthread object
+	when called and none exists. return a NULL object if instantiation
 	fails.
 	(pthread::precreate): Factor out common code.
 	(pthread::postcreate): Ditto.
@@ -38,7 +42,7 @@
 	(__pthread_getsequence_np): Remove.
 	(__pthread_setschedparam): Apply Extract Method to the object
 	validation.
-	(pthreadNull::getNullpthread): New method, return the pthreadNull 
+	(pthreadNull::getNullpthread): New method, return the pthreadNull
 	object.
 	(pthreadNull::pthreadNull): Private constructor to prevent accidental
 	use.
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index 2e08f11f2..ca5e7176d 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -1,6 +1,6 @@
 /* init.cc
 
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -38,23 +38,10 @@ WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load)
       pthread *thisthread = (pthread *) TlsGetValue (
 			user_data->threadinterface->thread_self_dwTlsIndex);
       if (thisthread) {
-	  /* Some non-pthread call created this thread, 
+	  /* Some non-pthread call created this thread,
 	   * but we need to clean it up */
 	  thisthread->exit(0);
       }
-#if 0 // FIXME: REINSTATE SOON
-      waitq *w;
-      if ((w = waitq_storage.get ()) != NULL)
-	{
-	  if (w->thread_ev != NULL)
-	    {
-	      system_printf ("closing %p", w->thread_ev);
-	      (void) CloseHandle (w->thread_ev);
-	    }
-	  memset (w, 0, sizeof(*w));	// FIXME: memory leak
-	}
-	// FIXME: Need to add other per_thread stuff here
-#endif
       break;
     }
   return 1;
diff --git a/winsup/cygwin/pthread.cc b/winsup/cygwin/pthread.cc
index d7c8fccfd..90eb20f25 100644
--- a/winsup/cygwin/pthread.cc
+++ b/winsup/cygwin/pthread.cc
@@ -1,6 +1,6 @@
 /* pthread.cc: posix pthread interface for Cygwin
 
-   Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
    Originally written by Marco Fuykschot <marco@ddi.nl>
 
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 3d9c40b48..2e2f353a8 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -377,8 +377,8 @@ pthread::setTlsSelfPointer(pthread *thisThread)
 
 /* member methods */
 pthread::pthread ():verifyable_object (PTHREAD_MAGIC), win32_obj_id (0),
-                    cancelstate (0), canceltype (0), cancel_event(0),
-                    joiner (NULL), cleanup_stack(NULL) 
+		    cancelstate (0), canceltype (0), cancel_event(0),
+		    joiner (NULL), cleanup_stack(NULL)
 {
 }
 
@@ -434,7 +434,7 @@ pthread::precreate (pthread_attr *newattr)
 void
 pthread::create (void *(*func) (void *), pthread_attr *newattr,
 		 void *threadarg)
-{ 
+{
   precreate (newattr);
   if (!magic)
       return;
@@ -483,7 +483,7 @@ pthread::exit (void *value_ptr)
   if( __pthread_equal(&joiner, &thread ) )
     delete this;
   else
-    {  
+    {
       return_ptr = value_ptr;
       mutex.UnLock ();
     }
@@ -739,7 +739,7 @@ pthread::setcancelstate (int state, int *oldstate)
   else
     {
       if (oldstate)
-        *oldstate = cancelstate;
+	*oldstate = cancelstate;
       cancelstate = state;
     }
 
@@ -760,7 +760,7 @@ pthread::setcanceltype (int type, int *oldtype)
   else
     {
       if (oldtype)
-        *oldtype = canceltype;
+	*oldtype = canceltype;
       canceltype = type;
     }
 
@@ -774,7 +774,7 @@ pthread::push_cleanup_handler (__pthread_cleanup_handler *handler)
 {
   if (this != self ())
     // TODO: do it?
-    api_fatal ("Attempt to push a cleanup handler across threads"); 
+    api_fatal ("Attempt to push a cleanup handler across threads");
   handler->next = cleanup_stack;
   InterlockedExchangePointer( &cleanup_stack, handler );
 }
@@ -785,7 +785,7 @@ pthread::pop_cleanup_handler (int const execute)
   if (this != self ())
     // 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)
@@ -793,7 +793,7 @@ pthread::pop_cleanup_handler (int const execute)
       __pthread_cleanup_handler *handler = cleanup_stack;
 
       if (execute)
-        (*handler->function) (handler->arg);
+	(*handler->function) (handler->arg);
       cleanup_stack = handler->next;
     }
 
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h
index ce4585031..8c69886a0 100644
--- a/winsup/cygwin/thread.h
+++ b/winsup/cygwin/thread.h
@@ -318,7 +318,7 @@ private:
 
 class pthreadNull : public pthread
 {
-  public: 
+  public:
     static pthread *getNullpthread();
     ~pthreadNull();