public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: John Cerney <j-cerney1@ti.com>
To: "gnu-win32@cygnus.com" <gnu-win32@cygnus.com>,
	Sergey Okhapkin<sos@prospect.com.ru>
Subject: RE: Can't Reference Stderr from a DLL
Date: Tue, 18 Mar 1997 09:38:00 -0000	[thread overview]
Message-ID: <BMSMTP8586987008a0182636@dsbmail.itg.ti.com> (raw)
In-Reply-To: <01BC3394.D4831CB0@gater.krystalbank.msk.ru>

>
>  > main.c calls impure_setup() in the dll with main's impure_ptr as its 
>  argument
>  >        impure_setup() in init.cc takes the impure_ptr from main and 
>  copies the
>  >        value to its (the dll's) local copy of impure_ptr.
>  
>  It's not a suitable way for me :-( It requires explicit call to 
>  impure_setup() for _each_ project's dll! This will prevent easy porting (X 
>  stuff for example). If reent_data will be exported from within cygwin.dll, 
>  then it will be possible to write
> 

For my work of porting perl5.003_25 to cygwin32, this was not really a problem.
Perl uses dynamic libraries to load language extension modules. These modules
are built as DLLs and are loaded at run-time (for win32, using the
LoadLibraryEx and GetProcAddress calls) by one piece of code (dynaloader.c).
Dynaloader.c in perl is already different for each OS the language is ported
to, so it was not hard for me to add the call to impure_setup() in dynaloader.c
just after it loads the dll module.
 
>  #include <windows.h>
>  extern struct reent *_impure_ptr, *__imp_reent_data;
>  int WINAPI dll_main(HANDLE a, DWORD reason, void *q)
>  { switch (reason){
>     case DLL_PROCESS_ATTACH: break;
>     case DLL_PROCESS_DETACH: break;
>     case DLL_THREAD_ATTACH:  break;
>     case DLL_THREAD_DETACH:  break;
>    }
>    _impure_ptr = __imp_reent_data;
>    return 1;
>  }
>  
>  and link this file to every DLL. Function dll_main (declared as entry point 
>  on ld's command line) will be called automatically after loading dll, and 
>  will set up dll's _impure_ptr right without explicit call to it! Number of 
>  dll's may vary - initialisation for each dll will be done automatically.
>  

This looks like a good, clean approach, hopefully cygnus will implement
something like this.

-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

  reply	other threads:[~1997-03-18  9:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-18  9:38 Sergey Okhapkin
1997-03-18  9:38 ` John Cerney [this message]
  -- strict thread matches above, loose matches on Subject: below --
1997-03-17 14:51 Sergey Okhapkin
1997-03-17 14:51 ` John Cerney
1997-03-13  6:25 Sergey Okhapkin
1997-03-17  9:29 ` John Cerney
1997-03-12  6:22 John Cerney
1997-03-12 13:11 ` Fergus Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BMSMTP8586987008a0182636@dsbmail.itg.ti.com \
    --to=j-cerney1@ti.com \
    --cc=gnu-win32@cygnus.com \
    --cc=sos@prospect.com.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).