comp.lang.ada
 help / color / mirror / Atom feed
* Win32 binding
@ 2002-04-23  9:37 Antonio L�pez
  2002-04-23 16:06 ` Stephen Leake
  0 siblings, 1 reply; 4+ messages in thread
From: Antonio L�pez @ 2002-04-23  9:37 UTC (permalink / raw)


I am using the Win32 binding that comes with the Gnat compiler in order to
interface with the API of a Dll.

When searching for an use example of "type    ULONG_Array is array (Natural
range <>) of aliased ULONG;", I found only one in win32-rpcndr.ads.
However instead of declare an array, it declares the elements alone, calling
for "storage unit bounday".

I have searched for "storage unit bounday", but I don0t understant the
concept and/or the problem. Can some enlight me, please?

Cheers,
Antonio


--  Reserved              : Win32.ULONG_Array(0..6);  -- rpcndr.h:802
--  @@ with GNAT the type ULONG_Array must be aligned at a storage
--  unit boundary. So I decided for now to declare Reserved<1..7>
--  instead.
         Reserved1 : Win32.ULONG;
         Reserved2 : Win32.ULONG;
         Reserved3 : Win32.ULONG;
         Reserved4 : Win32.ULONG;
         Reserved5 : Win32.ULONG;
         Reserved6 : Win32.ULONG;
         Reserved7 : Win32.ULONG;
      end record;






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

* Re: Win32 binding
  2002-04-23  9:37 Win32 binding Antonio L�pez
@ 2002-04-23 16:06 ` Stephen Leake
  2002-04-23 17:22   ` Gary Scott
  2002-04-24 10:46   ` Antonio López
  0 siblings, 2 replies; 4+ messages in thread
From: Stephen Leake @ 2002-04-23 16:06 UTC (permalink / raw)


"Antonio L�pez" <alm@gtd.es.REMOVE> writes:

> I am using the Win32 binding that comes with the Gnat compiler in order to
> interface with the API of a Dll.
> 
> When searching for an use example of "type    ULONG_Array is array (Natural
> range <>) of aliased ULONG;", I found only one in win32-rpcndr.ads.
> However instead of declare an array, it declares the elements alone, calling
> for "storage unit bounday".

the keyword "aliased" in the definition of ULONG_Array means that the
compiler must be able to provide pointers to the elements of the
array. In practice this means they elements must be directly
addressable, which means they must start on storage unit boundaries.
"storage unit boundaries" is the precise term for the common notion of
"byte" or "memory location".

For example, if the elements of the array were 4 bits, you could pack
two into a single byte; then the elements would _not_ be directly
addressable, so the keyword "aliased" forbids this packing.

However, in this particular case, the elements are 32 bit integers,
and there is no reason not to align them on byte boundaries, so I
don't think the comment in win32-rpcndr.ads is meaningful. Hmm, it
might have some impact on a machine that had 16 or 32 bit storage
units, but I'm not aware of Windows ports to any such machines!

> I have searched for "storage unit bounday", but I don0t understant
> the concept and/or the problem. Can some enlight me, please?
> 
> Cheers,
> Antonio
> 
> 
> --  Reserved              : Win32.ULONG_Array(0..6);  -- rpcndr.h:802
> --  @@ with GNAT the type ULONG_Array must be aligned at a storage
> --  unit boundary. So I decided for now to declare Reserved<1..7>
> --  instead.
>          Reserved1 : Win32.ULONG;
>          Reserved2 : Win32.ULONG;
>          Reserved3 : Win32.ULONG;
>          Reserved4 : Win32.ULONG;
>          Reserved5 : Win32.ULONG;
>          Reserved6 : Win32.ULONG;
>          Reserved7 : Win32.ULONG;
>       end record;
> 
> 
> 

-- 
-- Stephe



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

* Re: Win32 binding
  2002-04-23 16:06 ` Stephen Leake
@ 2002-04-23 17:22   ` Gary Scott
  2002-04-24 10:46   ` Antonio López
  1 sibling, 0 replies; 4+ messages in thread
From: Gary Scott @ 2002-04-23 17:22 UTC (permalink / raw)




Stephen Leake wrote:
> 
> "Antonio L�pez" <alm@gtd.es.REMOVE> writes:
> 
> > I am using the Win32 binding that comes with the Gnat compiler in order to
> > interface with the API of a Dll.
> >
> > When searching for an use example of "type    ULONG_Array is array (Natural
> > range <>) of aliased ULONG;", I found only one in win32-rpcndr.ads.
> > However instead of declare an array, it declares the elements alone, calling
> > for "storage unit bounday".
> 
> the keyword "aliased" in the definition of ULONG_Array means that the
> compiler must be able to provide pointers to the elements of the
> array. In practice this means they elements must be directly
> addressable, which means they must start on storage unit boundaries.
> "storage unit boundaries" is the precise term for the common notion of
> "byte" or "memory location".

Well, the common notion that "memory location" means "byte" isn't quite
correct.  On many systems, it means "word" which may be any number of
differing numbers of "bits" and/or "bytes".  Some older systems couldn't
efficiently address a "byte-sized" quantity (not to mention that a byte
isn't always 8-bits).

> 
> For example, if the elements of the array were 4 bits, you could pack
> two into a single byte; then the elements would _not_ be directly
> addressable, so the keyword "aliased" forbids this packing.
> 
> However, in this particular case, the elements are 32 bit integers,
> and there is no reason not to align them on byte boundaries, so I
> don't think the comment in win32-rpcndr.ads is meaningful. Hmm, it
> might have some impact on a machine that had 16 or 32 bit storage
> units, but I'm not aware of Windows ports to any such machines!
> 
> > I have searched for "storage unit bounday", but I don0t understant
> > the concept and/or the problem. Can some enlight me, please?
> >
> > Cheers,
> > Antonio
> >
> >
> > --  Reserved              : Win32.ULONG_Array(0..6);  -- rpcndr.h:802
> > --  @@ with GNAT the type ULONG_Array must be aligned at a storage
> > --  unit boundary. So I decided for now to declare Reserved<1..7>
> > --  instead.
> >          Reserved1 : Win32.ULONG;
> >          Reserved2 : Win32.ULONG;
> >          Reserved3 : Win32.ULONG;
> >          Reserved4 : Win32.ULONG;
> >          Reserved5 : Win32.ULONG;
> >          Reserved6 : Win32.ULONG;
> >          Reserved7 : Win32.ULONG;
> >       end record;
> >
> >
> >
> 
> --
> -- Stephe



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

* Re: Win32 binding
  2002-04-23 16:06 ` Stephen Leake
  2002-04-23 17:22   ` Gary Scott
@ 2002-04-24 10:46   ` Antonio López
  1 sibling, 0 replies; 4+ messages in thread
From: Antonio López @ 2002-04-24 10:46 UTC (permalink / raw)


> However, in this particular case, the elements are 32 bit integers,
> and there is no reason not to align them on byte boundaries, so I
> don't think the comment in win32-rpcndr.ads is meaningful. Hmm, it
> might have some impact on a machine that had 16 or 32 bit storage
> units, but I'm not aware of Windows ports to any such machines!

In fact, arrays of 16 bit unsigned integers and 8 bit unsigned chars
are used without problems in that binding. This is why I was confused.



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

end of thread, other threads:[~2002-04-24 10:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-23  9:37 Win32 binding Antonio L�pez
2002-04-23 16:06 ` Stephen Leake
2002-04-23 17:22   ` Gary Scott
2002-04-24 10:46   ` Antonio López

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