comp.lang.ada
 help / color / mirror / Atom feed
* Ada portability and conditional compilation
@ 1989-12-16  2:25 Daniel Lee
  1989-12-16 18:07 ` William Thomas Wolfe, 2847 
  1989-12-16 20:03 ` portability problems William Thomas Wolfe, 2847 
  0 siblings, 2 replies; 16+ messages in thread
From: Daniel Lee @ 1989-12-16  2:25 UTC (permalink / raw)


In a previous message, I described how we are using cpp to preprocess Ada source files
with C macros (#if, #endif, etc.) embedded.  The problem is that although Ada is
designed for portability, it is not portable enough.  In this message, I would like to
point out which Ada features are not portable and thus subject to conditional compilation.

1. binding

If you have experiences in developing an Ada binding, you would probably know how hard
it is to write portable binding code for multiple compilers running on multiple 
platforms.

  i.   Pragmas for importing and exporting subprograms are not portable.
  ii.  Parameter passing mechansim both for Ada call-in and Ada call-back is not 
       standardized.
  iii. Because of ii, a mechanism for string conversion between Ada and another 
       language (e.g. C) is not portable.

2. math library

Most Ada compilers come with a math library.  They are usually very similar,
but slightly different because there exists no standard for it.

3. operating system escape

We implemented a function MY_SYSTEM that calls out to the O/S.
For example,

  function MY_SYSTEM (ARG : STRING) return BOOLEAN;

  STATUS : BOOLEAN;
  STATUS := MY_SYSTEM("ls -l");

Obviously, implementation of this function cannot be portable.

4. pragmas

The pragma syntax in general is not standardized by LRM.

5. STANDARD.INTEGER, STANDARD.FLOAT, etc.

LRM does not enforce any standard for INTEGER, FLOAT,
LONG_INTEGER, LONG_FLOAT, SMALL_INTEGER, SMALL_FLOAT, etc.
Our tool supports 32-bit integers and 64-bit floats internally.
We define INTEGER_TYPE and FLOAT_TYPE as subtypes
of whatever a compiler define as such.

#if VERDIX
   subtype INTERNAL_FLOAT_TYPE is FLOAT;  
#endif
#if ALSYS || VMS
   subtype INTERNAL_FLOAT_TYPE is LONG_FLOAT;  
#endif
#if VERDIX || VMS
   subtype INTERNAL_INTEGER_TYPE is INTEGER;
#endif
#if ALSYS
   subtype INTERNAL_INTEGER_TYPE is LONG_INTEGER;
#endif

6. rep spec.

  As Bill Wolfe pointed out, the rep spec boundary alignment problem 
  can be solved by defining a global varable as follows:
  
#if VERDIX | VMS
   WORD : constant := 4;   -- number of storage units per 32-bit word
#endif

#if ?  -- we have not encountered this yet
   WORD : constant := 2;   -- number of storage units per 32-bit word
#endif

   for DATA use
   record
      FOO	at 0*WORD range 0..15;
      BAR 	at 0*WORD range 16..31;
      FEE 	at 1*WORD range 0..15
      BEE 	at 1*WORD range 16..31;
   end record;

  Another problem with rep spec is that bit-level rep spec does not
  work on some compilers (e.g. Verdix 5.5t on a Sun 3).  Therefore,
  you have to maintain at least two versions, one with no rep spec
  and one without it.

				Daniel Lee
				Inference Corporation
				lee@inference.com or sdl@inference.com

^ permalink raw reply	[flat|nested] 16+ messages in thread
* ada portability
@ 1990-11-14 14:09 Claus Franzkowiak
  1990-11-15 14:10 ` ryer
  0 siblings, 1 reply; 16+ messages in thread
From: Claus Franzkowiak @ 1990-11-14 14:09 UTC (permalink / raw)



   How much portability can I expect from an Ada program, given two different 
computers with two different operating systems and two different compiler 
vendors.  Exclude real-time programming from this assumption.  I am using
validated compilers only.

claus franzkowiak
cfranz@wrdis01.af.mil
cfranz@wrdis01.arpa
-- 

^ permalink raw reply	[flat|nested] 16+ messages in thread
* ada portability
@ 1990-11-14 14:16 Claus Franzkowiak
  1990-11-17  4:09 ` Ted Holden
  0 siblings, 1 reply; 16+ messages in thread
From: Claus Franzkowiak @ 1990-11-14 14:16 UTC (permalink / raw)



   How much portability can I expect from an Ada program, given two different 
computers with two different operating systems and two different compiler 
vendors.  Exclude real-time programming from this assumption.  I am using
validated compilers only.

claus franzkowiak
cfranz@wrdis01.af.mil
cfranz@wrdis01.arpa
-- 

^ permalink raw reply	[flat|nested] 16+ messages in thread
* ada portability
@ 1990-11-14 14:19 Claus Franzkowiak
  0 siblings, 0 replies; 16+ messages in thread
From: Claus Franzkowiak @ 1990-11-14 14:19 UTC (permalink / raw)



   How much portability can I expect from an Ada program, given two different 
computers with two different operating systems and two different compiler 
vendors.  Exclude real-time programming from this assumption.  I am using
validated compilers only.

claus franzkowiak
cfranz@wrdis01.af.mil
cfranz@wrdis01.arpa
-- 

^ permalink raw reply	[flat|nested] 16+ messages in thread
* ada portability
@ 1990-11-14 14:27 Claus Franzkowiak
  0 siblings, 0 replies; 16+ messages in thread
From: Claus Franzkowiak @ 1990-11-14 14:27 UTC (permalink / raw)



   How much portability can I expect from an Ada program, given two different 
computers with two different operating systems and two different compiler 
vendors.  Exclude real-time programming from this assumption.  I am using
validated compilers only.

claus franzkowiak
cfranz@wrdis01.af.mil
cfranz@wrdis01.arpa
-- 

^ permalink raw reply	[flat|nested] 16+ messages in thread
* ada portability
@ 1990-11-14 14:47 Claus Franzkowiak
  0 siblings, 0 replies; 16+ messages in thread
From: Claus Franzkowiak @ 1990-11-14 14:47 UTC (permalink / raw)



   How much portability can I expect from an Ada program, given two different 
computers with two different operating systems and two different compiler 
vendors.  Exclude real-time programming from this assumption.  I am using
validated compilers only.

claus franzkowiak
cfranz@wrdis01.af.mil
cfranz@wrdis01.arpa
-- 

^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: Ada portability
@ 1990-11-14 17:04 David Emery
  0 siblings, 0 replies; 16+ messages in thread
From: David Emery @ 1990-11-14 17:04 UTC (permalink / raw)


The answer to your question is indeterminate.  It is very possible to
write completely non-portable Ada, and it is possible to write code
that ports simply via recompilation.  Nissen & Wallis Ada Style Guide
(Cambridge University Press, earlier version published in Ada Letters
vol I, #3, Mar/Apr 1982) shows how to achieve portable code.  

But, you'll never fit SDI onto an IBM PC, no matter how well it's
written.  Most of the real portability problems are design problems,
not coding problems.  See Karl Nyberg and my paper in Ada-Europe 1989
(also Cambridge University Press), "Observations on Portable Ada
Systems".

				dave emery
				emery@aries.mitre.org

^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: Ada Portability
@ 1990-11-15 17:26 Ed Knoll @(719)593-3762
  0 siblings, 0 replies; 16+ messages in thread
From: Ed Knoll @(719)593-3762 @ 1990-11-15 17:26 UTC (permalink / raw)




The issue of portability is indeterminate if it is not planned for.  There 
are some aspects of the language and of some of the compilers that can make it 
difficult.  However, we have had some fairly decent success.  For example:

  A group I was working with was supporting two programs simultaneously.  One
  job was essentially a subset of the other with about 20% unique material.
  They were both hosted on the same target (embedded processor), but each 
  program was using a different run-time library.  This was the target 
  environment.

  On the host, we were using two different compilers.  One would generate
  code for the host and the target, the other just generated code for the
  host.  The host only compiler was somewhat faster and had a better host
  debugger.

  In addition, there was a large simulation (written in FORTRAN and Pascal)
  that emulated different aspects of the environment and the system.  We
  wished to test some of the subsystems of the Ada code by substituting
  them for their counterparts in the simulation.  At the same time we were
  putting together an environment where the entire applications software
  would be driven by the environment and hardware components of that
  simulation.

  We constructed an OS frontend to hide the differences between the two
  run-times for the target and we built a body for the frontend that would 
  allow the applications to run on the host.  The host only Ada compiler
  did not include 'long_int' in the standard package because 'integer' was
  long to begin with.  A package was constructed which contained a 'long_int'
  declaration for the host; the same package contained nothing for the target.
  This package was 'with'ed and 'use'ed by everyone.  Driver packages were 
  written for the different interfaces with the simulation.

  Library organization controlled how we constructed the different versions.

  Summary: Compilers             - 2
           Platforms             - 2 (target and host)
           Operating Systems     - 3 (two target and host emulation)
           Execution Environment - 5 (standalone host, subsystem w/ simulation, 
                                      entire system w/ simulation, two targets)

Not all code was (or could) be evaluated in every environment, but much of 
it was with very few portability problems.  It did take some planning and 
some rework, but very cost effective overall.

-------------------------------------------------------------------------------

Edward L. Knoll                     Disclaimer:  If my company doesn't trust
Texas Instruments                                my judgement, why am I working
5825 Mark Dabling Blvd                           for them?
Colorado Springs, Colo. 80919
(719) 593-5182

knoll@coopn1.csc.ti.com

^ permalink raw reply	[flat|nested] 16+ messages in thread
* Ada portability
@ 1990-11-16 17:09 "", Mats Weber
  1990-11-19 23:19 ` Robert I. Eachus
  0 siblings, 1 reply; 16+ messages in thread
From: "", Mats Weber @ 1990-11-16 17:09 UTC (permalink / raw)



In reply to what Dave Emery wrote, I must add that even if you write code 
with portability in mind, you will probably run into compiler quality 
problems if your code contains generics.
We have had major problems in this area which until now have made it 
impossible to port some quite small applications from VAX Ada to Unix with 
ANY compiler available on Unix.

In my opinion, the only two compilers I know that deserve the "validated" 
label are Rational and Vax Ada.


Mats Weber
Swiss Federal Institute of Technology
EPFL DI LGL
1015 Lausanne
Switzerland

E-mail : madmats@elcgl.epfl.ch
phone  : +41 21 693 52 92
fax    : +41 21 693 39 09

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

end of thread, other threads:[~1990-11-19 23:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1989-12-16  2:25 Ada portability and conditional compilation Daniel Lee
1989-12-16 18:07 ` William Thomas Wolfe, 2847 
1989-12-16 20:03 ` portability problems William Thomas Wolfe, 2847 
1989-12-20  4:17   ` ARTEWG Bruce Jones
1989-12-22 12:29     ` Ada Portability Ed Matthews
  -- strict thread matches above, loose matches on Subject: below --
1990-11-14 14:09 ada portability Claus Franzkowiak
1990-11-15 14:10 ` ryer
1990-11-14 14:16 Claus Franzkowiak
1990-11-17  4:09 ` Ted Holden
1990-11-14 14:19 Claus Franzkowiak
1990-11-14 14:27 Claus Franzkowiak
1990-11-14 14:47 Claus Franzkowiak
1990-11-14 17:04 Ada portability David Emery
1990-11-15 17:26 Ada Portability Ed Knoll @(719)593-3762
1990-11-16 17:09 Ada portability "", Mats Weber
1990-11-19 23:19 ` Robert I. Eachus

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