diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 451e42d55..b2639ac5f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,7 +1,13 @@ +2003-02-28 Christopher Faylor + + * cygwin.din: Wrap atexit and exit with cygwin, thread-safe functions. + * dcrt0.cc (cygwin_atexit): New function. + (cygwin_exit): Ditto. + 2003-02-28 Pierre Humblet * syscalls.cc (fstat64): Pass get_name () to pc. - (access): Pass fn to stat_worker. + (access): Pass fn to stat_worker. 2003-03-27 Corinna Vinschen @@ -11,7 +17,7 @@ class sock_event. Use class object instead. (fhandler_socket::accept): Ditto. Remove useless casts. -2003-03-27 Thomas Pfaff +2003-03-27 Thomas Pfaff * fhandler_socket.cc (fhandler_socket::connect): Add support for an interruptable connect. @@ -139,8 +145,8 @@ (wincap_2000): Ditto. (wincap_xp): Ditto. * path.h (path_conv::fs_flags): New method. - * fhandler_disk_file.cc: Include winioctl.h for DeviceIoControl. - (fhandler_disk_file::open): Set newly created and truncated files as + * fhandler_disk_file.cc: Include winioctl.h for DeviceIoControl. + (fhandler_disk_file::open): Set newly created and truncated files as sparse on platforms that support it. 2003-02-17 Pierre Humblet @@ -168,7 +174,7 @@ from non-waitloop call. 2003-02-13 Vaclav Haisman - Christopher Faylor + Christopher Faylor * fhandler_console.cc (fhandler_console::write_normal): Use MessageBeep for bell sound. diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index 80b58f067..1e54f0c99 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -156,8 +156,8 @@ atanh _atanh = atanh atanhf _atanhf = atanhf -atexit -_atexit = atexit +atexit = cygwin_atexit +_atexit = cygwin_atexit atof _atof = atof atoff @@ -372,7 +372,7 @@ execve _execve = execve execvp _execvp = execvp -exit +exit = cygwin_exit exp _exp = exp exp2 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) { diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index ebb9edbdb..b02cacd51 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -304,8 +304,16 @@ dll_list::load_after_fork (HANDLE parent, dll *first) the parent had some of those. */ if (d.type == DLL_LOAD) { + bool unload = true; HMODULE h = LoadLibraryEx (d.name, NULL, DONT_RESOLVE_DLL_REFERENCES); + if (!h) + { + unload = false; + LoadLibrary (d.name); + } + if (!h) + system_printf ("can't reload %s", d.name); /* See if DLL will load in proper place. If so, free it and reload it the right way. It sort of stinks that we can't invert the order of the FreeLibrary @@ -313,10 +321,13 @@ dll_list::load_after_fork (HANDLE parent, dll *first) should do what we want. However, since the library was loaded above, the second LoadLibrary does not execute it's startup code unless it is first unloaded. */ - if (h == d.handle) + else if (h == d.handle) { - FreeLibrary (h); - LoadLibrary (d.name); + if (unload) + { + FreeLibrary (h); + LoadLibrary (d.name); + } } else if (try2) api_fatal ("unable to remap %s to same address as parent(%p) != %p", diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index a1efc596d..306f31972 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -185,12 +185,13 @@ details. */ round roundf scalbln scalblnf sincos sincosf tgamma tgammaf truncf 76: mallinfo + 77: thread-safe exit/at_exit */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 76 +#define CYGWIN_VERSION_API_MINOR 77 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible