aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-03-01 02:02:42 +0000
committerChristopher Faylor <me@cgf.cx>2003-03-01 02:02:42 +0000
commit005c3065ebdbdf897733268edce15aeb0e7e9fd6 (patch)
treebf80f7c780a6e0ddd6b3da06f4ab835cb78071d7
parent27b4082ae7978779342690af5739f13486075b5f (diff)
downloadnewlib-005c3065ebdbdf897733268edce15aeb0e7e9fd6.zip
newlib-005c3065ebdbdf897733268edce15aeb0e7e9fd6.tar.gz
newlib-005c3065ebdbdf897733268edce15aeb0e7e9fd6.tar.bz2
* cygwin.din: Wrap atexit and exit with cygwin, thread-safe functions.
* dcrt0.cc (cygwin_atexit): New function. (cygwin_exit): Ditto.
-rw-r--r--winsup/cygwin/ChangeLog16
-rw-r--r--winsup/cygwin/cygwin.din6
-rw-r--r--winsup/cygwin/dcrt0.cc23
-rw-r--r--winsup/cygwin/dll_init.cc17
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
5 files changed, 53 insertions, 12 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 451e42d..b2639ac 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,7 +1,13 @@
+2003-02-28 Christopher Faylor <cgf@redhat.com>
+
+ * 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 <pierre.humblet@ieee.org>
* 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 <corinna@vinschen.de>
@@ -11,7 +17,7 @@
class sock_event. Use class object instead.
(fhandler_socket::accept): Ditto. Remove useless casts.
-2003-03-27 Thomas Pfaff <tpfaff@gmx.net>
+2003-03-27 Thomas Pfaff <tpfaff@gmx.net>
* 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 <pierre.humblet@ieee.org>
@@ -168,7 +174,7 @@
from non-waitloop call.
2003-02-13 Vaclav Haisman <V.Haisman@sh.cvut.cz>
- Christopher Faylor <cgf@redhat.com>
+ Christopher Faylor <cgf@redhat.com>
* 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 80b58f0..1e54f0c 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 1c30cea..515745c 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 ebb9edb..b02cacd 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 a1efc59..306f319 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