OSDN Git Service

2008-05-27 Vincent Celier <celier@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-casi32.adb
index 2f28018..7076918 100644 (file)
@@ -1,12 +1,12 @@
 ------------------------------------------------------------------------------
 --                                                                          --
---                   GNU ADA RUNTIME LIBRARY COMPONENTS                     --
+--                    GNAT RUN-TIME LIBRARY COMPONENTS                      --
 --                                                                          --
 --        S Y S T E M . C O M P A R E _ A R R A Y _ S I G N E D _ 3 2       --
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---             Copyright (C) 2002 Free Software Foundation, Inc.            --
+--          Copyright (C) 2002-2008, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -16,8 +16,8 @@
 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
 -- for  more details.  You should have  received  a copy of the GNU General --
 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.                                              --
 --                                                                          --
 -- As a special exception,  if other files  instantiate  generics from this --
 -- unit, or you link  this unit with other files  to produce an executable, --
@@ -31,7 +31,9 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with Unchecked_Conversion;
+with System.Address_Operations; use System.Address_Operations;
+
+with Ada.Unchecked_Conversion;
 
 package body System.Compare_Array_Signed_32 is
 
@@ -39,18 +41,15 @@ package body System.Compare_Array_Signed_32 is
    for Word'Size use 32;
    --  Used to process operands by words
 
-   type Uword is record
-      W : Word;
-   end record;
-   pragma Pack (Uword);
+   type Uword is new Word;
    for Uword'Alignment use 1;
    --  Used to process operands when unaligned
 
    type WP is access Word;
    type UP is access Uword;
 
-   function W is new Unchecked_Conversion (Address, WP);
-   function U is new Unchecked_Conversion (Address, UP);
+   function W is new Ada.Unchecked_Conversion (Address, WP);
+   function U is new Ada.Unchecked_Conversion (Address, UP);
 
    -----------------------
    -- Compare_Array_S32 --
@@ -60,8 +59,7 @@ package body System.Compare_Array_Signed_32 is
      (Left      : System.Address;
       Right     : System.Address;
       Left_Len  : Natural;
-      Right_Len : Natural)
-      return      Integer
+      Right_Len : Natural) return Integer
    is
       Clen : Natural := Natural'Min (Left_Len, Right_Len);
       --  Number of elements left to compare
@@ -73,7 +71,7 @@ package body System.Compare_Array_Signed_32 is
    begin
       --  Case of going by aligned words
 
-      if ((Left or Right) and (4 - 1)) = 0 then
+      if ModA (OrA (Left, Right), 4) = 0 then
          while Clen /= 0 loop
             if W (L).all /= W (R).all then
                if W (L).all > W (R).all then
@@ -84,16 +82,16 @@ package body System.Compare_Array_Signed_32 is
             end if;
 
             Clen := Clen - 1;
-            L := L + 4;
-            R := R + 4;
+            L := AddA (L, 4);
+            R := AddA (R, 4);
          end loop;
 
       --  Case of going by unaligned words
 
       else
          while Clen /= 0 loop
-            if U (L).W /= U (R).W then
-               if U (L).W > U (R).W then
+            if U (L).all /= U (R).all then
+               if U (L).all > U (R).all then
                   return +1;
                else
                   return -1;
@@ -101,8 +99,8 @@ package body System.Compare_Array_Signed_32 is
             end if;
 
             Clen := Clen - 1;
-            L := L + 4;
-            R := R + 4;
+            L := AddA (L, 4);
+            R := AddA (R, 4);
          end loop;
       end if;