public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
From: Christopher Faylor <cgf-use-the-mailinglist-please@cygwin.com>
To: cygwin-developers@cygwin.com
Subject: Re: MSYS mode (continue)
Date: Tue, 30 Jul 2013 14:55:00 -0000	[thread overview]
Message-ID: <20130730145533.GA3652@ednor.casa.cgf.cx> (raw)
In-Reply-To: <CABEPuQLm6StPQ2tZtBZ40W53O8=MukV=5=S_xMoqbmy8jD7cJA@mail.gmail.com>

On Tue, Jul 30, 2013 at 02:59:40PM +0400, Alexey Pavlov wrote:
>We need to determine places where you need to create hooks in
>Cygwin.dll and also prototypes for external functions (input and
>output arguments). Msys mode only change functions for non-Cygwin
>applications and in this case where it can be handled? In cygwin.dll
>or in msys.dll?

This is the outstanding question for the last month or so.

>For example, when we pass arguments to new process we determine in
>Cygwin is new process depends on cygwin.dll or not and make decision
>about changing arguments. If new process is non-cygwin then we try to
>change arguments else we leave them as is. If we need do implement
>decision logic in msys.dll then we need to rewrite many code. But if
>we implement it in Cygwin dll then it was simple like this:

No.  In the spawn function, you have something like:

  if (!callout (CO_SPAWN, mode, &argv, &argc))
    ...

And a DLL which has been preloaded and registered with cygwin1.dll will
modify the arguments as needed.

Either that or, the other proposal is that MSYS could just use LD_PRELOAD
but, as attractive as the notion of not modifying Cygwin at all might be,
it would mean that the MSYS dll would have to do a lot more work for
the above scenario because it would have to emulate a lot of what Cygwin
does to emulate exec/spawn.

So, in the interests of moving this discussion along, here is a more
fleshed out proposal:

Any helper DLL would be registered using a CYGWIN environment variable
preload keyword:

set CYGWIN=preload:msys.dll

An error will be issued if Cygwin can't find the preload dll.

The DLL will register callouts via:

cygwin_internal (CW_CALLOUT, function_which_handles_callouts);

Callout		Arguments
CO_SPAWN	mode (value), argv (reference), argc (reference)
CO_UNAME	utsname (reference)
CO_ENV		envp (reference)
CO_SYMLINK	is_native_symlink (value), oldpath (reference), newpath (reference)*
CW_MALLOC	Amount of cygheap memory to allocate

*Choosing where to call this might be tricky.  I don't see any reason
why MSYS shouldn't avail itself of the new native symlinks if they
can be created.  Otherwise, symlink would have to be short-circuited
in some cases so maybe we need to check the return value of the callout
function:

  ...
  switch (callout (CW_SYMLINK, is_native_symlink, &oldpath, &newpath))
    {
    case CO_R_KEEP_GOING:
      break;
    case CO_R_SHORT_CIRCUIT:
      return 0;
    case CO_R_ERR:
      return -1;
    }
  ...

The callout function will look something like:

enum callout_return
callout (enum callout co, ...)
{
  if (!callout_func)
    return CO_R_KEEP_GOING;
  va_list ap;
  va_start (ap, co);
  return callout_func (co, ap);
}

(I have to think about the most efficient way to implement this)

What other CO_* values are needed?

cgf

  reply	other threads:[~2013-07-30 14:55 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CABEPuQ+YxNF6LTAxRTVDQqQsKvGWGuaRxx1JAH62+wZZzgsC9w@mail.gmail.com>
     [not found] ` <CABEPuQKRz2kamtrbBF5MjxPiSRMxwJ7NhG6wRrtRXMoBm+quNg@mail.gmail.com>
     [not found]   ` <20130704091632.GM5118@calimero.vinschen.de>
     [not found]     ` <CABEPuQKb8ZFvA=5947_JNQ3xZUNi98FTkV=9Q04f8vMY-4q1pg@mail.gmail.com>
     [not found]       ` <20130704101046.GN5118@calimero.vinschen.de>
     [not found]         ` <CABEPuQJ2S5jUbJDS+XUhrvdLtu6t53QAvsmQ_q5RbvELZxHJhw@mail.gmail.com>
     [not found]           ` <20130704103708.GA12995@calimero.vinschen.de>
     [not found]             ` <CABEPuQ+iF265-SQzfLTmsBegG+BVjpLPowxRAH8ioWv1Us_iYg@mail.gmail.com>
     [not found]               ` <20130704121617.GC12995@calimero.vinschen.de>
     [not found]                 ` <20130704163612.GA4729@ednor.casa.cgf.cx>
2013-07-05  9:07                   ` Corinna Vinschen
2013-07-05 16:42                     ` Christopher Faylor
2013-07-11 11:17                       ` Corinna Vinschen
2013-07-25 11:06                         ` Alexey Pavlov
2013-07-25 11:11                           ` Corinna Vinschen
2013-07-25 13:11                         ` Charles Wilson
2013-07-25 15:02                           ` Corinna Vinschen
2013-07-25 18:21                             ` Charles Wilson
2013-07-25 18:33                               ` Charles Wilson
2013-07-25 20:53                               ` Christopher Faylor
2013-07-25 21:08                                 ` LRN
2013-07-25 21:31                                   ` Larry Hall (Cygwin Developers)
2013-07-26  1:55                                     ` Christopher Faylor
2013-07-26  4:03                                       ` LRN
2013-07-26  5:46                                         ` Christopher Faylor
2013-07-26  8:15                                 ` Corinna Vinschen
2013-07-26 15:14                                   ` Christopher Faylor
2013-07-26 15:48                                     ` LRN
2013-07-26 16:16                                       ` Corinna Vinschen
2013-07-26 16:12                                     ` Corinna Vinschen
2013-07-26 16:37                                       ` Christopher Faylor
2013-07-26 16:45                                         ` Daniel Colascione
2013-07-26 16:47                                         ` Corinna Vinschen
2013-07-26 17:01                                           ` Christopher Faylor
2013-07-26 17:03                                             ` Daniel Colascione
2013-07-26 17:36                                               ` Christopher Faylor
2013-07-26 23:12                                           ` Yaakov (Cygwin/X)
2013-07-27  3:07                                   ` Charles Wilson
2013-07-28  0:18                                     ` NightStrike
2013-07-29  9:30                                       ` Corinna Vinschen
2013-07-29 11:00                                         ` LRN
2013-07-29 11:19                                           ` Corinna Vinschen
2013-07-29 15:36                                             ` LRN
2013-07-29 15:47                                               ` Corinna Vinschen
2013-07-29 16:37                                                 ` Charles Wilson
2013-07-30  1:18                                                   ` LRN
2013-07-30  0:45                                                 ` LRN
2013-07-30  9:04                                                   ` Corinna Vinschen
2013-07-30  9:32                                                     ` Alexey Pavlov
2013-07-30  9:47                                                       ` Corinna Vinschen
2013-07-30 10:27                                                         ` Alexey Pavlov
2013-07-30 10:34                                                           ` Corinna Vinschen
2013-07-30 10:59                                                             ` Alexey Pavlov
2013-07-30 14:55                                                               ` Christopher Faylor [this message]
2013-07-30 15:43                                                                 ` Christopher Faylor
2013-07-30 16:14                                                                 ` Christopher Faylor
2013-07-29 11:19                                           ` Earnie Boyd
2013-07-29 12:20                                             ` Charles Wilson
2013-07-29 12:49                                               ` Corinna Vinschen
2013-07-29 14:22                                                 ` Charles Wilson
2013-07-29 18:11                                               ` Larry Hall (Cygwin Developers)
2013-07-29  9:25                                     ` Corinna Vinschen

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=20130730145533.GA3652@ednor.casa.cgf.cx \
    --to=cgf-use-the-mailinglist-please@cygwin.com \
    --cc=cygwin-developers@cygwin.com \
    /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).