summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2000-06-08 00:55:27 +0000
committerDJ Delorie <dj@redhat.com>2000-06-08 00:55:27 +0000
commit48b8705360615755832ad520ae3b151321f17e9c (patch)
tree27948c94aa8ae060f0991fea80fbd1b45c7d915b
parent6b878fd051121334a20711107bfe662b6371d937 (diff)
downloadcygnal-48b8705360615755832ad520ae3b151321f17e9c.tar.gz
cygnal-48b8705360615755832ad520ae3b151321f17e9c.tar.bz2
cygnal-48b8705360615755832ad520ae3b151321f17e9c.zip
* cygwin.din: add cygwin_dll_init
* dcrt0.cc (cygwin_dll_init): new (dll_crt0_1): short circuit if manually loaded * path.cc (mount_info::init): don't init if manually loaded
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/cygwin.din1
-rw-r--r--winsup/cygwin/dcrt0.cc44
-rw-r--r--winsup/cygwin/path.cc3
4 files changed, 55 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 3bcab6489..e10fa0108 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+2000-06-07 DJ Delorie <dj@cygnus.com>
+
+ * cygwin.din: add cygwin_dll_init
+ * dcrt0.cc (cygwin_dll_init): new
+ (dll_crt0_1): short circuit if manually loaded
+ * path.cc (mount_info::init): don't init if manually loaded
+
Wed Jun 7 13:47:00 2000 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in_systm.h: New file.
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 4b1d22136..a8c0006db 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -125,6 +125,7 @@ _difftime = difftime
div
_div = div
dll_crt0__FP11per_process
+cygwin_dll_init
dll_dllcrt0
dll_noncygwin_dllcrt0
cygwin_detach_dll
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index c77324f9d..4b87905b2 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -724,6 +724,10 @@ dll_crt0_1 ()
/* Initialize uid, gid. */
uinfo_init ();
+ /* beyond this we only do for cygwin apps or dlls */
+ if (dynamically_loaded)
+ return;
+
/* Initialize signal/subprocess handling. */
sigproc_init ();
@@ -842,6 +846,46 @@ dll_crt0 (per_process *uptr)
dll_crt0_1 ();
}
+extern "C" void *export_malloc (unsigned int);
+extern "C" void export_free (void *);
+extern "C" void *export_realloc (void *, unsigned int);
+extern "C" void *export_calloc (unsigned int, unsigned int);
+
+/* This must be called by anyone who uses LoadLibrary to load cygwin1.dll */
+extern "C" void cygwin_dll_init ();
+void
+cygwin_dll_init ()
+{
+ static struct _reent *temp_impure;
+ static char **envp;
+ static int _fmode;
+ user_data->heapbase = user_data->heapptr = user_data->heaptop = NULL;
+
+ if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
+ GetCurrentProcess (), &hMainProc, 0, FALSE,
+ DUPLICATE_SAME_ACCESS))
+ hMainProc = GetCurrentProcess ();
+
+ DuplicateHandle (hMainProc, GetCurrentThread (), hMainProc,
+ &hMainThread, 0, FALSE, DUPLICATE_SAME_ACCESS);
+ user_data->dll_major = CYGWIN_VERSION_DLL_MAJOR;
+ user_data->dll_minor = CYGWIN_VERSION_DLL_MINOR;
+ user_data->api_major = CYGWIN_VERSION_API_MAJOR;
+ user_data->api_minor = CYGWIN_VERSION_API_MINOR;
+ user_data->magic_biscuit = sizeof (per_process);
+
+ user_data->impure_ptr_ptr = &temp_impure;
+ user_data->envptr = &envp;
+ user_data->fmode_ptr = &_fmode;
+
+ user_data->malloc = &export_malloc;
+ user_data->free = &export_free;
+ user_data->realloc = &export_realloc;
+ user_data->calloc = &export_calloc;
+
+ dll_crt0_1 ();
+}
+
extern "C" void
__main (void)
{
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index d3bc76c19..af23932da 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -854,6 +854,9 @@ mount_info::init ()
the registry. */
from_registry ();
+ if (dynamically_loaded)
+ return;
+
/* If slash isn't already mounted, mount system directory as slash. */
if (nmounts != 0)
for (int i = 0; i < nmounts; i++)