diff options
author | Christopher Faylor <me@cgf.cx> | 2003-03-01 02:02:42 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-03-01 02:02:42 +0000 |
commit | 005c3065ebdbdf897733268edce15aeb0e7e9fd6 (patch) | |
tree | bf80f7c780a6e0ddd6b3da06f4ab835cb78071d7 /winsup/cygwin/dcrt0.cc | |
parent | 27b4082ae7978779342690af5739f13486075b5f (diff) | |
download | cygnal-005c3065ebdbdf897733268edce15aeb0e7e9fd6.tar.gz cygnal-005c3065ebdbdf897733268edce15aeb0e7e9fd6.tar.bz2 cygnal-005c3065ebdbdf897733268edce15aeb0e7e9fd6.zip |
* cygwin.din: Wrap atexit and exit with cygwin, thread-safe functions.
* dcrt0.cc (cygwin_atexit): New function.
(cygwin_exit): Ditto.
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) { |