diff options
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 1c30ceab2..515745c25 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -34,6 +34,7 @@ details. */ #include "cygwin_version.h" #include "dll_init.h" #include "cygthread.h" +#include "sync.h" #define MAX_AT_FILE_LEVEL 10 @@ -1064,6 +1065,28 @@ do_exit (int status) myself->exit (n); } +static muto *atexit_lock; + +extern "C" int +cygwin_atexit (void (*function)(void)) +{ + int res; + if (!atexit_lock) + new_muto (atexit_lock); + atexit_lock->acquire (); + res = atexit (function); + atexit_lock->release (); + return res; +} + +extern "C" void +cygwin_exit (int n) +{ + if (atexit_lock) + atexit_lock->acquire (); + exit (n); +} + extern "C" void _exit (int n) { |