OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [ada/] [s-stoele.adb] - Blame information for rev 859

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--               S Y S T E M . S T O R A G E _ E L E M E N T S              --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
10
--                                                                          --
11
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
17
--                                                                          --
18
-- As a special exception under Section 7 of GPL version 3, you are granted --
19
-- additional permissions described in the GCC Runtime Library Exception,   --
20
-- version 3.1, as published by the Free Software Foundation.               --
21
--                                                                          --
22
-- You should have received a copy of the GNU General Public License and    --
23
-- a copy of the GCC Runtime Library Exception along with this program;     --
24
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
27
-- GNAT was originally developed  by the GNAT team at  New York University. --
28
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29
--                                                                          --
30
------------------------------------------------------------------------------
31
 
32
pragma Compiler_Unit;
33
 
34
with Ada.Unchecked_Conversion;
35
 
36
package body System.Storage_Elements is
37
 
38
   pragma Suppress (All_Checks);
39
 
40
   function To_Address is
41
     new Ada.Unchecked_Conversion (Storage_Offset, Address);
42
   function To_Offset  is
43
     new Ada.Unchecked_Conversion (Address, Storage_Offset);
44
 
45
   --  Conversion to/from integers
46
 
47
   --  These functions must be place first because they are inlined_always
48
   --  and are used and inlined in other subprograms defined in this unit.
49
 
50
   function To_Integer (Value : Address) return Integer_Address is
51
   begin
52
      return Integer_Address (Value);
53
   end To_Integer;
54
 
55
   function To_Address (Value : Integer_Address) return Address is
56
   begin
57
      return Address (Value);
58
   end To_Address;
59
 
60
   --  Address arithmetic
61
 
62
   function "+" (Left : Address; Right : Storage_Offset) return Address is
63
   begin
64
      return To_Address (To_Integer (Left) + To_Integer (To_Address (Right)));
65
   end "+";
66
 
67
   function "+" (Left : Storage_Offset; Right : Address) return Address is
68
   begin
69
      return To_Address (To_Integer (To_Address (Left)) + To_Integer (Right));
70
   end "+";
71
 
72
   function "-" (Left : Address; Right : Storage_Offset) return Address is
73
   begin
74
      return To_Address (To_Integer (Left) - To_Integer (To_Address (Right)));
75
   end "-";
76
 
77
   function "-" (Left, Right : Address) return Storage_Offset is
78
   begin
79
      return To_Offset (To_Address (To_Integer (Left) - To_Integer (Right)));
80
   end "-";
81
 
82
   function "mod"
83
     (Left  : Address;
84
      Right : Storage_Offset) return Storage_Offset
85
   is
86
   begin
87
      if Right > 0 then
88
         return Storage_Offset
89
           (To_Integer (Left) mod Integer_Address (Right));
90
 
91
         --  The negative case makes no sense since it is a case of a mod where
92
         --  the left argument is unsigned and the right argument is signed. In
93
         --  accordance with the (spirit of the) permission of RM 13.7.1(16),
94
         --  we raise CE, and also include the zero case here. Yes, the RM says
95
         --  PE, but this really is so obviously more like a constraint error.
96
 
97
      else
98
         raise Constraint_Error;
99
      end if;
100
   end "mod";
101
end System.Storage_Elements;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.