comp.lang.ada
 help / color / mirror / Atom feed
From: awdorrin <awdorrin@gmail.com>
Subject: Re: Interfacing between Ada and C: records and structs
Date: Tue, 31 Jul 2012 11:44:11 -0700 (PDT)
Date: 2012-07-31T11:44:11-07:00	[thread overview]
Message-ID: <5813d3d2-8a9f-4a08-bf09-db3c62847593@googlegroups.com> (raw)
In-Reply-To: <a7qi6qFoc3U1@mid.individual.net>

On Tuesday, July 31, 2012 1:16:10 PM UTC-4, Niklas Holsti wrote:
> 
> How is pthread_mutex_t declared in Ada form? And in C form?
> 

Digging into the POSIX module:

private
  type Dummy is tagged null record;
  type Mutex is record
    Mutex : aliased POSIX.C.pthread_mutex_t;
    D : Dummy;
  end record

> 
> Have you checked that in Ada, pthread_mutex_t'Size is 192?
> 

In the POSIX.C package:
ALIGNMENT : constant := Natural'Min(Standard'Maximum_Alignment, 8);
type pthread_mutex_t'Alignment use ALIGNMENT;
type pthread_mutex_t'Size use 192;

However, when I write a simple test program I get 256 bits from 'Size, I'm not sure why...
But that is probably the source of my problem.
 
> 
> What is the storage unit of your target processor? 8 bits?

The system is an Intel core2Duo E4600 - so a 64bit processor running x86_64 variant of Debian. (32-bit mode) So the storage unit is 8 bits.

> 
> That is a strange alignment. Do you see any need for it? If not, try
> removing it.

That was a typo on my part, should have read 'Alignment use 8;

> 
> Do you see any need for this representation clause? If not, remove it.
> 
> Or change it to use 192 bits per component.

That is the output from the -gnatR3 parameter, I don't have the rep spec defined in the code.

> 
> (What are the "-" characters after the "at" keywords? Shouldn't it read
> "at 0 range"?)

Sorry, that was apparently another typo on my part. (Cut and paste isn't working between my Linux VNC session and my desktop Windows PC)






  reply	other threads:[~2012-08-07  7:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-31 16:38 Interfacing between Ada and C: records and structs awdorrin
2012-07-31 17:16 ` Niklas Holsti
2012-07-31 18:44   ` awdorrin [this message]
2012-07-31 19:08     ` awdorrin
2012-07-31 19:27       ` Simon Wright
2012-07-31 19:44         ` awdorrin
2012-07-31 20:46           ` Niklas Holsti
2012-08-01 12:16             ` awdorrin
2012-07-31 19:23     ` Simon Wright
2012-08-02  4:39     ` Shark8
2012-08-02 12:32       ` awdorrin
     [not found] <7beb59ba-ca6f-476e-8b39-604196b0b79f@googlegroups.com>
2012-08-01  2:51 ` Jeffrey Carter
replies disabled

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