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:
Diffstat (limited to 'newlib/libc/stdlib/__call_atexit.c')
-rw-r--r--newlib/libc/stdlib/__call_atexit.c13
1 files changed, 13 insertions, 0 deletions
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
+
}