comp.lang.ada
 help / color / mirror / Atom feed
From: gwinn@ma.ultranet.com (Joe Gwinn)
Subject: Re: Urgent question: malloc and ada...READ/NEW/FOLLOWUP
Date: 1998/04/12
Date: 1998-04-12T00:00:00+00:00	[thread overview]
Message-ID: <gwinn-1204981957370001@d13.dial-1.cmb.ma.ultra.net> (raw)
In-Reply-To: 1998Apr10.073110.1@eisner


In article <1998Apr10.073110.1@eisner>, Kilgallen@eisner.decus.org.nospam wrote:

> In article <gwinn-0904982253200001@d183.dial-5.cmb.ma.ultra.net>,
gwinn@ma.ultranet.com (Joe Gwinn) writes:
> 
> > detail.  It sounds like you are calling Ada from C; this is difficult to
> > impossible with Ada83, and better with Ada95, but is often tricky.  Ada83
> > really expected to be on top, to be the main(), and it was often easier to
> > call C from an Ada main than to call Ada from a C main.  
> 
> Those limitations regarding which language was used for the main program
> may be true for some particular Ada83 implementation with which you are
> familiar, but they are not a characteristic of the Ada83 language itself.
> One problem I have heard discussed here is "elaboration", and DEC Ada for
> VMS has always done that via the LIB$INITIALIZE mechanism of the operating
> system, without requiring the main program be written in Ada. (There was
> a bug 10 years ago when sharable images (DLLs) were used, but bugs are bugs.)
> Since LIB$INITIALIZE is an "obvious" capability of the operating system,
> presumably GNAT for VMS either does the same obvious thing with LIB$INITIALIZE
> or does something different which also works, but at any rate does not ignore
> the issue.

Even under VAX/VMS in the 1980s, it wasn't so easy to call Ada from C.  I
know because we did just that.  There was a way to declare an Ada function
as being called from non-Ada; this worked and we used it, but you lost
much of the Ada environment.  

Actually, we were implementing an object-oriented communications 
system able to handle the full bandwidth of a large intelligence radar in
Ada83 on VAX 8600s, and we used these non-Ada Ada functions as the OO
methods, using a special assembly-coded invoker to call them by address
(vice name).  To get Ada83 and VMS to run that fast on the hardware of the
day was quite the trick, requiring special kernel calls plus a
shared-memory message passing infrastructure.  DEC Ada83 didn't handle
shared memory at all well, so we did an elaborate fan-dance so she never
saw memory she didn't completely own - her eyes were covered whenever we
needed to violate the closely-held assumptions of her upbringing. Sort of
like when your mother covered your eyes so you wouldn't see something on
the TV, because she didn't want to deal with the nightmares.

Ada95 should allow one to do without such hacks, but it still isn't
totally smooth, but the multiple-language problem isn't restricted to Ada,
and never was.



> > C may well not be setting the stack and registers up to Ada's liking.  Or
> > vica versa. 
> 
> This also should be a non-problem if the operating system (like VMS) mandates
> a calling standard.  On less organized operating systems you may survive
> by buying all your compilers from the same source.  Perhaps the main
> advantage of Ada95 is that it forces compiler developers to do the right
> thing, rather than trusting them :-).

This was one clear advantage of VAX/VMS in its day, but few other vendors
did any such thing.  Under VMS, there was one common subroutine calling
convention, so calling one language from another was much easier than
normal.  

That said, we used to call all manner of languages one from another,
sometimes directly, and sometimes by means of little assembly-coded
wrappers ("bindings" in modern jargon), on all manner of computers.  Ugly,
but effective, so one didn't choose platforms just for the ability to call
one language from another.


Joe Gwinn




  reply	other threads:[~1998-04-12  0:00 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-07  0:00 Urgent question: malloc and ada Guido Tesch
1998-04-09  0:00 ` Joe Gwinn
1998-04-10  0:00   ` Robert Dewar
1998-04-12  0:00     ` Joe Gwinn
1998-04-12  0:00       ` Enumeration Types (was: Urgent question: malloc and ada) Matthew Heaney
1998-04-13  0:00         ` Mark A Biggar
1998-04-10  0:00   ` Urgent question: malloc and ada...READ/NEW/FOLLOWUP Larry Kilgallen
1998-04-12  0:00     ` Joe Gwinn [this message]
1998-04-14  0:00       ` Robert Dewar
1998-04-16  0:00         ` Joe Gwinn
1998-04-17  0:00           ` Robert Dewar
1998-04-18  0:00             ` Joe Gwinn
1998-04-18  0:00               ` Robert Dewar
1998-04-25  0:00                 ` Joe Gwinn
1998-04-26  0:00                   ` Robert Dewar
1998-04-26  0:00                     ` Jonathan Guthrie
1998-04-26  0:00                       ` Robert Dewar
1998-04-26  0:00                       ` Simon Wright
1998-04-26  0:00                         ` Larry Kilgallen
1998-04-27  0:00                           ` Stephen Leake
1998-04-30  0:00                       ` Robert I. Eachus
1998-04-30  0:00                         ` Urgent question: malloc and ada Larry Kilgallen
     [not found]                           ` <matthew_heaney-ya023680003004981723000001@news.ni.net>
1998-05-01  0:00                             ` Robert Dewar
1998-05-01  0:00                               ` Larry Kilgallen
1998-05-02  0:00                                 ` Robert Dewar
1998-05-02  0:00                                   ` Jonathan Guthrie
1998-05-03  0:00                                     ` Robert Dewar
1998-05-03  0:00                                     ` Richard Kenner
1998-05-03  0:00                                       ` Jonathan Guthrie
1998-05-03  0:00                                         ` Richard Kenner
1998-05-03  0:00                                         ` Robert Dewar
1998-05-03  0:00                                   ` Larry Kilgallen
1998-05-01  0:00                           ` Robert Dewar
1998-05-01  0:00                             ` Charles Hixson
1998-05-02  0:00                               ` Jonathan Guthrie
1998-05-02  0:00                             ` Corey Minyard
1998-05-06  0:00                             ` Robert I. Eachus
1998-05-12  0:00                               ` Craig T. Spannring
1998-05-12  0:00                                 ` Robert Dewar
1998-05-01  0:00                       ` Urgent question: malloc and ada...READ/NEW/FOLLOWUP Fergus Henderson
1998-05-01  0:00                     ` Joe Gwinn
1998-05-02  0:00                       ` Larry Kilgallen
1998-05-05  0:00                       ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox