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

* Re: converting VADS Ada 83 code to GNAT Ada 95
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Jud @ 2001-07-20 14:55 UTC (permalink / raw)


The gnatchop hint is probably the one that will save people the most
time.  It worked great.

Did you create your own packages to handle things like interrupts,
mutexes, mailboxes, and tasking calls that were used in VADS or did
you find another way to handle those (I am specifically thinking about
GNAT for NT)?

Do you know of any online sources for VADS documentation of the
libraries and the calls that I will probably have to rewrite?

I also found that the math functions can mostly be replaced with
Ada.Numerics.xxx


Paul Jud


"Terry Westley" <westley@yahoo.com> wrote in message news:<kd4%6.898$im3.333201@news.uswest.net>...
> 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.



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

* Re: converting VADS Ada 83 code to GNAT Ada 95
  2001-07-20 14:55 ` Paul Jud
@ 2001-07-21 18:29   ` Robert Dewar
  0 siblings, 0 replies; 3+ messages in thread
From: Robert Dewar @ 2001-07-21 18:29 UTC (permalink / raw)


pauljud@yahoo.com (Paul Jud) wrote in message news:<51614484.0107200655.1d7a93d3@posting.google.com>...

> The gnatchop hint is probably the one that will save people the most
> time.  It worked great.

If you found this a useful hint, let me give you another, which is
more general and even more valuable - read the documentation!

In this particular case, the user's guide has an entire chapter
whose title is

"Renaming Files Using gnatchop"

The subsections of this chapter are:

* Handling Files with Multiple Units::        
* Operating gnatchop in Compilation Mode::    
* Command Line for gnatchop::                 
* Switches for gnatchop::                     
* Examples of gnatchop Usage::                

So you will find not only this "gnatchop hint" in this section, but
a whole lot of additional useful details on dealing with this 
particular issue.



^ 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