comp.lang.ada
 help / color / mirror / Atom feed
From: Craig Carey <research@ijs.co.nz>
Subject: Re: ++ of C in ada
Date: Tue, 02 Aug 2005 17:32:44 +1200
Date: 2005-08-02T17:32:44+12:00	[thread overview]
Message-ID: <pmtte11v89tc8eobt0a0a2r5ka2fndcusb@4ax.com> (raw)
In-Reply-To: 1122228917.377279.262690@g47g2000cwa.googlegroups.com


On 24 Jul 2005 11:15:17 -0700, "nicolas.b"
<nicolas.blanpain@fr.thalesgroup.com> wrote:

>How can i implement the operator ++ in ada :
>
>type T_Ptr is access all T_Item;
>How can i implement : procedure Increment (Ptr : in out T_Ptr);
>thanks


A simple solution is to adapt GNAT source code. Then a problem for
a newbie might be: how to choose Linux and avoid daylight savings
bugs, unless Cygwin "cvs" runs. Here is some code I had already
written:


with System;  with Ada.Unchecked_Conversion;
                                    --  Similar to GNAT's i-cpoint.adb
package LL_Byte_Pointers is               --  Low level byte pointers

   function "+" (Left : in System.Address; Right : in Integer)
         return System.Address;

   pragma Convention (Intrinsic, "+");

end LL_Byte_Pointers;


package body LL_Byte_Pointers is

   generic function AUC renames Ada.Unchecked_Conversion;
   subtype Int is Integer;

   type Addr is mod System.Memory_Size;

   function To_System_Address is new AUC (Addr, System.Address);
   function To_Addr is new AUC (System.Address, Addr);
   function To_Addr is new AUC (Int, Addr);

   Elmt_Size   : constant Int := (String'Component_Size
                        + System.Storage_Unit - 1) / System.Storage_Unit;

               --  Strings are packed byte arrays. X'Address counts bytes
   pragma Assert (String'Component_Size = 8);
   pragma Assert (System.Storage_Unit = 8);

   function "+" (Left : in System.Address; Right : in Int)
         return System.Address is
   begin
      return To_System_Address (
                  To_Addr (Left) + To_Addr (Elmt_Size * Right));
   end "+";


end LL_Byte_Pointers;

Checked in the September 2004 MinGW GNAT compiler:

L:/mingw/bin/gnatmake ll_byte_pointers.adb -gnata -gnato -gnatq -gnatf
   -gnatU -m -i -O0 -g -gnatVa -gnatwacfHlpru -gnatR3s
   -bargs -E -p -we -s -static -largs -v -v -L. -lwin32ada -luser32...

(Older and newever versions of that compiler don't run, and all versions
seem unusable on large programs. The May 2005 MinGW GNAT lacks a gnat1
file, and seemingly an e-mail address of the pacakger).

---

There was a list of 191 FreeBSD Ports that would be deleted, at the
 "announce@freebsd.org" list (on 29 July 2005). 

With Debian GNU/Linux, the failures seem to occur at my end (no fonts
in KDE, and a while back it was ill-explained data loss until IBM did
something for the opensource project). 

A FreeBSD GNAT Ada cross-compiler seems to be a need.
I found that the FreeBSD Linuxulator can compete with and beat,
a native Linux distro (such a Debian system).


Craig Carey
research@ijs.co.nz





      parent reply	other threads:[~2005-08-02  5:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-24 18:15 ++ of C in ada nicolas.b
2005-07-24 18:22 ` Ludovic Brenta
2005-07-25  5:55 ` Jeffrey Carter
2005-07-25 13:18 ` Marc A. Criley
2005-07-25 17:00 ` Martin Krischik
2005-07-25 20:15 ` Robert A Duff
2005-08-02  5:32 ` Craig Carey [this message]
replies disabled

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