aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/libgnat
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/libgnat')
-rw-r--r--gcc/ada/libgnat/a-calend.adb29
-rw-r--r--gcc/ada/libgnat/a-cbhama.adb2
-rw-r--r--gcc/ada/libgnat/a-cbhama.ads2
-rw-r--r--gcc/ada/libgnat/g-calend.adb21
-rw-r--r--gcc/ada/libgnat/g-socket.adb9
5 files changed, 44 insertions, 19 deletions
diff --git a/gcc/ada/libgnat/a-calend.adb b/gcc/ada/libgnat/a-calend.adb
index 4f89a40..0be5673 100644
--- a/gcc/ada/libgnat/a-calend.adb
+++ b/gcc/ada/libgnat/a-calend.adb
@@ -1068,19 +1068,28 @@ is
tv_nsec : out Long_Integer)
is
pragma Unsuppress (Overflow_Check);
- Secs : Duration;
- Nano_Secs : Duration;
begin
- -- Seconds extraction, avoid potential rounding errors
-
- Secs := D - 0.5;
- tv_sec := Long_Long_Integer (Secs);
-
- -- Nanoseconds extraction
+ if D = 0.0 then
+ tv_sec := 0;
+ tv_nsec := 0;
+
+ elsif D < 0.0 then
+ tv_sec := Long_Long_Integer (D + 0.5);
+ if D = Duration (tv_sec) then
+ tv_nsec := 0;
+ else
+ tv_nsec := Long_Integer ((D - Duration (tv_sec)) * Nano + 0.5);
+ end if;
- Nano_Secs := D - Duration (tv_sec);
- tv_nsec := Long_Integer (Nano_Secs * Nano);
+ else
+ tv_sec := Long_Long_Integer (D - 0.5);
+ if D = Duration (tv_sec) then
+ tv_nsec := 0;
+ else
+ tv_nsec := Long_Integer ((D - Duration (tv_sec)) * Nano - 0.5);
+ end if;
+ end if;
end To_Struct_Timespec_64;
------------------
diff --git a/gcc/ada/libgnat/a-cbhama.adb b/gcc/ada/libgnat/a-cbhama.adb
index ee6584d..b2d7964 100644
--- a/gcc/ada/libgnat/a-cbhama.adb
+++ b/gcc/ada/libgnat/a-cbhama.adb
@@ -368,7 +368,7 @@ is
-- Empty --
-----------
- function Empty (Capacity : Count_Type) return Map is
+ function Empty (Capacity : Count_Type := 10) return Map is
begin
return Result : Map (Capacity, 0) do
null;
diff --git a/gcc/ada/libgnat/a-cbhama.ads b/gcc/ada/libgnat/a-cbhama.ads
index 6ffc815..c741b40 100644
--- a/gcc/ada/libgnat/a-cbhama.ads
+++ b/gcc/ada/libgnat/a-cbhama.ads
@@ -71,7 +71,7 @@ is
-- Map objects declared without an initialization expression are
-- initialized to the value Empty_Map.
- function Empty (Capacity : Count_Type) return Map;
+ function Empty (Capacity : Count_Type := 10) return Map;
No_Element : constant Cursor;
-- Cursor objects declared without an initialization expression are
diff --git a/gcc/ada/libgnat/g-calend.adb b/gcc/ada/libgnat/g-calend.adb
index e410c3e..a2bc77c 100644
--- a/gcc/ada/libgnat/g-calend.adb
+++ b/gcc/ada/libgnat/g-calend.adb
@@ -344,6 +344,8 @@ package body GNAT.Calendar is
sec : aliased C.Extensions.long_long;
usec : aliased C.long;
+ pragma Unsuppress (Overflow_Check);
+
begin
timeval_to_duration (T, sec'Access, usec'Access);
pragma Annotate (CodePeer, Modified, sec);
@@ -369,13 +371,28 @@ package body GNAT.Calendar is
sec : C.Extensions.long_long;
usec : C.long;
+ pragma Unsuppress (Overflow_Check);
+
begin
if D = 0.0 then
sec := 0;
usec := 0;
+
+ elsif D < 0.0 then
+ sec := C.Extensions.long_long (D + 0.5);
+ if D = Duration (sec) then
+ usec := 0;
+ else
+ usec := C.long ((D - Duration (sec)) * Micro + 0.5);
+ end if;
+
else
- sec := C.Extensions.long_long (D - 0.5);
- usec := C.long ((D - Duration (sec)) * Micro - 0.5);
+ sec := C.Extensions.long_long (D - 0.5);
+ if D = Duration (sec) then
+ usec := 0;
+ else
+ usec := C.long ((D - Duration (sec)) * Micro - 0.5);
+ end if;
end if;
duration_to_timeval (sec, usec, Result'Access);
diff --git a/gcc/ada/libgnat/g-socket.adb b/gcc/ada/libgnat/g-socket.adb
index 5042dac..0fed791 100644
--- a/gcc/ada/libgnat/g-socket.adb
+++ b/gcc/ada/libgnat/g-socket.adb
@@ -3059,12 +3059,11 @@ package body GNAT.Sockets is
-- Normal case where we do round down
else
- S := time_t (Val - 0.5);
- uS := suseconds_t (1_000_000 * (Val - Selector_Duration (S)) - 0.5);
-
- if uS = -1 then
- -- It happen on integer duration
+ S := time_t (Val - 0.5);
+ if Val = Timeval_Duration (S) then
uS := 0;
+ else
+ uS := suseconds_t ((Val - Timeval_Duration (S)) * 1_000_000 - 0.5);
end if;
end if;