comp.lang.ada
 help / color / mirror / Atom feed
From: Adrian Knoth <adi@thur.de>
Subject: Re: Porting ADA source
Date: 19 Jul 2004 11:09:08 GMT
Date: 2004-07-19T11:09:08+00:00	[thread overview]
Message-ID: <slrncfnauk.usp.adi@ppc201.mipool.uni-jena.de> (raw)
In-Reply-To: cdfu3s$k1a$1@e3k.asi.ansaldo.it

Giacomo Polizzi <mio@.> wrote:

First I suggest you should put some kind of email-address in this header.

> I have to port an ADA program from an Unix DEC Alpha machine with a DEC ADA
> compiler to a Linux pc machine with gnat (gcc) compiler.

Second you should realize that it is called "Ada".

> The task is to have, if possible, an unique source code compilable on both
> platforms but there are the following problems:

A solution might be a portable-package.

> 1) some system packages that execute the same kind of operations have
> different names in the two compilers

Write wrappers around it in the portable-package.

> 2) some system functions (for example mathematical function) have different
> names in the two compilers

Write wrappers around it in the portable-package.

> 3) the word length is 64 bits on DEC Alpha and 32 bits on pc so it is not
> always possible to use the same standard type (for example the long type is
> 64 bits on Alpha and 32 bits on pc)

Use your own types derived either from the largest type possible (range)
or use mod-types.

   type stuff is mod 2**64;


> 4) the standard type (long long) used by gcc on pc to solve the previous
> problem is not supported by the DEC ADA compiler

Don't rely on any special compiler behaviour, it might not be available
on your target. Use the language specification instead.

> 5) the different word length modifies some structure length used to define
> interface messages with other external programs

You lost. It's a well-known drawback in the C-programming language
that the memory layout of structs is not defined. Also for Ada it
is not specified, but when using representation clauses you can
force the compiler to make it your way, thus giving you a common
interface.

Ergo: you don't know how the compiler, used for compiling the external
C-library, arranges the structs in memory. And because you don't know
you can't build an Ada-Interface for that. The only thing you can
do is to take the headers and the same C-compiler and figure out how
it is done for that particular team (tool-chain). You cannot tell how
it will behave on different systems.

And you'll surely have to put these differences into the portable-package.
Keep in mind that different flags used for the C-compiler may result
in different memory-layout of your structs. 

I suggest a complete rewrite of the world with RepClauses ;)


-- 
mail: adi@thur.de  	http://adi.thur.de	PGP: v2-key via keyserver

Geht die Sonne auf im Westen, mu�t du deinen Kompa� testen



  parent reply	other threads:[~2004-07-19 11:09 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-19  7:42 Porting ADA source Giacomo Polizzi
2004-07-19 11:04 ` Dale Stanbrough
2004-07-19 12:14   ` Marin David Condic
2004-07-19 18:46     ` tmoran
2004-07-20  0:44       ` Marin David Condic
2004-07-20 11:18       ` Peter C. Chapin
2004-07-20 11:41         ` Martin Dowie
2004-07-20 11:59           ` Marin David Condic
2004-07-20 13:02             ` Georg Bauhaus
2004-07-20 18:49             ` Jeffrey Carter
2004-07-20 22:51             ` Randy Brukardt
2004-07-21  0:35               ` Robert I. Eachus
2004-07-21 12:24                 ` Marin David Condic
2004-07-22 22:48                   ` Robert I. Eachus
2004-07-23 13:00                     ` Marin David Condic
2004-07-24  3:04                       ` Robert I. Eachus
2004-07-24 11:48                         ` Marin David Condic
2004-07-24 12:42                           ` Robert I. Eachus
2004-07-26 18:39                             ` Marin David Condic
2004-08-17  4:28               ` Ronald Price
2004-08-17 11:28                 ` Frank J. Lhota
2004-07-19 11:09 ` Adrian Knoth [this message]
2004-07-19 12:23 ` Porting Ada source Jacob Sparre Andersen
2004-07-19 18:05   ` Jean-Pierre Rosen
2004-07-19 13:39 ` Porting ADA source Steve
2004-07-20  0:54   ` Marin David Condic
2004-07-19 18:05 ` Martin Dowie
2004-07-19 19:33   ` Wes Groleau
2004-07-19 20:03     ` Larry Kilgallen
2004-07-19 20:29       ` Wes Groleau
2004-07-20 16:13         ` Martin Krischik
2004-07-19 21:36     ` Martin Dowie
2004-07-20 12:14       ` Frank J. Lhota
2004-07-20 12:27         ` Vinzent 'Gadget' Hoefler
2004-07-20 13:13 ` Peter Amey
2004-07-21  6:20 ` Volkert
2004-07-31 16:04 ` Richard  Riehle
replies disabled

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