comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Access Type
Date: Wed, 29 Dec 2010 15:18:55 +0000
Date: 2010-12-29T15:18:55+00:00	[thread overview]
Message-ID: <m2lj387gkg.fsf@pushface.org> (raw)
In-Reply-To: 0cc2d01d-2744-470f-82e9-f7aa1c097783@c39g2000yqi.googlegroups.com

kug1977 <kug1977@web.de> writes:

> On 29 Dez., 00:52, Simon Wright <si...@pushface.org> wrote:
>> kug1977 <kug1...@web.de> writes:
>> > For my programm I need a type like System.Address but with a
>> > definitive size of 32-bits. So I've create one
>>
>> >    type t_OFW_vAddress is mod t_Cell_Size;
>> >    for t_OFW_vAddress'Size use 32 ;
>> >    pragma Assert (t_OFW_vAddress'Size = 32);
>> >    pragma Assert (t_OFW_vAddress'Alignment = 4) ;
>>
>> >    OFW_Null_vAddress : constant t_OFW_vAddress := 0;
>>
>> You shouldn't need the first Assert, because if the compiler can't
>> honour the "for t_OFW_vAddress'Size use 32;" it should refuse the
>> compilation.
>>
>> Similarly, replace the second Assert by "for t_OFW_vAddress'Alignment
>> use 4;".
>>
>> But .. are you using GNAT? because, being built on GCC, its natural
>> tendency is to use the same representations as C would. In any case, I
>> think you're making things more complicated than they need to be.
>>
>> Assuming that both your Ada and C compilers are 32-bit (you have big
>> problems ahead if they are different!), type System.Address is going to
>> be 32-bits and 4-byte aligned anyway.
>>
>> So why not just use System.Address? (I guess in that case it would make
>> sense to assert that System.Address'Size is 32, etc. Though the main
>> thing is to be sure that your compilers and system libraries agree!)
>
> I've to give you more information about the project. The thing will be
> a bootloader for IEEE1275 aka Open Firmware (OFW) (used in Apple Mac
> PPC's). So, my Ada programm is using the OFW client interface which is
> defined in the standard usign 32-bit wide Cells on 4-Byte boundaries
> some hold natural numbers, others pointer to X but all are 32-bit. So,
> the damn thing are not allowed to use 64-Bit wide System.Address.
>
> So, you suggest to use an System.Address, an assert for the 32-bit and
> compiler options to make sure every thing is 32-bit? Sounds easy.

Broadly, yes.

It's possible to have one compiler generate both 32- and 64-bit code;
for an Intel target you can use -m32/-m64 (for example) provided the
compiler was built with that ability. Whenever I've built a compiler
it's been for one architecture only; if for no other reason than that
the Ada build process in GCC doesn't support multilibs. (Well, that's
what the documentation seemed to be saying ...)

I don't remember whether GNAT for PowerPC supports 64-bit, don't think
so???

It sounds as though your argument list ought to be an array of ints (or
Integers), not bytes?

One thing you'll need to be careful of: some Ada features (eg exception
handling, functions returing indefinite objects, tasking ...) rely on
runtime support that may not be available, or may not be properly
initialized, in the OFW environment. I'm not familiar with how to get
over this sort of problem.

> Simon, I really appreciate your help and hope you don't stop.

You're welcome.



  reply	other threads:[~2010-12-29 15:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-24 16:36 Access Type kug1977
2010-12-24 17:30 ` Robert A Duff
2010-12-24 20:59   ` kug1977
2010-12-24 22:06     ` Simon Wright
2010-12-27  1:50     ` Ludovic Brenta
2010-12-27 12:29       ` Simon Wright
2010-12-27 17:53         ` Ludovic Brenta
2010-12-27 18:15           ` Simon Wright
2010-12-27 20:03             ` Pascal Obry
2010-12-28 20:08               ` kug1977
2010-12-28 23:52                 ` Simon Wright
2010-12-29  8:46                   ` kug1977
2010-12-29 15:18                     ` Simon Wright [this message]
2010-12-29 15:27                       ` Ludovic Brenta
replies disabled

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