[RS6000] cost SLOW_UNALIGNED_ACCESS
[official-gcc.git] / gcc / ada / a-calari.adb
blob1166b4349a309e7b0de5a5a027c71f715a55caf3
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . C A L E N D A R . A R I T H M E T I C --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2006-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 ------------------------------------------------------------------------------
32 package body Ada.Calendar.Arithmetic is
34 --------------------------
35 -- Implementation Notes --
36 --------------------------
38 -- All operations in this package are target and time representation
39 -- independent, thus only one source file is needed for multiple targets.
41 ---------
42 -- "+" --
43 ---------
45 function "+" (Left : Time; Right : Day_Count) return Time is
46 R : constant Long_Integer := Long_Integer (Right);
47 begin
48 return Arithmetic_Operations.Add (Left, R);
49 end "+";
51 function "+" (Left : Day_Count; Right : Time) return Time is
52 L : constant Long_Integer := Long_Integer (Left);
53 begin
54 return Arithmetic_Operations.Add (Right, L);
55 end "+";
57 ---------
58 -- "-" --
59 ---------
61 function "-" (Left : Time; Right : Day_Count) return Time is
62 R : constant Long_Integer := Long_Integer (Right);
63 begin
64 return Arithmetic_Operations.Subtract (Left, R);
65 end "-";
67 function "-" (Left, Right : Time) return Day_Count is
68 Days : Long_Integer;
69 Seconds : Duration;
70 Leap_Seconds : Integer;
71 pragma Warnings (Off, Seconds); -- temporary ???
72 pragma Warnings (Off, Leap_Seconds); -- temporary ???
73 pragma Unreferenced (Seconds, Leap_Seconds);
74 begin
75 Arithmetic_Operations.Difference
76 (Left, Right, Days, Seconds, Leap_Seconds);
77 return Day_Count (Days);
78 end "-";
80 ----------------
81 -- Difference --
82 ----------------
84 procedure Difference
85 (Left : Time;
86 Right : Time;
87 Days : out Day_Count;
88 Seconds : out Duration;
89 Leap_Seconds : out Leap_Seconds_Count)
91 Op_Days : Long_Integer;
92 Op_Leaps : Integer;
93 begin
94 Arithmetic_Operations.Difference
95 (Left, Right, Op_Days, Seconds, Op_Leaps);
96 Days := Day_Count (Op_Days);
97 Leap_Seconds := Leap_Seconds_Count (Op_Leaps);
98 end Difference;
100 end Ada.Calendar.Arithmetic;