comp.lang.ada
 help / color / mirror / Atom feed
* converting VADS Ada 83 code to GNAT Ada 95
@ 2001-06-29 18:57 Terry Westley
  2001-07-20 14:55 ` Paul Jud
  0 siblings, 1 reply; 3+ messages in thread
From: Terry Westley @ 2001-06-29 18:57 UTC (permalink / raw)


Since there's always an interest in this topic and I answered a question on
Team-Ada mailing list, I decided to post a copy here of our experience
converting VADS Ada 83 code to GNAT Ada 95...

Posted to the Team-Ada mailing list:

>   I have a requirement where in i have to port code from VADS Ada 83
> compiler to GNAT Ada 95 compiler. My query is, if there is any tool
> available for this work or any guideline sort of thing which helps in
> porting.

We recently completed converting ~750K SLOC of VADS Ada 83 code
to GNAT Ada 95.  I know of no tool to do the heavy lifting for
you.  Here are some tips that may prove useful.  I concur with
David Hoos that the major difficulty is in how much you used
VADS-specific features (such as passive tasking) and VADS library
calls.

First and foremost, do NOT ignore any GNAT warning messages unless
you understand the warning and choose to leave it there.  We tried
to eliminate all warning messages by correcting the code.  Trust
the compiler; it's your best tool.

We didn't have the luxury to stop all development while doing
the conversion, so we preserved VADS implementations in package
bodies along with parallel Ada95 implementations for awhile.

1) Use gnatchop to separate compilation units into separate files
   and to rename files as needed.

2) We created our own packages which mirrored the purpose of some
   of the VADS packages.  Each of these packages had two bodies,
   the VADS/Ada83 body and the GNAT/Ada95 body.  As it turns out,
   very little code was GNAT-specific since there's lots more
   predefined packages to handle things like unbounded strings,
   command line arguments, environment variables, and random numbers,
   and exception information in Ada95 than in Ada83.

3) We replaced all references to VADS Os_Files and File_Support
   with our own Unix I/O packages rather than using GNAT-specific
   packages.  POSIX may have been a better choice, but this is
   what we did.

4) Replace "pragma Optimize_Code" with "pragma Optimize."

5) Replace "System.No_Addr" with "System.Null_Address."

6) Replace "pragma Inline_Only" with "pragma Inline."

7) Replace "Natural'size" and "Positive'size" with "Integer'size."
   This is because Natural'size is 31 bits in Ada since you can fit
   a Natural in 31 bits.  The VADS implementers interpreted this
   differently and we didn't know any better.  You'll also want to
   evaluate your use of Boolean'size.

8) Change all tasks with "pragma passive" to protected records.
   Our experience is that GNAT protected records are VERY efficient.
   Better than VADS passive tasks.

9) Examine all arrays of Boolean for whether or not you need
   to use pragma Pack.

10) Access types to unconstrained types are 64 bits in GNAT.  Watch
    out for unchecked conversion of access types to System.ADDRESS.
    Compiler will warn you.  A workaround is to add a size representation
    clause: for Some_Access_Type'size use 32.

11) If your target is Solaris, you'll find that each exception handler
    setup will cost some CPU time since there's no Solaris zero-cost
    exception handling capability.  "When others" is cheaper than
    specific handlers.

This certainly isn't comprehensive, but it may help a little.

--
Terry Westley
Veridian Engineering
twestley@buffalo.veridian.com






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-07-21 18:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-29 18:57 converting VADS Ada 83 code to GNAT Ada 95 Terry Westley
2001-07-20 14:55 ` Paul Jud
2001-07-21 18:29   ` Robert Dewar

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