comp.lang.ada
 help / color / mirror / Atom feed
From: Per Sandberg <per.sandberg@bredband.net>
Subject: Some idea could be:
Date: Mon, 29 Aug 2011 19:14:43 +0200
Date: 2011-08-29T19:14:43+02:00	[thread overview]
Message-ID: <4e5bc8d1$0$10699$a8266bb1@newsreader.readnews.com> (raw)

The whole idea is copied from "System.Storage_Elements".
/P

---------------------------------------------------------
with System; use System;
with System.Storage_Elements; use System.Storage_Elements;
package ops is
    function "and" (Left  : Address;
                    Right : Address) return Address;
    pragma Convention (Intrinsic, "and");
    pragma Inline_Always ("and");
    pragma Pure_Function ("and");

    function "or" (Left  : Address;
                   Right : Address) return Address;
    pragma Convention (Intrinsic, "or");
    pragma Inline_Always ("or");
    pragma Pure_Function ("or");


    function "xor" (Left  : Address;
                    Right : Address) return Address;
    pragma Convention (Intrinsic, "xor");
    pragma Inline_Always ("xor");
    pragma Pure_Function ("xor");

    function "xor"
      (Left  : Address;
       Right : Integer_Address) return Address;
    pragma Convention (Intrinsic, "xor");
    pragma Inline_Always ("xor");
    pragma Pure_Function ("xor");

    function "xor"
      (Left  : Integer_Address;
       Right : Address) return Address;

    pragma Convention (Intrinsic, "xor");
    pragma Inline_Always ("xor");
    pragma Pure_Function ("xor");

end ops;

-----------------------------------------------------
package body ops is

    function "and"
      (Left  : Address;
       Right : Address)
       return Address
    is
    begin
       return To_Address (To_Integer (Left) and To_Integer (Right));
    end "and";


    function "or"
      (Left  : Address;
       Right : Address)
       return Address
    is
    begin
       return To_Address (To_Integer (Left) or To_Integer (Right));
    end "or";


    function "xor"
      (Left  : Address;
       Right : Address)
       return Address
    is
    begin
       return To_Address (To_Integer (Left) xor To_Integer (Right));
    end "xor";

    function "xor"
      (Left  : Address;
       Right : Integer_Address) return Address is
    begin
       return To_Address (To_Integer (Left) xor Right);
    end "xor";

    function "xor"
      (Left  : Integer_Address;
       Right : Address) return Address is
    begin
       return To_Address (Left xor To_Integer (Right));
    end "xor";
end ops;
------------------------------------------------------------
with ops; use ops;
with System.Storage_Elements; use System.Storage_Elements;
procedure My_Address_Ops_Demo is
    a1 : System.Address;
    a2 : System.Address;
    a3 : System.Address;
    pragma Unreferenced (a3);
begin
    a1 := a2'Address;
    a2 := a1'Address;
    a3 := 2#0000_0000_1111_1111# xor a2;
end My_Address_Ops_Demo;
-----------------------------------------------------------



             reply	other threads:[~2011-08-29 17:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-29 17:14 Per Sandberg [this message]
2011-08-29 19:17 ` Some idea could be: Dmitry A. Kazakov
replies disabled

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