]> sourceware.org Git - newlib-cygwin.git/commitdiff
* libc/stdlib/__atexit.c (__atexit_lock): Define a global lock for atexit
authorChristopher Faylor <me@cgf.cx>
Thu, 4 Feb 2010 17:57:30 +0000 (17:57 +0000)
committerChristopher Faylor <me@cgf.cx>
Thu, 4 Feb 2010 17:57:30 +0000 (17:57 +0000)
functions.
(__register_exitproc): Use __atexit_lock rather than a local static lock.
* libc/stdlib/__call_atexit.c: Ditto.

newlib/ChangeLog
newlib/libc/stdlib/__atexit.c
newlib/libc/stdlib/__call_atexit.c

index 7ef714c77c8b3ab13772d89ea68c46d8fc692edd..e83fdcecd08afc99466313806c92b5d6156cf967 100644 (file)
@@ -1,3 +1,11 @@
+2010-02-01  Christopher Faylor  <me+cygwin@cgf.cx>
+
+       * libc/stdlib/__atexit.c (__atexit_lock): Define a global lock for
+       atexit functions.
+       (__register_exitproc): Use __atexit_lock rather than a local static
+       lock.
+       * libc/stdlib/__call_atexit.c: Ditto.
+
 2010-01-29  Jeff Johnston  <jjohnstn@redhat.com>
 
        * libc/search/Makefile.am: Create .def files for bsearch and qsort.
index 4f0b67c9e2e7455395809a3b11ba5eaccca94e06..b68d80f9c964f34137c30117a5459412f265c4f5 100644 (file)
@@ -10,6 +10,7 @@
 
 /* Make this a weak reference to avoid pulling in malloc.  */
 void * malloc(size_t) _ATTRIBUTE((__weak__));
+__LOCK_INIT(, __atexit_lock);
 
 /*
  * Register a function to be performed at exit or on shared library unload.
@@ -27,9 +28,7 @@ _DEFUN (__register_exitproc,
   register struct _atexit *p;
 
 #ifndef __SINGLE_THREAD__
-  __LOCK_INIT(static, lock);
-
-  __lock_acquire(lock);
+  __lock_acquire(__atexit_lock);
 #endif
 
   p = _GLOBAL_REENT->_atexit;
@@ -49,7 +48,7 @@ _DEFUN (__register_exitproc,
       if (p == NULL)
        {
 #ifndef __SINGLE_THREAD__
-         __lock_release(lock);
+         __lock_release(__atexit_lock);
 #endif
          return -1;
        }
@@ -94,7 +93,7 @@ _DEFUN (__register_exitproc,
     }
   p->_fns[p->_ind++] = fn;
 #ifndef __SINGLE_THREAD__
-  __lock_release(lock);
+  __lock_release(__atexit_lock);
 #endif
   return 0;
 }
index e7f9561848fd13aea43558e53fbabc1286b72ef4..1e2a9f5fa5b4ef73fc86cc228d28b2c09d3117a6 100644 (file)
 /* Make this a weak reference to avoid pulling in free.  */
 void free(void *) _ATTRIBUTE((__weak__));
 
+#ifndef __SINGLE_THREAD__
+extern _LOCK_T __atexit_lock;
+#endif
+
 /*
  * Call registered exit handlers.  If D is null then all handlers are called,
  * otherwise only the handlers from that DSO are called.
@@ -26,6 +30,11 @@ _DEFUN (__call_exitprocs, (code, d),
   int i;
   void (*fn) (void);
 
+
+#ifndef __SINGLE_THREAD__
+  __lock_acquire(__atexit_lock);
+#endif
+
  restart:
 
   p = _GLOBAL_REENT->_atexit;
@@ -104,4 +113,8 @@ _DEFUN (__call_exitprocs, (code, d),
        }
 #endif
     }
+#ifndef __SINGLE_THREAD__
+  __lock_release(__atexit_lock);
+#endif
+
 }
This page took 0.055852 seconds and 5 git commands to generate.