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:
authorChristopher Faylor <me@cgf.cx>2010-02-04 20:57:30 +0300
committerChristopher Faylor <me@cgf.cx>2010-02-04 20:57:30 +0300
commitfa40bd922ee199af9b2d70389f80ce0e3b67d3d4 (patch)
tree43950d0899e38d5f0a37447b99cb1699432cef67 /newlib/libc/stdlib
parentaec8c3d5104e9b808276bb68d7f35396780b091b (diff)
* 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.
Diffstat (limited to 'newlib/libc/stdlib')
-rw-r--r--newlib/libc/stdlib/__atexit.c9
-rw-r--r--newlib/libc/stdlib/__call_atexit.c13
2 files changed, 17 insertions, 5 deletions
diff --git a/newlib/libc/stdlib/__atexit.c b/newlib/libc/stdlib/__atexit.c
index 4f0b67c9e..b68d80f9c 100644
--- a/newlib/libc/stdlib/__atexit.c
+++ b/newlib/libc/stdlib/__atexit.c
@@ -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;
}
diff --git a/newlib/libc/stdlib/__call_atexit.c b/newlib/libc/stdlib/__call_atexit.c
index e7f956184..1e2a9f5fa 100644
--- a/newlib/libc/stdlib/__call_atexit.c
+++ b/newlib/libc/stdlib/__call_atexit.c
@@ -10,6 +10,10 @@
/* 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
+
}