This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fwd: [patch, fortran, gcc] PR35063 [Regression wrt g77] I/O leaks handles/memory on Windows XP


I forgot to CC  gcc-patches in my reply to Jerry.

---------- Forwarded message ----------
From: Danny Smith <dansmister@gmail.com>
Date: Feb 10, 2008 9:57 PM
Subject: Re: [patch, fortran, gcc] PR35063 [Regression wrt g77] I/O
leaks handles/memory on Windows XP
To: Jerry DeLisle <jvdelisle@verizon.net>


On Feb 9, 2008 6:10 PM, Jerry DeLisle <jvdelisle@verizon.net> wrote:
>
> Andrew Pinski wrote:
> > On Feb 8, 2008 3:42 PM, Jerry DeLisle <jvdelisle@verizon.net> wrote:
> >> Ok to commit?  I need a gcc maintainer to approve as well.
> >
> > It might be best if you created a __gthread_mutex_destroy_function for
> > each of the gthr-* files and not do it via
> > __GTHREAD_MUTEX_DESTROY_FUNCTION .
> >
> > The reason I am saying this is because targets which single threading
> > will now fail because of the use of pthread_mutex_destroy.
> >
>
> For the short term, I suggest the following to alleviate the immediate problem
> on windows.  I have tested this on i686-pc-cygwin. Then for 4.4 we can have the
> rest of the gthr-* files fixed.
>
> My hesitation to go into the other files now is my lack of familiarity and i don
> not have access to test all the other platforms.  This fix limits the scope to
> Windows only.
>
> OK for trunk with this change?
>
> Jerry

Jerry,
 This is OK with me (as mingw32 maintainer) for 4.3.0, if RM accepts
that this is a regression For 4.4.  I agree with others that a
gthread_mutex_destroy  function should be added.  The patch to do that
for mingw32 is attached.  But I am hesitant to add a new function to
libgcc.a for mingw at this stage in development cycle.

Danny
Index: gthr-win32.h
===================================================================
--- gthr-win32.h	(revision 131857)
+++ gthr-win32.h	(working copy)
@@ -358,6 +358,7 @@
 #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION \
   __gthread_recursive_mutex_init_function
 #define __GTHREAD_RECURSIVE_MUTEX_INIT_DEFAULT {-1, 0, 0, 0}
+#define __GTHREAD_MUTEX_DESTROY_FUNCTION __gthread_mutex_destroy
 
 #if __MINGW32_MAJOR_VERSION >= 1 || \
   (__MINGW32_MAJOR_VERSION == 0 && __MINGW32_MINOR_VERSION > 2)
@@ -423,6 +424,7 @@
 extern int
   __gthr_win32_recursive_mutex_trylock (__gthread_recursive_mutex_t *);
 extern int __gthr_win32_recursive_mutex_unlock (__gthread_recursive_mutex_t *);
+extern void __gthr_win32_mutex_destroy (__gthread_mutex_t *);
 
 static inline int
 __gthread_once (__gthread_once_t *once, void (*func) (void))
@@ -463,6 +465,12 @@
   __gthr_win32_mutex_init_function (mutex);
 }
 
+static inline void
+__gthread_mutex_destroy (__gthread_mutex_t *mutex)
+{
+  __gthr_win32_mutex_destroy (mutex);
+}
+
 static inline int
 __gthread_mutex_lock (__gthread_mutex_t *mutex)
 {
@@ -615,6 +623,12 @@
   mutex->sema = CreateSemaphore (NULL, 0, 65535, NULL);
 }
 
+static inline void
+__gthread_mutex_destroy (__gthread_mutex_t *mutex)
+{
+  CloseHandle ((HANDLE) mutex->sema);
+}
+
 static inline int
 __gthread_mutex_lock (__gthread_mutex_t *mutex)
 {
Index: config/i386/gthr-win32.c
===================================================================
--- config/i386/gthr-win32.c	(revision 131857)
+++ config/i386/gthr-win32.c	(working copy)
@@ -151,6 +151,12 @@
   mutex->sema = CreateSemaphore (NULL, 0, 65535, NULL);
 }
 
+void
+__gthr_win32_mutex_destroy (__gthread_mutex_t *mutex)
+{
+  CloseHandle ((HANDLE) mutex->sema);
+}
+
 int
 __gthr_win32_mutex_lock (__gthread_mutex_t *mutex)
 {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]