This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Can the Guile library be reentrant



[I'm quoting Steven's entire message, since I think this issue is
relevant to the mailing list.]

Steven Rubin <strubin@dnai.com> writes:
> >> I am porting Guile into a large CAD system called Electric (which will soon
> >> be a GNU offering).  The problem I am having is that Guile wants control (I
> >> call "gh_enter" and it never returns).  This is unacceptable for the
> >> structure of my program, which is message-based, and expects to return to
> >> the operating system for interrupt-based control.
> >
> >I don't, offhand, see any reason this is incompatible with gh_enter.
> >Guile has interfaces to Tk and GTK, which are both event-driven.
> >Can you explain the problem in more detail?
> 
> The problem comes up when porting to that obscure operating system:
> Windows.  Windows (at least under the MFC package) requires the main
> program to *RETURN* to the operating system, and not sit in an event loop.
> All interaction then occurs with messages that are sent to the application.
> I know that Tk cannot be run under MFC on Windows (it can run as a non-MFC
> application).  I suspect that GTK is the same.

Okay.  So in other words, you have no control over the `main'
function: Windows calls your initialization function, which must
return before the world begins to operate.  Is that what you mean?


> I know that it is somewhat of an anathema to mention Windows to LINUX
> folks, but this system of mine has existed for 15 years and been ported to
> nearly every machine that has existed in that time (Apollo, VAX, etc.)  It
> currently runs on UNIX, Macintosh, and Windows (which about covers it,
> these days).

Well, this isn't necessarily a group of Linux folks.  I'm running
Ultrix and Solaris at the moment.  :(  I haven't seen anyone be rude
about that issue on this list, which is great.

> By the way, Mark Galassi tells me this:
> 
> >Also, the recent glibc versions should have a call that returns the
> >top of the stack.  This allows for a gh_init() call to be implemented, 
> >since the whole reason for the gh_enter() mechanism was to have a
> >reliable top of the stack for garbage collection purposes.
> 
> Do you know anything about this?  Thanks.

Yeah.  This solves the problem on Linux, but nowhere else.  Every
system probably provides some way to find the bottom of the stack, but
it'll be different from every other system.

Guile could provide another initialization function that accepts the
address of the base of the stack as an argument, but I really don't
trust people to use that reliably.

Probably the best approach is to continue to provide gh_enter-style
initialization, and then provide another function which uses whatever
system-specific tactics it can scrounge together, and prints an error
message if it can't figure out your system.  That way, we can
gradually acquire expertise, while still ensuring that Guile operates
reliably.