Bug#1074577: gnat ftbfs with glibc from experimental
Source: gcc-13
Followup-For: Bug #1074577
Matthias Klose:
> Simon Chopin came up with a conditional to work with both variants
[before and after glibc introduces __USE_TIME64_REDIRECTS]
> #if defined(__USE_TIME64_REDIRECTS) || (__TIMESIZE == 32 && __USE_TIME_BITS64)
I have forwarded this upstream as version 11.
This changes the libgnat-13 sources (System.OS_Constants).
Most Ada packages will require a bin-NMU after you upload gcc-13,
ideally before people start filling FTBS bug reports.
I take the opportunity to apply some postponed changes.
I do not commit them because I have tested no build,
but the only changes since the (tested) version 10 are
* the line above, tested by Simon Chopin in Ubuntu
* unapplying small style changes reviewed by upstream
From: Nicolas Boulenguez <nicolas@debian.org>
Subject: [PATCH] Ada: update patches for PR114065 (time_64) to v11
The fix 2bacf86d for #1074577 by Simon Chopin at
https://bugs.launchpad.net/ubuntu/+source/gcc-13/+bug/2071605 requires
a rebuild of all Ada libraries, so we might as well
* update all patches to version 11
* apply the parts fixing bugs, but not the style suggestions
---
...ersions-with-C-struct-timeval-from-GN.diff | 143 -----
...ersions-with-C-struct-timespec-from-A.diff | 167 -----
...ersions-with-C-time_t-from-System.OS_.diff | 79 ---
...imeval-and-timespec-definitions-and-c.diff | 604 ++++++++++++++----
...-unneeded-x32-variant-of-System.Linux.diff | 146 -----
...ed-posix2008-variant-of-System.Parame.diff | 229 -------
...ed-darwin-solaris-x32-variants-of-Sys.diff | 472 --------------
...sleep-from-System.OS_Primitives.Timed.diff | 74 ---
...its-time-functions-from-GNU-libc-when.diff | 74 ++-
debian/rules.patch | 7 -
10 files changed, 520 insertions(+), 1475 deletions(-)
delete mode 100644 debian/patches/0001-Ada-remove-conversions-with-C-struct-timeval-from-GN.diff
delete mode 100644 debian/patches/0002-Ada-remove-conversions-with-C-struct-timespec-from-A.diff
delete mode 100644 debian/patches/0003-Ada-remove-conversions-with-C-time_t-from-System.OS_.diff
delete mode 100644 debian/patches/0005-Ada-drop-unneeded-x32-variant-of-System.Linux.diff
delete mode 100644 debian/patches/0006-Ada-drop-unneeded-posix2008-variant-of-System.Parame.diff
delete mode 100644 debian/patches/0007-Ada-drop-unneeded-darwin-solaris-x32-variants-of-Sys.diff
delete mode 100644 debian/patches/0008-Ada-import-nanosleep-from-System.OS_Primitives.Timed.diff
diff --git a/debian/patches/0001-Ada-remove-conversions-with-C-struct-timeval-from-GN.diff b/debian/patches/0001-Ada-remove-conversions-with-C-struct-timeval-from-GN.diff
deleted file mode 100644
index d57d7ec7..00000000
--- a/debian/patches/0001-Ada-remove-conversions-with-C-struct-timeval-from-GN.diff
+++ /dev/null
@@ -1,143 +0,0 @@
-From bedb7553c420da59938eacb115fd9384e54ceae0 Mon Sep 17 00:00:00 2001
-From: Nicolas Boulenguez <nicolas.boulenguez@free.fr>
-Date: Fri, 5 Apr 2024 16:51:54 +0200
-Subject: [PATCH 1/9] Ada: remove conversions with C struct timeval from
- GNAT.Calendar
-
----
- gcc/ada/doc/gnat_rm/the_gnat_library.rst | 2 -
- gcc/ada/libgnat/g-calend.adb | 58 ------------------------
- gcc/ada/libgnat/g-calend.ads | 18 --------
- 3 files changed, 78 deletions(-)
-
-diff --git a/src/gcc/ada/doc/gnat_rm/the_gnat_library.rst b/src/gcc/ada/doc/gnat_rm/the_gnat_library.rst
-index 3aae70a..bcec49f 100644
---- a/src/gcc/ada/doc/gnat_rm/the_gnat_library.rst
-+++ b/src/gcc/ada/doc/gnat_rm/the_gnat_library.rst
-@@ -674,8 +674,6 @@ Machine-specific implementations are available in some cases.
-
- Extends the facilities provided by ``Ada.Calendar`` to include handling
- of days of the week, an extended ``Split`` and ``Time_Of`` capability.
--Also provides conversion of ``Ada.Calendar.Time`` values to and from the
--C ``timeval`` format.
-
- .. _`GNAT.Calendar.Time_IO_(g-catiio.ads)`:
-
-diff --git a/src/gcc/ada/libgnat/g-calend.adb b/src/gcc/ada/libgnat/g-calend.adb
-index 0a98eb2..e0d34f5 100644
---- a/src/gcc/ada/libgnat/g-calend.adb
-+++ b/src/gcc/ada/libgnat/g-calend.adb
-@@ -29,11 +29,8 @@
- -- --
- ------------------------------------------------------------------------------
-
--with Interfaces.C.Extensions;
--
- package body GNAT.Calendar is
- use Ada.Calendar;
-- use Interfaces;
-
- -----------------
- -- Day_In_Year --
-@@ -328,61 +325,6 @@ package body GNAT.Calendar is
- Time_Zone => 0);
- end Time_Of_At_Locale;
-
-- -----------------
-- -- To_Duration --
-- -----------------
--
-- function To_Duration (T : not null access timeval) return Duration is
--
-- procedure timeval_to_duration
-- (T : not null access timeval;
-- sec : not null access C.Extensions.long_long;
-- usec : not null access C.long);
-- pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
--
-- Micro : constant := 10**6;
-- sec : aliased C.Extensions.long_long;
-- usec : aliased C.long;
--
-- begin
-- timeval_to_duration (T, sec'Access, usec'Access);
-- pragma Annotate (CodePeer, Modified, sec);
-- pragma Annotate (CodePeer, Modified, usec);
--
-- return Duration (sec) + Duration (usec) / Micro;
-- end To_Duration;
--
-- ----------------
-- -- To_Timeval --
-- ----------------
--
-- function To_Timeval (D : Duration) return timeval is
--
-- procedure duration_to_timeval
-- (Sec : C.Extensions.long_long;
-- Usec : C.long;
-- T : not null access timeval);
-- pragma Import (C, duration_to_timeval, "__gnat_duration_to_timeval");
--
-- Micro : constant := 10**6;
-- Result : aliased timeval;
-- sec : C.Extensions.long_long;
-- usec : C.long;
--
-- begin
-- if D = 0.0 then
-- sec := 0;
-- usec := 0;
-- else
-- sec := C.Extensions.long_long (D - 0.5);
-- usec := C.long ((D - Duration (sec)) * Micro - 0.5);
-- end if;
--
-- duration_to_timeval (sec, usec, Result'Access);
--
-- return Result;
-- end To_Timeval;
--
- ------------------
- -- Week_In_Year --
- ------------------
-diff --git a/src/gcc/ada/libgnat/g-calend.ads b/src/gcc/ada/libgnat/g-calend.ads
-index b9dd15d..f317ab4 100644
---- a/src/gcc/ada/libgnat/g-calend.ads
-+++ b/src/gcc/ada/libgnat/g-calend.ads
-@@ -40,7 +40,6 @@
- -- Day_Of_Week, Day_In_Year and Week_In_Year.
-
- with Ada.Calendar.Formatting;
--with Interfaces.C;
-
- package GNAT.Calendar is
-
-@@ -145,24 +144,7 @@ package GNAT.Calendar is
- -- Return the week number as defined in ISO 8601 along with the year in
- -- which the week occurs.
-
-- -- C timeval conversion
--
-- -- C timeval represent a duration (used in Select for example). This
-- -- structure is composed of a number of seconds and a number of micro
-- -- seconds. The timeval structure is not exposed here because its
-- -- definition is target dependent. Interface to C programs is done via a
-- -- pointer to timeval structure.
--
-- type timeval is private;
--
-- function To_Duration (T : not null access timeval) return Duration;
-- function To_Timeval (D : Duration) return timeval;
--
- private
-- -- This is a dummy declaration that should be the largest possible timeval
-- -- structure of all supported targets.
--
-- type timeval is array (1 .. 3) of Interfaces.C.long;
-
- function Julian_Day
- (Year : Ada.Calendar.Year_Number;
---
-2.39.2
-
diff --git a/debian/patches/0002-Ada-remove-conversions-with-C-struct-timespec-from-A.diff b/debian/patches/0002-Ada-remove-conversions-with-C-struct-timespec-from-A.diff
deleted file mode 100644
index 6d11def2..00000000
--- a/debian/patches/0002-Ada-remove-conversions-with-C-struct-timespec-from-A.diff
+++ /dev/null
@@ -1,167 +0,0 @@
-From 4099038b7c9c5a5b5747ddc3a05dbb6b5d95f544 Mon Sep 17 00:00:00 2001
-From: Nicolas Boulenguez <nicolas.boulenguez@free.fr>
-Date: Thu, 4 Apr 2024 16:50:18 +0200
-Subject: [PATCH 2/9] Ada: remove conversions with C struct timespec from
- Ada.Calendar
-
----
- gcc/ada/libgnat/a-calcon.adb | 33 -------------------------------
- gcc/ada/libgnat/a-calcon.ads | 18 +----------------
- gcc/ada/libgnat/a-calend.adb | 38 ------------------------------------
- gcc/ada/libgnat/a-calend.ads | 11 -----------
- 4 files changed, 1 insertion(+), 99 deletions(-)
-
-diff --git a/src/gcc/ada/libgnat/a-calcon.adb b/src/gcc/ada/libgnat/a-calcon.adb
-index 8654d1e..3c5ec21 100644
---- a/src/gcc/ada/libgnat/a-calcon.adb
-+++ b/src/gcc/ada/libgnat/a-calcon.adb
-@@ -69,39 +69,6 @@ package body Ada.Calendar.Conversions is
- (Year, Month, Day, Hour, Minute, Second, DST);
- end To_Ada_Time;
-
-- -----------------
-- -- To_Duration --
-- -----------------
--
-- function To_Duration
-- (tv_sec : long;
-- tv_nsec : long) return Duration
-- is
-- Secs : constant Long_Integer := Long_Integer (tv_sec);
-- Nano_Secs : constant Long_Integer := Long_Integer (tv_nsec);
-- begin
-- return Conversion_Operations.To_Duration (Secs, Nano_Secs);
-- end To_Duration;
--
-- ------------------------
-- -- To_Struct_Timespec --
-- ------------------------
--
-- procedure To_Struct_Timespec
-- (D : Duration;
-- tv_sec : out long;
-- tv_nsec : out long)
-- is
-- Secs : Long_Integer;
-- Nano_Secs : Long_Integer;
--
-- begin
-- Conversion_Operations.To_Struct_Timespec (D, Secs, Nano_Secs);
--
-- tv_sec := long (Secs);
-- tv_nsec := long (Nano_Secs);
-- end To_Struct_Timespec;
--
- ------------------
- -- To_Struct_Tm --
- ------------------
-diff --git a/src/gcc/ada/libgnat/a-calcon.ads b/src/gcc/ada/libgnat/a-calcon.ads
-index 97df2a9..ad4ca64 100644
---- a/src/gcc/ada/libgnat/a-calcon.ads
-+++ b/src/gcc/ada/libgnat/a-calcon.ads
-@@ -30,7 +30,7 @@
- ------------------------------------------------------------------------------
-
- -- This package provides various routines for conversion between Ada and Unix
---- time models - Time, Duration, struct tm and struct timespec.
-+-- time models - Time, Duration and struct tm.
-
- with Interfaces.C;
-
-@@ -67,22 +67,6 @@ package Ada.Calendar.Conversions is
- -- the input values are out of the defined ranges or if tm_sec equals 60
- -- and the instance in time is not a leap second occurrence.
-
-- function To_Duration
-- (tv_sec : Interfaces.C.long;
-- tv_nsec : Interfaces.C.long) return Duration;
-- -- Convert an elapsed time value expressed in Unix-like fields of struct
-- -- timespec into a Duration value. The expected ranges are:
--
-- -- tv_sec - seconds
-- -- tv_nsec - nanoseconds
--
-- procedure To_Struct_Timespec
-- (D : Duration;
-- tv_sec : out Interfaces.C.long;
-- tv_nsec : out Interfaces.C.long);
-- -- Convert a Duration value into the constituents of struct timespec.
-- -- Formal tv_sec denotes seconds and tv_nsecs denotes nanoseconds.
--
- procedure To_Struct_Tm
- (T : Time;
- tm_year : out Interfaces.C.int;
-diff --git a/src/gcc/ada/libgnat/a-calend.adb b/src/gcc/ada/libgnat/a-calend.adb
-index 1083ece..06946a5 100644
---- a/src/gcc/ada/libgnat/a-calend.adb
-+++ b/src/gcc/ada/libgnat/a-calend.adb
-@@ -990,44 +990,6 @@ is
- raise Time_Error;
- end To_Ada_Time;
-
-- -----------------
-- -- To_Duration --
-- -----------------
--
-- function To_Duration
-- (tv_sec : Long_Integer;
-- tv_nsec : Long_Integer) return Duration
-- is
-- pragma Unsuppress (Overflow_Check);
-- begin
-- return Duration (tv_sec) + Duration (tv_nsec) / Nano_F;
-- end To_Duration;
--
-- ------------------------
-- -- To_Struct_Timespec --
-- ------------------------
--
-- procedure To_Struct_Timespec
-- (D : Duration;
-- tv_sec : out Long_Integer;
-- 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_Integer (Secs);
--
-- -- Nanoseconds extraction
--
-- Nano_Secs := D - Duration (tv_sec);
-- tv_nsec := Long_Integer (Nano_Secs * Nano);
-- end To_Struct_Timespec;
--
- ------------------
- -- To_Struct_Tm --
- ------------------
-diff --git a/src/gcc/ada/libgnat/a-calend.ads b/src/gcc/ada/libgnat/a-calend.ads
-index 9625f4d..cfffc70 100644
---- a/src/gcc/ada/libgnat/a-calend.ads
-+++ b/src/gcc/ada/libgnat/a-calend.ads
-@@ -303,17 +303,6 @@ private
- tm_isdst : Integer) return Time;
- -- Struct tm to Ada Epoch conversion
-
-- function To_Duration
-- (tv_sec : Long_Integer;
-- tv_nsec : Long_Integer) return Duration;
-- -- Struct timespec to Duration conversion
--
-- procedure To_Struct_Timespec
-- (D : Duration;
-- tv_sec : out Long_Integer;
-- tv_nsec : out Long_Integer);
-- -- Duration to struct timespec conversion
--
- procedure To_Struct_Tm
- (T : Time;
- tm_year : out Integer;
---
-2.39.2
-
diff --git a/debian/patches/0003-Ada-remove-conversions-with-C-time_t-from-System.OS_.diff b/debian/patches/0003-Ada-remove-conversions-with-C-time_t-from-System.OS_.diff
deleted file mode 100644
index 57b73ba8..00000000
--- a/debian/patches/0003-Ada-remove-conversions-with-C-time_t-from-System.OS_.diff
+++ /dev/null
@@ -1,79 +0,0 @@
-From 3e2838d416c7dbe4100625302a899a5b0194e8b6 Mon Sep 17 00:00:00 2001
-From: Nicolas Boulenguez <nicolas.boulenguez@free.fr>
-Date: Sat, 13 Apr 2024 19:31:25 +0200
-Subject: [PATCH 3/9] Ada: remove conversions with C time_t from System.OS_Lib
-
-Only one conversion is used by Ada.Calendar, and it is unrelated with
-the C time_t type.
----
- gcc/ada/libgnat/s-os_lib.adb | 11 +----------
- gcc/ada/libgnat/s-os_lib.ads | 17 +----------------
- 2 files changed, 2 insertions(+), 26 deletions(-)
-
-diff --git a/src/gcc/ada/libgnat/s-os_lib.adb b/src/gcc/ada/libgnat/s-os_lib.adb
-index 20e109a..976d39c 100644
---- a/src/gcc/ada/libgnat/s-os_lib.adb
-+++ b/src/gcc/ada/libgnat/s-os_lib.adb
-@@ -2980,7 +2980,7 @@ package body System.OS_Lib is
- -- To_Ada --
- ------------
-
-- function To_Ada (Time : time_t) return OS_Time is
-+ function To_Ada (Time : Long_Long_Integer) return OS_Time is
- begin
- return OS_Time (Time);
- end To_Ada;
-@@ -3014,15 +3014,6 @@ package body System.OS_Lib is
- return Return_Val;
- end To_Path_String_Access;
-
-- ----------
-- -- To_C --
-- ----------
--
-- function To_C (Time : OS_Time) return time_t is
-- begin
-- return time_t (Time);
-- end To_C;
--
- ------------------
- -- Wait_Process --
- ------------------
-diff --git a/src/gcc/ada/libgnat/s-os_lib.ads b/src/gcc/ada/libgnat/s-os_lib.ads
-index 46e11f7..c69e357 100644
---- a/src/gcc/ada/libgnat/s-os_lib.ads
-+++ b/src/gcc/ada/libgnat/s-os_lib.ads
-@@ -165,21 +165,7 @@ package System.OS_Lib is
- -- Time_t Stuff --
- ------------------
-
-- -- Note: Do not use time_t in the compiler and host-based tools; instead
-- -- use OS_Time.
--
-- subtype time_t is Long_Long_Integer;
-- -- C time_t can be either long or long long, so we choose the Ada
-- -- equivalent of the latter because eventually that will be the
-- -- type used out of necessity. This may affect some user code on 32-bit
-- -- targets that have not yet migrated to the Posix 2008 standard,
-- -- particularly pre version 5 32-bit Linux. Do not change this
-- -- declaration without coordinating it with conversions in Ada.Calendar.
--
-- function To_C (Time : OS_Time) return time_t;
-- -- Convert OS_Time to C time_t type
--
-- function To_Ada (Time : time_t) return OS_Time;
-+ function To_Ada (Time : Long_Long_Integer) return OS_Time;
- -- Convert C time_t type to OS_Time
-
- ----------------
-@@ -1119,7 +1105,6 @@ private
- pragma Import (Intrinsic, ">");
- pragma Import (Intrinsic, "<=");
- pragma Import (Intrinsic, ">=");
-- pragma Inline (To_C);
- pragma Inline (To_Ada);
-
- type Process_Id is new Integer;
---
-2.39.2
-
diff --git a/debian/patches/0004-Ada-merge-all-timeval-and-timespec-definitions-and-c.diff b/debian/patches/0004-Ada-merge-all-timeval-and-timespec-definitions-and-c.diff
index b1744f6b..c5e02410 100644
--- a/debian/patches/0004-Ada-merge-all-timeval-and-timespec-definitions-and-c.diff
+++ b/debian/patches/0004-Ada-merge-all-timeval-and-timespec-definitions-and-c.diff
@@ -1,8 +1,8 @@
-From 517d53475e2c46ed0593791c6cb02842a53c410f Mon Sep 17 00:00:00 2001
-From: Nicolas Boulenguez <nicolas.boulenguez@free.fr>
+From 405868861a4b2b0f1b4272f312131ec9a4906ef4 Mon Sep 17 00:00:00 2001
+From: Nicolas Boulenguez <nicolas@debian.org>
Date: Tue, 23 Apr 2024 08:37:43 +0200
-Subject: [PATCH 4/9] Ada: merge all timeval and timespec definitions and
- conversions
+Subject: [PATCH 1/8] Ada: merge all timeval and timespec definitions and
+ conversions [PR114065]
Add a new System.C_Time unit in libgnat,
* not in libgnarl like OS_Interface,
@@ -11,24 +11,37 @@ Add a new System.C_Time unit in libgnat,
OS_Primitives is a candidate, but has several variants
and would cause duplication again.
+Merge all conversions to and from Duration and remove the wrappers in
+cal.c using long long int as an intermediate 64 bits type.
+
The System.OS_Interface specification for Android now forbids a body.
-Remove lots of variants of the conversion functions with Duration.
-Remove the C wrapper using long long int as an intermediate 64 bits type.
+In System.OS_Interface for Darwin and System.OS_Primitives for
+POSIX/RTEMS/X32, replace intermediate Durations with direct integer
+conversions, preventing some avoidable roundings (when Duration'Size =
+32) or overflows (when time_t'Size = 64).
+
+Remove the non portable conversions based on long int from the private
+part of a-calend.ads but keep them in Ada.Calendar.Conversions and
+GNAT.Calendar for backward compatibility.
+
+In s-oscons-tmplt.c, add sizeof(timespec.tv_nsec) because it is not
+always a long int.
+
+In the new System.C_Time:
+Fix some versions for D = 0.0.
When Duration'Size = 32 bits
* round correctly in both variants of To_Duration.
* prevent an overflow in To_Duration when nsec = 999_999_999.
* prevent an overflow in To_Timespec without intermediate 64 bits.
-
-Provide direct conversions for System.OS_Interface (Darwin) and
-GNAt.Sockets.Poll.G_Wait, replacing an intermediate Duration that may
-loose overflow or loose precision.
-
-Provide a test checking if a timeval value can be converted to
+Provide a way to check if a timeval value can be represented as
Duration for GNAT.Sockets.
+
+PR ada/114065
+Signed-off-by: Nicolas Boulenguez <nicolas@debian.org>
---
gcc/ada/Makefile.rtl | 4 +-
- gcc/ada/cal.c | 74 --------
+ gcc/ada/cal.c | 74 -------
gcc/ada/gcc-interface/Makefile.in | 1 -
gcc/ada/libgnarl/a-exetim__posix.adb | 7 +-
gcc/ada/libgnarl/s-linux.ads | 17 --
@@ -36,65 +49,71 @@ Duration for GNAT.Sockets.
gcc/ada/libgnarl/s-linux__android.ads | 17 --
gcc/ada/libgnarl/s-linux__hppa.ads | 17 --
gcc/ada/libgnarl/s-linux__loongarch.ads | 18 --
- gcc/ada/libgnarl/s-linux__mips.ads | 22 +--
- gcc/ada/libgnarl/s-linux__riscv.ads | 22 +--
+ gcc/ada/libgnarl/s-linux__mips.ads | 22 +-
+ gcc/ada/libgnarl/s-linux__riscv.ads | 22 +-
gcc/ada/libgnarl/s-linux__sparc.ads | 17 --
gcc/ada/libgnarl/s-linux__x32.ads | 19 --
- gcc/ada/libgnarl/s-osinte__aix.adb | 32 ----
+ gcc/ada/libgnarl/s-osinte__aix.adb | 32 ---
gcc/ada/libgnarl/s-osinte__aix.ads | 25 +--
- gcc/ada/libgnarl/s-osinte__android.adb | 74 --------
+ gcc/ada/libgnarl/s-osinte__android.adb | 74 -------
gcc/ada/libgnarl/s-osinte__android.ads | 25 +--
- gcc/ada/libgnarl/s-osinte__darwin.adb | 61 +------
+ gcc/ada/libgnarl/s-osinte__darwin.adb | 61 +-----
gcc/ada/libgnarl/s-osinte__darwin.ads | 25 +--
- gcc/ada/libgnarl/s-osinte__dragonfly.adb | 33 ----
+ gcc/ada/libgnarl/s-osinte__dragonfly.adb | 33 ---
gcc/ada/libgnarl/s-osinte__dragonfly.ads | 27 +--
- gcc/ada/libgnarl/s-osinte__freebsd.adb | 32 ----
+ gcc/ada/libgnarl/s-osinte__freebsd.adb | 32 ---
gcc/ada/libgnarl/s-osinte__freebsd.ads | 27 +--
- gcc/ada/libgnarl/s-osinte__gnu.adb | 33 ----
+ gcc/ada/libgnarl/s-osinte__gnu.adb | 33 ---
gcc/ada/libgnarl/s-osinte__gnu.ads | 27 +--
- gcc/ada/libgnarl/s-osinte__hpux-dce.adb | 36 +---
+ gcc/ada/libgnarl/s-osinte__hpux-dce.adb | 36 +--
gcc/ada/libgnarl/s-osinte__hpux-dce.ads | 25 +--
gcc/ada/libgnarl/s-osinte__hpux.ads | 25 +--
gcc/ada/libgnarl/s-osinte__kfreebsd-gnu.ads | 27 +--
gcc/ada/libgnarl/s-osinte__linux.ads | 18 +-
- gcc/ada/libgnarl/s-osinte__lynxos178.adb | 32 ----
- gcc/ada/libgnarl/s-osinte__lynxos178e.ads | 35 +---
- gcc/ada/libgnarl/s-osinte__posix.adb | 33 ----
- gcc/ada/libgnarl/s-osinte__qnx.adb | 33 ----
+ gcc/ada/libgnarl/s-osinte__lynxos178.adb | 32 ---
+ gcc/ada/libgnarl/s-osinte__lynxos178e.ads | 35 +--
+ gcc/ada/libgnarl/s-osinte__posix.adb | 33 ---
+ gcc/ada/libgnarl/s-osinte__qnx.adb | 33 ---
gcc/ada/libgnarl/s-osinte__qnx.ads | 25 +--
- gcc/ada/libgnarl/s-osinte__rtems.adb | 30 ----
+ gcc/ada/libgnarl/s-osinte__rtems.adb | 30 ---
gcc/ada/libgnarl/s-osinte__rtems.ads | 29 +--
- gcc/ada/libgnarl/s-osinte__solaris.adb | 34 ----
+ gcc/ada/libgnarl/s-osinte__solaris.adb | 34 ---
gcc/ada/libgnarl/s-osinte__solaris.ads | 25 +--
- gcc/ada/libgnarl/s-osinte__vxworks.adb | 32 ----
+ gcc/ada/libgnarl/s-osinte__vxworks.adb | 32 ---
gcc/ada/libgnarl/s-osinte__vxworks.ads | 28 +--
- gcc/ada/libgnarl/s-osinte__x32.adb | 33 ----
+ gcc/ada/libgnarl/s-osinte__x32.adb | 33 ---
gcc/ada/libgnarl/s-qnx.ads | 17 --
gcc/ada/libgnarl/s-taprop__hpux-dce.adb | 13 +-
gcc/ada/libgnarl/s-taprop__solaris.adb | 17 +-
gcc/ada/libgnarl/s-taprop__vxworks.adb | 5 +-
gcc/ada/libgnarl/s-tpopmo.adb | 18 +-
- gcc/ada/libgnat/g-socket.adb | 79 +-------
+ gcc/ada/libgnat/a-calcon.adb | 33 ---
+ gcc/ada/libgnat/a-calcon.ads | 23 +-
+ gcc/ada/libgnat/a-calend.adb | 38 ----
+ gcc/ada/libgnat/a-calend.ads | 11 -
+ gcc/ada/libgnat/g-calend.adb | 58 -----
+ gcc/ada/libgnat/g-calend.ads | 26 +--
+ gcc/ada/libgnat/g-socket.adb | 79 +------
gcc/ada/libgnat/g-socthi.adb | 4 +-
gcc/ada/libgnat/g-socthi__vxworks.adb | 4 +-
- gcc/ada/libgnat/g-sothco.ads | 24 +--
+ gcc/ada/libgnat/g-sothco.ads | 24 +-
gcc/ada/libgnat/g-spogwa.adb | 11 +-
- gcc/ada/libgnat/s-c_time.adb | 188 ++++++++++++++++++++
- gcc/ada/libgnat/s-c_time.ads | 112 ++++++++++++
+ gcc/ada/libgnat/s-c_time.adb | 231 ++++++++++++++++++++
+ gcc/ada/libgnat/s-c_time.ads | 128 +++++++++++
gcc/ada/libgnat/s-optide.adb | 6 +-
- gcc/ada/libgnat/s-osprim__darwin.adb | 59 +-----
- gcc/ada/libgnat/s-osprim__posix.adb | 63 +------
- gcc/ada/libgnat/s-osprim__posix2008.adb | 48 +----
- gcc/ada/libgnat/s-osprim__rtems.adb | 71 ++------
+ gcc/ada/libgnat/s-osprim__darwin.adb | 59 +----
+ gcc/ada/libgnat/s-osprim__posix.adb | 63 +-----
+ gcc/ada/libgnat/s-osprim__posix2008.adb | 48 +---
+ gcc/ada/libgnat/s-osprim__rtems.adb | 71 +-----
gcc/ada/libgnat/s-osprim__solaris.adb | 27 +--
gcc/ada/libgnat/s-osprim__unix.adb | 27 +--
- gcc/ada/libgnat/s-osprim__x32.adb | 65 +------
+ gcc/ada/libgnat/s-osprim__x32.adb | 65 +-----
gcc/ada/libgnat/s-parame.ads | 7 -
gcc/ada/libgnat/s-parame__hpux.ads | 7 -
gcc/ada/libgnat/s-parame__posix2008.ads | 8 -
gcc/ada/libgnat/s-parame__vxworks.ads | 15 --
- gcc/ada/s-oscons-tmplt.c | 15 +-
- 67 files changed, 507 insertions(+), 1576 deletions(-)
+ gcc/ada/s-oscons-tmplt.c | 11 +
+ 73 files changed, 586 insertions(+), 1741 deletions(-)
delete mode 100644 gcc/ada/cal.c
delete mode 100644 gcc/ada/libgnarl/s-osinte__android.adb
create mode 100644 gcc/ada/libgnat/s-c_time.adb
@@ -818,7 +837,7 @@ index 4670807..0000000
-
-end System.OS_Interface;
diff --git a/src/gcc/ada/libgnarl/s-osinte__android.ads b/src/gcc/ada/libgnarl/s-osinte__android.ads
-index ca35aab..ee3a5dc 100644
+index ca35aab..ecf4a32 100644
--- a/src/gcc/ada/libgnarl/s-osinte__android.ads
+++ b/src/gcc/ada/libgnarl/s-osinte__android.ads
@@ -40,9 +40,9 @@
@@ -842,7 +861,7 @@ index ca35aab..ee3a5dc 100644
function clock_gettime
- (clock_id : clockid_t; tp : access timespec) return int;
-+ (clock_id : clockid_t; tp : access C_time.timespec) return int;
++ (clock_id : clockid_t; tp : access C_Time.timespec) return int;
pragma Import (C, clock_gettime, "clock_gettime");
function clock_getres
@@ -2731,6 +2750,290 @@ index a38f9f4..7fb0dea 100644
Inner : loop
exit Outer
+diff --git a/src/gcc/ada/libgnat/a-calcon.adb b/src/gcc/ada/libgnat/a-calcon.adb
+index 8654d1e..3c5ec21 100644
+--- a/src/gcc/ada/libgnat/a-calcon.adb
++++ b/src/gcc/ada/libgnat/a-calcon.adb
+@@ -69,39 +69,6 @@ package body Ada.Calendar.Conversions is
+ (Year, Month, Day, Hour, Minute, Second, DST);
+ end To_Ada_Time;
+
+- -----------------
+- -- To_Duration --
+- -----------------
+-
+- function To_Duration
+- (tv_sec : long;
+- tv_nsec : long) return Duration
+- is
+- Secs : constant Long_Integer := Long_Integer (tv_sec);
+- Nano_Secs : constant Long_Integer := Long_Integer (tv_nsec);
+- begin
+- return Conversion_Operations.To_Duration (Secs, Nano_Secs);
+- end To_Duration;
+-
+- ------------------------
+- -- To_Struct_Timespec --
+- ------------------------
+-
+- procedure To_Struct_Timespec
+- (D : Duration;
+- tv_sec : out long;
+- tv_nsec : out long)
+- is
+- Secs : Long_Integer;
+- Nano_Secs : Long_Integer;
+-
+- begin
+- Conversion_Operations.To_Struct_Timespec (D, Secs, Nano_Secs);
+-
+- tv_sec := long (Secs);
+- tv_nsec := long (Nano_Secs);
+- end To_Struct_Timespec;
+-
+ ------------------
+ -- To_Struct_Tm --
+ ------------------
+diff --git a/src/gcc/ada/libgnat/a-calcon.ads b/src/gcc/ada/libgnat/a-calcon.ads
+index 97df2a9..196028e 100644
+--- a/src/gcc/ada/libgnat/a-calcon.ads
++++ b/src/gcc/ada/libgnat/a-calcon.ads
+@@ -33,6 +33,7 @@
+ -- time models - Time, Duration, struct tm and struct timespec.
+
+ with Interfaces.C;
++with System.C_Time;
+
+ package Ada.Calendar.Conversions is
+
+@@ -68,20 +69,18 @@ package Ada.Calendar.Conversions is
+ -- and the instance in time is not a leap second occurrence.
+
+ function To_Duration
+- (tv_sec : Interfaces.C.long;
+- tv_nsec : Interfaces.C.long) return Duration;
+- -- Convert an elapsed time value expressed in Unix-like fields of struct
+- -- timespec into a Duration value. The expected ranges are:
+-
+- -- tv_sec - seconds
+- -- tv_nsec - nanoseconds
++ (tv_sec : System.C_Time.Tv_Sec_Long;
++ tv_nsec : System.C_Time.Tv_Nsec_Long)
++ return System.C_Time.Non_Negative_Duration
++ renames System.C_Time.To_Duration;
++ -- Deprecated. Please use C_Time directly.
+
+ procedure To_Struct_Timespec
+- (D : Duration;
+- tv_sec : out Interfaces.C.long;
+- tv_nsec : out Interfaces.C.long);
+- -- Convert a Duration value into the constituents of struct timespec.
+- -- Formal tv_sec denotes seconds and tv_nsecs denotes nanoseconds.
++ (D : System.C_Time.Non_Negative_Duration;
++ tv_sec : out System.C_Time.Tv_Sec_Long;
++ tv_nsec : out System.C_Time.Tv_Nsec_Long)
++ renames System.C_Time.To_Struct_Timespec;
++ -- Deprecated. Please use C_Time directly.
+
+ procedure To_Struct_Tm
+ (T : Time;
+diff --git a/src/gcc/ada/libgnat/a-calend.adb b/src/gcc/ada/libgnat/a-calend.adb
+index 1083ece..06946a5 100644
+--- a/src/gcc/ada/libgnat/a-calend.adb
++++ b/src/gcc/ada/libgnat/a-calend.adb
+@@ -990,44 +990,6 @@ is
+ raise Time_Error;
+ end To_Ada_Time;
+
+- -----------------
+- -- To_Duration --
+- -----------------
+-
+- function To_Duration
+- (tv_sec : Long_Integer;
+- tv_nsec : Long_Integer) return Duration
+- is
+- pragma Unsuppress (Overflow_Check);
+- begin
+- return Duration (tv_sec) + Duration (tv_nsec) / Nano_F;
+- end To_Duration;
+-
+- ------------------------
+- -- To_Struct_Timespec --
+- ------------------------
+-
+- procedure To_Struct_Timespec
+- (D : Duration;
+- tv_sec : out Long_Integer;
+- 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_Integer (Secs);
+-
+- -- Nanoseconds extraction
+-
+- Nano_Secs := D - Duration (tv_sec);
+- tv_nsec := Long_Integer (Nano_Secs * Nano);
+- end To_Struct_Timespec;
+-
+ ------------------
+ -- To_Struct_Tm --
+ ------------------
+diff --git a/src/gcc/ada/libgnat/a-calend.ads b/src/gcc/ada/libgnat/a-calend.ads
+index 9625f4d..cfffc70 100644
+--- a/src/gcc/ada/libgnat/a-calend.ads
++++ b/src/gcc/ada/libgnat/a-calend.ads
+@@ -303,17 +303,6 @@ private
+ tm_isdst : Integer) return Time;
+ -- Struct tm to Ada Epoch conversion
+
+- function To_Duration
+- (tv_sec : Long_Integer;
+- tv_nsec : Long_Integer) return Duration;
+- -- Struct timespec to Duration conversion
+-
+- procedure To_Struct_Timespec
+- (D : Duration;
+- tv_sec : out Long_Integer;
+- tv_nsec : out Long_Integer);
+- -- Duration to struct timespec conversion
+-
+ procedure To_Struct_Tm
+ (T : Time;
+ tm_year : out Integer;
+diff --git a/src/gcc/ada/libgnat/g-calend.adb b/src/gcc/ada/libgnat/g-calend.adb
+index 0a98eb2..e0d34f5 100644
+--- a/src/gcc/ada/libgnat/g-calend.adb
++++ b/src/gcc/ada/libgnat/g-calend.adb
+@@ -29,11 +29,8 @@
+ -- --
+ ------------------------------------------------------------------------------
+
+-with Interfaces.C.Extensions;
+-
+ package body GNAT.Calendar is
+ use Ada.Calendar;
+- use Interfaces;
+
+ -----------------
+ -- Day_In_Year --
+@@ -328,61 +325,6 @@ package body GNAT.Calendar is
+ Time_Zone => 0);
+ end Time_Of_At_Locale;
+
+- -----------------
+- -- To_Duration --
+- -----------------
+-
+- function To_Duration (T : not null access timeval) return Duration is
+-
+- procedure timeval_to_duration
+- (T : not null access timeval;
+- sec : not null access C.Extensions.long_long;
+- usec : not null access C.long);
+- pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
+-
+- Micro : constant := 10**6;
+- sec : aliased C.Extensions.long_long;
+- usec : aliased C.long;
+-
+- begin
+- timeval_to_duration (T, sec'Access, usec'Access);
+- pragma Annotate (CodePeer, Modified, sec);
+- pragma Annotate (CodePeer, Modified, usec);
+-
+- return Duration (sec) + Duration (usec) / Micro;
+- end To_Duration;
+-
+- ----------------
+- -- To_Timeval --
+- ----------------
+-
+- function To_Timeval (D : Duration) return timeval is
+-
+- procedure duration_to_timeval
+- (Sec : C.Extensions.long_long;
+- Usec : C.long;
+- T : not null access timeval);
+- pragma Import (C, duration_to_timeval, "__gnat_duration_to_timeval");
+-
+- Micro : constant := 10**6;
+- Result : aliased timeval;
+- sec : C.Extensions.long_long;
+- usec : C.long;
+-
+- begin
+- if D = 0.0 then
+- sec := 0;
+- usec := 0;
+- else
+- sec := C.Extensions.long_long (D - 0.5);
+- usec := C.long ((D - Duration (sec)) * Micro - 0.5);
+- end if;
+-
+- duration_to_timeval (sec, usec, Result'Access);
+-
+- return Result;
+- end To_Timeval;
+-
+ ------------------
+ -- Week_In_Year --
+ ------------------
+diff --git a/src/gcc/ada/libgnat/g-calend.ads b/src/gcc/ada/libgnat/g-calend.ads
+index b9dd15d..7791943 100644
+--- a/src/gcc/ada/libgnat/g-calend.ads
++++ b/src/gcc/ada/libgnat/g-calend.ads
+@@ -40,7 +40,7 @@
+ -- Day_Of_Week, Day_In_Year and Week_In_Year.
+
+ with Ada.Calendar.Formatting;
+-with Interfaces.C;
++with System.C_Time;
+
+ package GNAT.Calendar is
+
+@@ -145,24 +145,20 @@ package GNAT.Calendar is
+ -- Return the week number as defined in ISO 8601 along with the year in
+ -- which the week occurs.
+
+- -- C timeval conversion
++ subtype timeval is System.C_Time.timeval;
++ -- Deprecated. Please use C_Time directly.
+
+- -- C timeval represent a duration (used in Select for example). This
+- -- structure is composed of a number of seconds and a number of micro
+- -- seconds. The timeval structure is not exposed here because its
+- -- definition is target dependent. Interface to C programs is done via a
+- -- pointer to timeval structure.
++ function To_Duration (T : not null access timeval)
++ return System.C_Time.Non_Negative_Duration
++ with Inline
++ is (System.C_Time.To_Duration (T.all));
++ -- Deprecated. Please use C_Time directly.
+
+- type timeval is private;
+-
+- function To_Duration (T : not null access timeval) return Duration;
+- function To_Timeval (D : Duration) return timeval;
++ function To_Timeval (D : System.C_Time.Non_Negative_Duration) return timeval
++ renames System.C_Time.To_Timeval;
++ -- Deprecated. Please use C_Time directly.
+
+ private
+- -- This is a dummy declaration that should be the largest possible timeval
+- -- structure of all supported targets.
+-
+- type timeval is array (1 .. 3) of Interfaces.C.long;
+
+ function Julian_Day
+ (Year : Ada.Calendar.Year_Number;
diff --git a/src/gcc/ada/libgnat/g-socket.adb b/src/gcc/ada/libgnat/g-socket.adb
index e2f91b3..02c2bab 100644
--- a/src/gcc/ada/libgnat/g-socket.adb
@@ -3016,10 +3319,10 @@ index c16674e..530a6cd 100644
Reset_Socket_Set (Rfds);
diff --git a/src/gcc/ada/libgnat/s-c_time.adb b/src/gcc/ada/libgnat/s-c_time.adb
new file mode 100644
-index 0000000..9f862ec
+index 0000000..d44727c
--- /dev/null
+++ b/src/gcc/ada/libgnat/s-c_time.adb
-@@ -0,0 +1,188 @@
+@@ -0,0 +1,231 @@
+------------------------------------------------------------------------------
+-- --
+-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
@@ -3058,6 +3361,9 @@ index 0000000..9f862ec
+ -- 32 0.02 42_949_672.94
+ -- 64 0.000_000_001 9_223_372_036.854_775_807
+
++ -- The overflows listed in comments must raise Constraint_Error.
++ pragma Unsuppress (Overflow_Check);
++
+ -----------------
+ -- In_Duration --
+ -----------------
@@ -3094,57 +3400,86 @@ index 0000000..9f862ec
+ -- Milliseconds_To_Timeval --
+ -----------------------------
+
-+ function Milliseconds_To_Timeval (M : Interfaces.C.int) return timeval is
++ function Milliseconds_To_Timeval (M : Non_Negative_Int) return timeval is
+ use Interfaces.C;
+ Q : constant int range 0 .. int'Last / 1_000 := M / 1_000;
+ R : constant int range 0 .. 999 := M mod 1_000;
+ begin
+ return (tv_sec => time_t (Q),
-+ tv_usec => 1_000 * suseconds_t (R));
++ tv_usec => 1_000 * usec_t (R));
+ end Milliseconds_To_Timeval;
+
+ -----------------------------
+ -- Nanoseconds_To_Timespec --
+ -----------------------------
+
-+ function Nanoseconds_To_Timespec (N : Interfaces.C.int) return timespec is
++ function Nanoseconds_To_Timespec (N : Non_Negative_Int) return timespec is
+ use Interfaces.C;
+ Q : constant int range 0 .. int'Last / 10**9 := N / 10**9;
+ R : constant int range 0 .. 999_999_999 := N mod 10**9;
+ begin
-+ return (tv_sec => time_t (Q),
-+ tv_nsec => snseconds_t (R));
++ return (tv_sec => time_t (Q),
++ tv_nsec => nsec_t (R));
+ end Nanoseconds_To_Timespec;
+
+ -----------------
+ -- To_Duration --
+ -----------------
+
-+ function To_Duration (T : timeval) return Duration is
++ function To_Duration (T : timeval) return Non_Negative_Duration is
++ Usec : usec_t range 0 .. 1_009_999;
+ Frac : Duration range 0.0 .. 1.0;
+ begin
+ if Duration'Size = 64 then
-+ Frac := Duration (T.tv_usec) / 1_000_000;
++ Usec := T.tv_usec;
+ else
-+ -- Fix the rounding (999_999.0 / 1_000_000 = 0.98).
-+ Frac := Duration (T.tv_usec + 10_000) / 1_000_000;
++ -- Fix the rounding (999_999.0 / 1_000_000 = 0.98)
++ -- with a bias of half Duration'Small = 10 ms.
++ Usec := T.tv_usec + 10_000;
+ end if;
++ Frac := Duration (Usec) / 1_000_000;
++
+ return Duration (T.tv_sec) + Frac;
++ -- Both the conversion and the addition may overflow.
+ end To_Duration;
+
-+ function To_Duration (T : timespec) return Duration is
++ function To_Duration (T : timespec) return Non_Negative_Duration is
+ Frac : Duration range 0.0 .. 1.0;
+ begin
+ if Duration'Size = 64 then
+ Frac := Duration (T.tv_nsec) / 1_000_000_000;
+ else
+ -- Avoid an overflow (Duration'Last < 999_999_999).
-+ -- Fix the rounding (999_999_999.0 / 1_000_000_000 = 0.98).
++ -- Fix the rounding (999_999_999.0 / 1_000_000_000 = 0.98)
++ -- with a bias of half Duration'Small = 10 ms.
+ Frac := Duration (T.tv_nsec / 10_000_000 + 1) / 100;
+ end if;
++
+ return Duration (T.tv_sec) + Frac;
++ -- Both the conversion and the addition may overflow.
+ end To_Duration;
+
++ function To_Duration (tv_sec : Tv_Sec_Long;
++ tv_nsec : Tv_Nsec_Long)
++ return Non_Negative_Duration is
++ begin
++ return To_Duration (timespec'(tv_sec => time_t (tv_sec),
++ tv_nsec => nsec_t (tv_nsec)));
++ end To_Duration;
++
++ ------------------------
++ -- To_Struct_Timespec --
++ ------------------------
++
++ procedure To_Struct_Timespec (D : Non_Negative_Duration;
++ tv_sec : out Tv_Sec_Long;
++ tv_nsec : out Tv_Nsec_Long) is
++ T : constant timespec := To_Timespec (D);
++ begin
++ tv_sec := Tv_Sec_Long (T.tv_sec); -- May overflow Interfaces.C.long.
++ tv_nsec := Tv_Nsec_Long (T.tv_nsec);
++ end To_Struct_Timespec;
++
+ -----------------
+ -- To_Timespec --
+ -----------------
@@ -3152,26 +3487,27 @@ index 0000000..9f862ec
+ function To_Timespec (T : timeval) return timespec is
+ begin
+ return (tv_sec => T.tv_sec,
-+ tv_nsec => 1_000 * snseconds_t (T.tv_usec));
++ tv_nsec => 1_000 * nsec_t (T.tv_usec));
+ end To_Timespec;
+
-+ function To_Timespec (D : Duration) return timespec is
++ function To_Timespec (D : Non_Negative_Duration) return timespec is
+ -- See To_Timeval.
+ Dm1 : constant Duration range -1.0 .. Duration'Last - 1.0 := D - 1.0;
+ Sec : constant time_t range -1 .. time_t'Last := time_t (Dm1);
+ Frac : constant Duration range -0.5 .. 0.5 := Dm1 - Duration (Sec);
-+ Nsec : snseconds_t range -500_000_000 .. 500_000_000;
++ Nsec : nsec_t range -500_000_000 .. 500_000_000;
+ begin
+ if Duration'Size = 64 then
-+ Nsec := snseconds_t (1_000_000_000 * Frac);
++ Nsec := nsec_t (1_000_000_000 * Frac);
+ else
-+ -- Avoid an overflow when Duration'Last < 999_999_999.
-+ Nsec := 10_000_000 * snseconds_t (100 * Frac);
++ -- Duration'Last < 500_000_000 so there is an overflow issue,
++ -- easy to solve because Frac has few significative digits.
++ Nsec := 20_000_000 * nsec_t (50 * Frac);
+ end if;
+ if Nsec < 0 then
-+ return (Sec, Nsec + 1_000_000_000);
++ return (tv_sec => Sec, tv_nsec => Nsec + 1_000_000_000);
+ else
-+ return (Sec + 1, Nsec);
++ return (tv_sec => Sec + 1, tv_nsec => Nsec);
+ end if;
+ end To_Timespec;
+
@@ -3179,27 +3515,37 @@ index 0000000..9f862ec
+ -- To_Timeval --
+ -----------------
+
-+ function To_Timeval (D : Duration) return timeval is
++ function To_Timeval (D : Non_Negative_Duration) return timeval is
++
++ -- Most comments also apply to the timespec variant.
+
+ -- Sec := time_t (D);
-+ -- Usec := suseconds_t (1_000_000 * (D - Duration (Sec)));
++ -- Usec := usec_t (1_000_000 * (D - Duration (Sec)));
+ -- fails when D is
+ -- Duration'Last (Sec is rounded up and Duration (Sec) overflows)
+ -- 0.9 (Sec is rounded up and Usec < 0)
+
+ -- Sec := time_t (D - 0.5);
-+ -- Usec := suseconds_t (1_000_000 * (D - Duration (Sec)));
-+ -- fails when D is
-+ -- 0.0 (Sec is rounded down and Usec = 1_000_000)
-+ -- 0.999_999_999 (Usec is rounded up to 1_000_000)
++ -- Usec := usec_t (1_000_000 * (D - Duration (Sec)));
++ -- leads to Usec = 1_000_000 when D is
++ -- 0.0 (Sec is rounded down)
++ -- 0.999_999_999 (Usec is rounded up) (not an issue with timespec)
+
-+ -- Converting D - 1 seems to solve overflow and simplify roundings.
+ Dm1 : constant Duration range -1.0 .. Duration'Last - 1.0 := D - 1.0;
++ -- Converting D - 1 avoids overflows and simplifies roundings.
++
+ Sec : constant time_t range -1 .. time_t'Last := time_t (Dm1);
++ -- The conversion of Dm1 may overflow if time_t has 32 bits.
++
+ Frac : constant Duration range -0.5 .. 0.5 := Dm1 - Duration (Sec);
-+ Usec : constant suseconds_t range -500_000 .. 500_000
-+ := suseconds_t (1_000_000 * Frac);
++ -- The conversion back is always possible, Sec <= Duration'Last - 0.5.
++
++ Usec : constant usec_t range -500_000 .. 500_000
++ := usec_t (1_000_000 * Frac);
+ begin
++ -- Add the second substracted at the beginning, in a way fixing
++ -- the Usec interval if necessary.
++ -- In both cases, tv_sec may exceed MAX_tv_sec.
+ if Usec < 0 then
+ return (tv_sec => Sec, tv_usec => Usec + 1_000_000);
+ else
@@ -3210,10 +3556,10 @@ index 0000000..9f862ec
+end System.C_Time;
diff --git a/src/gcc/ada/libgnat/s-c_time.ads b/src/gcc/ada/libgnat/s-c_time.ads
new file mode 100644
-index 0000000..0feabb3
+index 0000000..8eaf22d
--- /dev/null
+++ b/src/gcc/ada/libgnat/s-c_time.ads
-@@ -0,0 +1,112 @@
+@@ -0,0 +1,128 @@
+------------------------------------------------------------------------------
+-- --
+-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
@@ -3252,50 +3598,63 @@ index 0000000..0feabb3
+private with System.OS_Constants;
+
+package System.C_Time
-+ with Preelaborate
++ with Pure
+is
+
-+ type timeval is private; -- Non negative duration in microseconds.
++ -- These C structs represent non negative durations with different
++ -- accuracies and maximal values.
++ type timespec is private; -- accurate to 1 nanosecond
++ type timeval is private; -- accurate to 1 microsecond
+
-+ Timeval_Zero : constant timeval;
-+ -- g-sothco.ads
++ -- Duration is accurate to either 1 nanosecond or 20 milliseconds.
++ subtype Non_Negative_Duration is Duration range 0.0 .. Duration'Last;
+
-+ function To_Timeval (D : Duration) return timeval
-+ with Pre => 0.0 <= D;
-+ -- The value is rounded if Duration'Size = 64.
++ -- All conversions round if the target type is less accurate than
++ -- the source type, away from zero if the source value is midway
++ -- between two values of the target type.
++ -- They raise Constraint_Error when the value, after rounding,
++ -- exceeds the last value of the target type.
+
-+ function In_Duration (T : timeval) return Boolean
-+ with Inline;
-+ -- True if computing To_Duration (T) is safe,
-+ -- False if Constraint Error would be raised.
++ function To_Duration (T : timespec) return Non_Negative_Duration;
++ function To_Duration (T : timeval) return Non_Negative_Duration;
+
-+ function To_Duration (T : timeval) return Duration
-+ with Post => 0.0 <= To_Duration'Result;
-+ -- The value is rounded if Duration'Size = 32.
++ function To_Timespec (D : Non_Negative_Duration) return timespec;
++ function To_Timeval (D : Non_Negative_Duration) return timeval;
+
-+ type timespec is private; -- Non negative duration in nanoseconds.
++ Timeval_Zero : constant timeval;
++ -- g-sothco.ads
+
-+ function To_Timespec (D : Duration) return timespec
-+ with Pre => 0.0 <= D;
++ function In_Duration (T : timeval) return Boolean with Inline;
++ -- True if computing To_Duration (T) is safe,
++ -- False if Constraint Error would be raised.
++ -- g-socket.adb:
+
-+ function To_Duration (T : timespec) return Duration
-+ with Post => 0.0 <= To_Duration'Result;
-+ -- The value is rounded if Duration'Size = 32.
++ subtype Non_Negative_Int is
++ Interfaces.C.int range 0 .. Interfaces.C.int'Last;
+
-+ -- Direct conversions avoiding an intermediate Duration that may
-+ -- loose precision (when Duration'Size = 32) or overflow (when
-+ -- time_t'Size = 64).
++ function Milliseconds_To_Timeval (M : Non_Negative_Int) return timeval
++ with Inline;
++ -- g-spogwa.adb
+
-+ function Milliseconds_To_Timeval (M : Interfaces.C.int) return timeval
-+ with Inline,
-+ Pre => Interfaces.C."<=" (0, M);
++ function Nanoseconds_To_Timespec (N : Non_Negative_Int) return timespec
++ with Inline;
++ function To_Timespec (T : timeval) return timespec with Inline;
++ -- s-osinte__darwin.adb
+
-+ function Nanoseconds_To_Timespec (N : Interfaces.C.int) return timespec
-+ with Inline,
-+ Pre => Interfaces.C."<=" (0, N);
++ -- These functions are provided for backward compatibility,
++ -- but lead to non portable interfaces with C.
++ -- Tv_sec and tv_nsec do not match the long int type on x32,
++ -- or on 32 bits ARM with a 2038-compatible GNU libc.
+
-+ function To_Timespec (T : timeval) return timespec
++ subtype Tv_Sec_Long is Interfaces.C.long range 0 .. Interfaces.C.long'Last;
++ subtype Tv_Nsec_Long is Interfaces.C.long range 0 .. 999_999_999;
++ function To_Duration (tv_sec : Tv_Sec_Long;
++ tv_nsec : Tv_Nsec_Long) return Non_Negative_Duration
+ with Inline;
++ procedure To_Struct_Timespec (D : Non_Negative_Duration;
++ tv_sec : out Tv_Sec_Long;
++ tv_nsec : out Tv_Nsec_Long) with Inline;
++ -- a-calcon.ads
+
+private
+
@@ -3303,23 +3662,26 @@ index 0000000..0feabb3
+ 2 ** (OS_Constants.SIZEOF_tv_sec * 8 - 1) - 1
+ with Convention => C, Size => OS_Constants.SIZEOF_tv_sec * 8;
+
-+ type suseconds_t is range -2 ** (OS_Constants.SIZEOF_tv_usec * 8 - 1) ..
-+ 2 ** (OS_Constants.SIZEOF_tv_usec * 8 - 1) - 1
++ type usec_t is range -2 ** (OS_Constants.SIZEOF_tv_usec * 8 - 1) ..
++ 2 ** (OS_Constants.SIZEOF_tv_usec * 8 - 1) - 1
+ with Convention => C, Size => OS_Constants.SIZEOF_tv_usec * 8;
++ -- Larger than the suseconds_t C type on ARM 32 bits with GNU libc
++ -- when __TIME_BITS=64.
+
-+ type snseconds_t is range -2 ** (OS_Constants.SIZEOF_tv_nsec * 8 - 1) ..
-+ 2 ** (OS_Constants.SIZEOF_tv_nsec * 8 - 1) - 1
++ type nsec_t is range -2 ** (OS_Constants.SIZEOF_tv_nsec * 8 - 1) ..
++ 2 ** (OS_Constants.SIZEOF_tv_nsec * 8 - 1) - 1
+ with Convention => C, Size => OS_Constants.SIZEOF_tv_nsec * 8;
++ -- Larger than the signed long int C type on x32.
+
+ type timeval is record
-+ tv_sec : time_t range 0 .. OS_Constants.MAX_tv_sec; -- seconds
-+ tv_usec : suseconds_t range 0 .. 999_999; -- microseconds
++ tv_sec : time_t range 0 .. OS_Constants.MAX_tv_sec; -- seconds
++ tv_usec : usec_t range 0 .. 999_999; -- microseconds
+ end record
+ with Convention => C;
+
+ type timespec is record
-+ tv_sec : time_t range 0 .. OS_Constants.MAX_tv_sec; -- seconds
-+ tv_nsec : snseconds_t range 0 .. 999_999_999; -- nanoseconds
++ tv_sec : time_t range 0 .. OS_Constants.MAX_tv_sec; -- seconds
++ tv_nsec : nsec_t range 0 .. 999_999_999; -- nanoseconds
+ end record
+ with Convention => C;
+
@@ -4127,21 +4489,9 @@ index 802357e..d0bcecd 100644
-- Characteristics of types in Interfaces.C --
----------------------------------------------
diff --git a/src/gcc/ada/s-oscons-tmplt.c b/src/gcc/ada/s-oscons-tmplt.c
-index 4e512b9..5beb929 100644
+index 4e512b9..e5dad44 100644
--- a/src/gcc/ada/s-oscons-tmplt.c
+++ b/src/gcc/ada/s-oscons-tmplt.c
-@@ -1740,9 +1740,9 @@ CND(IPV6_V6ONLY, "Restricted to IPv6 communications only")
- -- Sizes (in bytes) of the components of struct timeval
- */
- #define SIZEOF_tv_sec (sizeof tv.tv_sec)
--CND(SIZEOF_tv_sec, "tv_sec")
-+CND(SIZEOF_tv_sec, "tv_sec, time_t")
- #define SIZEOF_tv_usec (sizeof tv.tv_usec)
--CND(SIZEOF_tv_usec, "tv_usec")
-+CND(SIZEOF_tv_usec, "tv_usec, suseconds_t")
- /*
-
- -- Maximum allowed value for tv_sec
@@ -1764,6 +1764,17 @@ CND(SIZEOF_tv_usec, "tv_usec")
#endif
CNS(MAX_tv_sec, "")
@@ -4154,7 +4504,7 @@ index 4e512b9..5beb929 100644
+ -- The tv_sec field is the same than in struct timeval.
+*/
+#define SIZEOF_tv_nsec (sizeof (ts.tv_nsec))
-+CND(SIZEOF_tv_nsec, "tv_nsec, long except on x32");
++CND(SIZEOF_tv_nsec, "tv_nsec");
+}
+
/*
diff --git a/debian/patches/0005-Ada-drop-unneeded-x32-variant-of-System.Linux.diff b/debian/patches/0005-Ada-drop-unneeded-x32-variant-of-System.Linux.diff
deleted file mode 100644
index 2204336d..00000000
--- a/debian/patches/0005-Ada-drop-unneeded-x32-variant-of-System.Linux.diff
+++ /dev/null
@@ -1,146 +0,0 @@
-From 9f073499ba8249a6f510634c7a8c876bd45dc5d9 Mon Sep 17 00:00:00 2001
-From: Nicolas Boulenguez <nicolas.boulenguez@free.fr>
-Date: Mon, 1 Apr 2024 12:20:43 +0200
-Subject: [PATCH 5/9] Ada: drop unneeded x32 variant of System.Linux
-
----
- gcc/ada/Makefile.rtl | 1 -
- gcc/ada/libgnarl/s-linux__x32.ads | 114 ------------------------------
- 2 files changed, 115 deletions(-)
- delete mode 100644 gcc/ada/libgnarl/s-linux__x32.ads
-
-diff --git a/src/gcc/ada/Makefile.rtl b/src/gcc/ada/Makefile.rtl
-index 8b34047..7bcfb81 100644
---- a/src/gcc/ada/Makefile.rtl
-+++ b/src/gcc/ada/Makefile.rtl
-@@ -2618,7 +2618,6 @@ ifeq ($(strip $(filter-out %x32 linux%,$(target_cpu) $(target_os))),)
- a-synbar.ads<libgnarl/a-synbar__posix.ads \
- s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
- s-intman.adb<libgnarl/s-intman__posix.adb \
-- s-linux.ads<libgnarl/s-linux__x32.ads \
- s-mudido.adb<libgnarl/s-mudido__affinity.adb \
- s-osinte.ads<libgnarl/s-osinte__linux.ads \
- s-osinte.adb<libgnarl/s-osinte__x32.adb \
-diff --git a/src/gcc/ada/libgnarl/s-linux__x32.ads b/src/gcc/ada/libgnarl/s-linux__x32.ads
-deleted file mode 100644
-index e586ae0..0000000
---- a/src/gcc/ada/libgnarl/s-linux__x32.ads
-+++ /dev/null
-@@ -1,114 +0,0 @@
--------------------------------------------------------------------------------
---- --
---- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
---- --
---- S Y S T E M . L I N U X --
---- --
---- S p e c --
---- --
---- Copyright (C) 2013-2024, Free Software Foundation, Inc. --
----
---- --
---- GNARL 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- --
---- ware Foundation; either version 3, or (at your option) any later ver- --
---- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
---- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
---- or FITNESS FOR A PARTICULAR PURPOSE. --
---- --
---- As a special exception under Section 7 of GPL version 3, you are granted --
---- additional permissions described in the GCC Runtime Library Exception, --
---- version 3.1, as published by the Free Software Foundation. --
---- --
---- You should have received a copy of the GNU General Public License and --
---- a copy of the GCC Runtime Library Exception along with this program; --
---- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
---- <http://www.gnu.org/licenses/>. --
---- --
---- --
--------------------------------------------------------------------------------
--
---- This is the x32 version of this package
--
---- This package encapsulates cpu specific differences between implementations
---- of GNU/Linux, in order to share s-osinte-linux.ads.
--
---- PLEASE DO NOT add any with-clauses to this package or remove the pragma
---- Preelaborate. This package is designed to be a bottom-level (leaf) package
--
--with Interfaces.C;
--
--package System.Linux is
-- pragma Preelaborate;
--
-- ----------
-- -- Time --
-- ----------
--
-- subtype clockid_t is Interfaces.C.int;
--
-- -----------
-- -- Errno --
-- -----------
--
-- EAGAIN : constant := 11;
-- EINTR : constant := 4;
-- EINVAL : constant := 22;
-- ENOMEM : constant := 12;
-- EPERM : constant := 1;
-- ETIMEDOUT : constant := 110;
--
-- -------------
-- -- Signals --
-- -------------
--
-- SIGHUP : constant := 1; -- hangup
-- SIGINT : constant := 2; -- interrupt (rubout)
-- SIGQUIT : constant := 3; -- quit (ASCD FS)
-- SIGILL : constant := 4; -- illegal instruction (not reset)
-- SIGTRAP : constant := 5; -- trace trap (not reset)
-- SIGIOT : constant := 6; -- IOT instruction
-- SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
-- SIGFPE : constant := 8; -- floating point exception
-- SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
-- SIGBUS : constant := 7; -- bus error
-- SIGUSR1 : constant := 10; -- user defined signal 1
-- SIGSEGV : constant := 11; -- segmentation violation
-- SIGUSR2 : constant := 12; -- user defined signal 2
-- SIGPIPE : constant := 13; -- write on a pipe with no one to read it
-- SIGALRM : constant := 14; -- alarm clock
-- SIGTERM : constant := 15; -- software termination signal from kill
-- SIGSTKFLT : constant := 16; -- coprocessor stack fault (Linux)
-- SIGCLD : constant := 17; -- alias for SIGCHLD
-- SIGCHLD : constant := 17; -- child status change
-- SIGSTOP : constant := 19; -- stop (cannot be caught or ignored)
-- SIGTSTP : constant := 20; -- user stop requested from tty
-- SIGCONT : constant := 18; -- stopped process has been continued
-- SIGTTIN : constant := 21; -- background tty read attempted
-- SIGTTOU : constant := 22; -- background tty write attempted
-- SIGURG : constant := 23; -- urgent condition on IO channel
-- SIGXCPU : constant := 24; -- CPU time limit exceeded
-- SIGXFSZ : constant := 25; -- filesize limit exceeded
-- SIGVTALRM : constant := 26; -- virtual timer expired
-- SIGPROF : constant := 27; -- profiling timer expired
-- SIGWINCH : constant := 28; -- window size change
-- SIGPOLL : constant := 29; -- pollable event occurred
-- SIGIO : constant := 29; -- I/O now possible (4.2 BSD)
-- SIGLOST : constant := 29; -- File lock lost
-- SIGPWR : constant := 30; -- power-fail restart
-- SIGSYS : constant := 31; -- bad system call
-- SIGUNUSED : constant := 31; -- unused signal (mapped to SIGSYS)
-- SIG32 : constant := 32; -- glibc internal signal
-- SIG33 : constant := 33; -- glibc internal signal
-- SIG34 : constant := 34; -- glibc internal signal
--
-- -- struct_sigaction offsets
--
-- sa_handler_pos : constant := 0;
-- sa_mask_pos : constant := Standard'Address_Size / 8;
-- sa_flags_pos : constant := 128 + sa_mask_pos;
--
-- SA_SIGINFO : constant := 16#04#;
-- SA_ONSTACK : constant := 16#08000000#;
--
--end System.Linux;
---
-2.39.2
-
diff --git a/debian/patches/0006-Ada-drop-unneeded-posix2008-variant-of-System.Parame.diff b/debian/patches/0006-Ada-drop-unneeded-posix2008-variant-of-System.Parame.diff
deleted file mode 100644
index 7e208de0..00000000
--- a/debian/patches/0006-Ada-drop-unneeded-posix2008-variant-of-System.Parame.diff
+++ /dev/null
@@ -1,229 +0,0 @@
-From 135d79c7622faf09e1fe6ba8b1ac4f119079e32d Mon Sep 17 00:00:00 2001
-From: Nicolas Boulenguez <nicolas.boulenguez@free.fr>
-Date: Sat, 30 Mar 2024 17:32:51 +0100
-Subject: [PATCH 6/9] Ada: drop unneeded posix2008 variant of System.Parameters
-
----
- gcc/ada/Makefile.rtl | 3 -
- gcc/ada/libgnat/s-parame__posix2008.ads | 181 ------------------------
- 2 files changed, 184 deletions(-)
- delete mode 100644 gcc/ada/libgnat/s-parame__posix2008.ads
-
-diff --git a/src/gcc/ada/Makefile.rtl b/src/gcc/ada/Makefile.rtl
-index 7bcfb81..82d01b2 100644
---- a/src/gcc/ada/Makefile.rtl
-+++ b/src/gcc/ada/Makefile.rtl
-@@ -1955,7 +1955,6 @@ ifeq ($(strip $(filter-out lynxos178%,$(target_os))),)
-
- ifeq ($(strip $(filter-out lynxos178e,$(target_os))),)
- LIBGNAT_TARGET_PAIRS += \
-- s-parame.ads<libgnat/s-parame__posix2008.ads \
- s-osinte.ads<libgnarl/s-osinte__lynxos178e.ads \
- s-osprim.adb<libgnat/s-osprim__posix2008.adb \
- s-tracon.adb<hie/s-tracon__ppc-eabi.adb
-@@ -1976,7 +1975,6 @@ ifeq ($(strip $(filter-out rtems%,$(target_os))),)
- s-osinte.ads<libgnarl/s-osinte__rtems.ads \
- s-osprim.adb<libgnat/s-osprim__rtems.adb \
- s-parame.adb<libgnat/s-parame__rtems.adb \
-- s-parame.ads<libgnat/s-parame__posix2008.ads \
- s-taprop.adb<libgnarl/s-taprop__rtems.adb \
- s-taspri.ads<libgnarl/s-taspri__posix.ads \
- s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
-@@ -2622,7 +2620,6 @@ ifeq ($(strip $(filter-out %x32 linux%,$(target_cpu) $(target_os))),)
- s-osinte.ads<libgnarl/s-osinte__linux.ads \
- s-osinte.adb<libgnarl/s-osinte__x32.adb \
- s-osprim.adb<libgnat/s-osprim__x32.adb \
-- s-parame.ads<libgnat/s-parame__posix2008.ads \
- s-taprop.adb<libgnarl/s-taprop__linux.adb \
- s-tasinf.ads<libgnarl/s-tasinf__linux.ads \
- s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
-diff --git a/src/gcc/ada/libgnat/s-parame__posix2008.ads b/src/gcc/ada/libgnat/s-parame__posix2008.ads
-deleted file mode 100644
-index 5d4cf28..0000000
---- a/src/gcc/ada/libgnat/s-parame__posix2008.ads
-+++ /dev/null
-@@ -1,181 +0,0 @@
--------------------------------------------------------------------------------
---- --
---- GNAT COMPILER COMPONENTS --
---- --
---- S Y S T E M . P A R A M E T E R S --
---- --
---- S p e c --
---- --
---- Copyright (C) 1992-2024, 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- --
---- ware Foundation; either version 3, or (at your option) any later ver- --
---- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
---- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
---- or FITNESS FOR A PARTICULAR PURPOSE. --
---- --
---- As a special exception under Section 7 of GPL version 3, you are granted --
---- additional permissions described in the GCC Runtime Library Exception, --
---- version 3.1, as published by the Free Software Foundation. --
---- --
---- You should have received a copy of the GNU General Public License and --
---- a copy of the GCC Runtime Library Exception along with this program; --
---- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
---- <http://www.gnu.org/licenses/>. --
---- --
---- GNAT was originally developed by the GNAT team at New York University. --
---- Extensive contributions were provided by Ada Core Technologies Inc. --
---- --
--------------------------------------------------------------------------------
--
---- This is the Posix 2008 version for 64 bit time_t.
--
---- This package defines some system dependent parameters for GNAT. These
---- are values that are referenced by the runtime library and are therefore
---- relevant to the target machine.
--
---- The parameters whose value is defined in the spec are not generally
---- expected to be changed. If they are changed, it will be necessary to
---- recompile the run-time library.
--
---- The parameters which are defined by functions can be changed by modifying
---- the body of System.Parameters in file s-parame.adb. A change to this body
---- requires only rebinding and relinking of the application.
--
---- Note: do not introduce any pragma Inline statements into this unit, since
---- otherwise the relinking and rebinding capability would be deactivated.
--
--package System.Parameters is
-- pragma Pure;
--
-- ---------------------------------------
-- -- Task And Stack Allocation Control --
-- ---------------------------------------
--
-- type Size_Type is range -Memory_Size / 2 .. Memory_Size / 2 - 1;
-- -- Type used to provide task stack sizes to the runtime. Sized to permit
-- -- stack sizes of up to half the total addressable memory space. This may
-- -- seem excessively large (even for 32-bit systems), however there are many
-- -- instances of users requiring large stack sizes (for example string
-- -- processing).
--
-- Unspecified_Size : constant Size_Type := Size_Type'First;
-- -- Value used to indicate that no size type is set
--
-- function Default_Stack_Size return Size_Type;
-- -- Default task stack size used if none is specified
--
-- function Minimum_Stack_Size return Size_Type;
-- -- Minimum task stack size permitted
--
-- function Adjust_Storage_Size (Size : Size_Type) return Size_Type;
-- -- Given the storage size stored in the TCB, return the Storage_Size
-- -- value required by the RM for the Storage_Size attribute. The
-- -- required adjustment is as follows:
-- --
-- -- when Size = Unspecified_Size, return Default_Stack_Size
-- -- when Size < Minimum_Stack_Size, return Minimum_Stack_Size
-- -- otherwise return given Size
--
-- Default_Env_Stack_Size : constant Size_Type := 8_192_000;
-- -- Assumed size of the environment task, if no other information is
-- -- available. This value is used when stack checking is enabled and
-- -- no GNAT_STACK_LIMIT environment variable is set.
--
-- Stack_Grows_Down : constant Boolean := True;
-- -- This constant indicates whether the stack grows up (False) or
-- -- down (True) in memory as functions are called. It is used for
-- -- proper implementation of the stack overflow check.
--
-- Runtime_Default_Sec_Stack_Size : constant Size_Type := 10 * 1024;
-- -- The run-time chosen default size for secondary stacks that may be
-- -- overridden by the user with the use of binder -D switch.
--
-- Sec_Stack_Dynamic : constant Boolean := True;
-- -- Indicates if secondary stacks can grow and shrink at run-time. If False,
-- -- the size of a secondary stack is fixed at the point of its creation.
--
-- ----------------------------------------------
-- -- Characteristics of types in Interfaces.C --
-- ----------------------------------------------
--
-- long_bits : constant := Long_Integer'Size;
-- -- Number of bits in type long and unsigned_long. The normal convention
-- -- is that this is the same as type Long_Integer, but this may not be true
-- -- of all targets.
--
-- ptr_bits : constant := Standard'Address_Size;
-- subtype C_Address is System.Address;
-- -- Number of bits in Interfaces.C pointers, normally a standard address
--
-- C_Malloc_Linkname : constant String := "__gnat_malloc";
-- -- Name of runtime function used to allocate such a pointer
--
-- ----------------------------------------------
-- -- Behavior of Pragma Finalize_Storage_Only --
-- ----------------------------------------------
--
-- -- Garbage_Collected is a Boolean constant whose value indicates the
-- -- effect of the pragma Finalize_Storage_Entry on a controlled type.
--
-- -- Garbage_Collected = False
--
-- -- The system releases all storage on program termination only,
-- -- but not other garbage collection occurs, so finalization calls
-- -- are omitted only for outer level objects can be omitted if
-- -- pragma Finalize_Storage_Only is used.
--
-- -- Garbage_Collected = True
--
-- -- The system provides full garbage collection, so it is never
-- -- necessary to release storage for controlled objects for which
-- -- a pragma Finalize_Storage_Only is used.
--
-- Garbage_Collected : constant Boolean := False;
-- -- The storage mode for this system (release on program exit)
--
-- ---------------------
-- -- Tasking Profile --
-- ---------------------
--
-- -- In the following sections, constant parameters are defined to
-- -- allow some optimizations and fine tuning within the tasking run time
-- -- based on restrictions on the tasking features.
--
-- -------------------
-- -- Task Abortion --
-- -------------------
--
-- No_Abort : constant Boolean := False;
-- -- This constant indicates whether abort statements and asynchronous
-- -- transfer of control (ATC) are disallowed. If set to True, it is
-- -- assumed that neither construct is used, and the run time does not
-- -- need to defer/undefer abort and check for pending actions at
-- -- completion points. A value of True for No_Abort corresponds to:
-- -- pragma Restrictions (No_Abort_Statements);
-- -- pragma Restrictions (Max_Asynchronous_Select_Nesting => 0);
--
-- ---------------------
-- -- Task Attributes --
-- ---------------------
--
-- Max_Attribute_Count : constant := 32;
-- -- Number of task attributes stored in the task control block
--
-- -----------------------
-- -- Task Image Length --
-- -----------------------
--
-- Max_Task_Image_Length : constant := 256;
-- -- This constant specifies the maximum length of a task's image
--
-- ------------------------------
-- -- Exception Message Length --
-- ------------------------------
--
-- Default_Exception_Msg_Max_Length : constant := 200;
-- -- This constant specifies the default number of characters to allow
-- -- in an exception message (200 is minimum required by RM 11.4.1(18)).
--
--end System.Parameters;
---
-2.39.2
-
diff --git a/debian/patches/0007-Ada-drop-unneeded-darwin-solaris-x32-variants-of-Sys.diff b/debian/patches/0007-Ada-drop-unneeded-darwin-solaris-x32-variants-of-Sys.diff
deleted file mode 100644
index c325ff0e..00000000
--- a/debian/patches/0007-Ada-drop-unneeded-darwin-solaris-x32-variants-of-Sys.diff
+++ /dev/null
@@ -1,472 +0,0 @@
-From 943270964c66eee60fe3f75659978479ad2d54ae Mon Sep 17 00:00:00 2001
-From: Nicolas Boulenguez <nicolas.boulenguez@free.fr>
-Date: Sun, 21 Apr 2024 19:52:28 +0200
-Subject: [PATCH 7/9] Ada: drop unneeded darwin, solaris, x32 variants of
- System.OS_Primitives
-
----
- gcc/ada/Makefile.rtl | 14 +--
- gcc/ada/libgnat/s-osprim__darwin.adb | 130 --------------------------
- gcc/ada/libgnat/s-osprim__solaris.adb | 115 -----------------------
- gcc/ada/libgnat/s-osprim__x32.adb | 123 ------------------------
- 4 files changed, 7 insertions(+), 375 deletions(-)
- delete mode 100644 gcc/ada/libgnat/s-osprim__darwin.adb
- delete mode 100644 gcc/ada/libgnat/s-osprim__solaris.adb
- delete mode 100644 gcc/ada/libgnat/s-osprim__x32.adb
-
-diff --git a/src/gcc/ada/Makefile.rtl b/src/gcc/ada/Makefile.rtl
-index 82d01b2..1f339f3 100644
---- a/src/gcc/ada/Makefile.rtl
-+++ b/src/gcc/ada/Makefile.rtl
-@@ -1461,7 +1461,7 @@ ifeq ($(strip $(filter-out sparc% sun solaris%,$(target_cpu) $(target_vendor) $(
- s-mudido.adb<libgnarl/s-mudido__affinity.adb \
- s-osinte.adb<libgnarl/s-osinte__solaris.adb \
- s-osinte.ads<libgnarl/s-osinte__solaris.ads \
-- s-osprim.adb<libgnat/s-osprim__solaris.adb \
-+ s-osprim.adb<libgnat/s-osprim__unix.adb \
- s-taprop.adb<libgnarl/s-taprop__solaris.adb \
- s-tasinf.adb<libgnarl/s-tasinf__solaris.adb \
- s-tasinf.ads<libgnarl/s-tasinf__solaris.ads \
-@@ -1504,7 +1504,7 @@ ifeq ($(strip $(filter-out %86 %x86_64 solaris2%,$(target_cpu) $(target_os))),)
- s-mudido.adb<libgnarl/s-mudido__affinity.adb \
- s-osinte.adb<libgnarl/s-osinte__solaris.adb \
- s-osinte.ads<libgnarl/s-osinte__solaris.ads \
-- s-osprim.adb<libgnat/s-osprim__solaris.adb \
-+ s-osprim.adb<libgnat/s-osprim__unix.adb \
- s-taprop.adb<libgnarl/s-taprop__solaris.adb \
- s-tasinf.adb<libgnarl/s-tasinf__solaris.adb \
- s-tasinf.ads<libgnarl/s-tasinf__solaris.ads \
-@@ -2619,7 +2619,7 @@ ifeq ($(strip $(filter-out %x32 linux%,$(target_cpu) $(target_os))),)
- s-mudido.adb<libgnarl/s-mudido__affinity.adb \
- s-osinte.ads<libgnarl/s-osinte__linux.ads \
- s-osinte.adb<libgnarl/s-osinte__x32.adb \
-- s-osprim.adb<libgnat/s-osprim__x32.adb \
-+ s-osprim.adb<libgnat/s-osprim__rtems.adb \
- s-taprop.adb<libgnarl/s-taprop__linux.adb \
- s-tasinf.ads<libgnarl/s-tasinf__linux.ads \
- s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
-@@ -2703,7 +2703,7 @@ ifeq ($(strip $(filter-out darwin%,$(target_os))),)
- ifeq ($(strip $(filter-out %86,$(target_cpu))),)
- LIBGNAT_TARGET_PAIRS += \
- s-intman.adb<libgnarl/s-intman__susv3.adb \
-- s-osprim.adb<libgnat/s-osprim__darwin.adb \
-+ s-osprim.adb<libgnat/s-osprim__rtems.adb \
- $(ATOMICS_TARGET_PAIRS) \
- system.ads<libgnat/system-darwin-x86.ads
-
-@@ -2722,7 +2722,7 @@ ifeq ($(strip $(filter-out darwin%,$(target_os))),)
- ifeq ($(strip $(filter-out %x86_64,$(target_cpu))),)
- LIBGNAT_TARGET_PAIRS += \
- s-intman.adb<libgnarl/s-intman__susv3.adb \
-- s-osprim.adb<libgnat/s-osprim__darwin.adb \
-+ s-osprim.adb<libgnat/s-osprim__rtems.adb \
- a-exetim.ads<libgnarl/a-exetim__default.ads \
- a-exetim.adb<libgnarl/a-exetim__darwin.adb \
- $(ATOMICS_TARGET_PAIRS) \
-@@ -2769,7 +2769,7 @@ ifeq ($(strip $(filter-out darwin%,$(target_os))),)
- ifeq ($(strip $(filter-out arm,$(target_cpu))),)
- LIBGNAT_TARGET_PAIRS += \
- s-intman.adb<libgnarl/s-intman__susv3.adb \
-- s-osprim.adb<libgnat/s-osprim__darwin.adb \
-+ s-osprim.adb<libgnat/s-osprim__rtems.adb \
- $(ATOMICS_TARGET_PAIRS) \
- $(ATOMICS_BUILTINS_TARGET_PAIRS)
-
-@@ -2782,7 +2782,7 @@ ifeq ($(strip $(filter-out darwin%,$(target_os))),)
- a-nallfl.ads<libgnat/a-nallfl__wraplf.ads \
- s-intman.adb<libgnarl/s-intman__susv3.adb \
- s-dorepr.adb<libgnat/s-dorepr__fma.adb \
-- s-osprim.adb<libgnat/s-osprim__darwin.adb \
-+ s-osprim.adb<libgnat/s-osprim__rtems.adb \
- $(ATOMICS_TARGET_PAIRS) \
- $(ATOMICS_BUILTINS_TARGET_PAIRS) \
- $(GNATRTL_128BIT_PAIRS)
-diff --git a/src/gcc/ada/libgnat/s-osprim__darwin.adb b/src/gcc/ada/libgnat/s-osprim__darwin.adb
-deleted file mode 100644
-index 5f75688..0000000
---- a/src/gcc/ada/libgnat/s-osprim__darwin.adb
-+++ /dev/null
-@@ -1,130 +0,0 @@
--------------------------------------------------------------------------------
---- --
---- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
---- --
---- S Y S T E M . O S _ P R I M I T I V E S --
---- --
---- B o d y --
---- --
---- Copyright (C) 1998-2024, Free Software Foundation, Inc. --
---- --
---- GNARL 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- --
---- ware Foundation; either version 3, or (at your option) any later ver- --
---- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
---- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
---- or FITNESS FOR A PARTICULAR PURPOSE. --
---- --
---- As a special exception under Section 7 of GPL version 3, you are granted --
---- additional permissions described in the GCC Runtime Library Exception, --
---- version 3.1, as published by the Free Software Foundation. --
---- --
---- You should have received a copy of the GNU General Public License and --
---- a copy of the GCC Runtime Library Exception along with this program; --
---- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
---- <http://www.gnu.org/licenses/>. --
---- --
---- GNARL was developed by the GNARL team at Florida State University. --
---- Extensive contributions were provided by Ada Core Technologies, Inc. --
---- --
--------------------------------------------------------------------------------
--
---- This version is for darwin
--
--with System.C_Time;
--package body System.OS_Primitives is
--
-- -- ??? These definitions are duplicated from System.OS_Interface
-- -- because we don't want to depend on any package. Consider removing
-- -- these declarations in System.OS_Interface and move these ones in
-- -- the spec.
--
-- type struct_timezone is record
-- tz_minuteswest : Integer;
-- tz_dsttime : Integer;
-- end record;
-- pragma Convention (C, struct_timezone);
-- type struct_timezone_ptr is access all struct_timezone;
--
-- function gettimeofday
-- (tv : not null access C_Time.timeval;
-- tz : struct_timezone_ptr) return Integer;
-- pragma Import (C, gettimeofday, "gettimeofday");
--
-- function nanosleep (rqtp, rmtp : not null access C_Time.timespec)
-- return Integer;
-- pragma Import (C, nanosleep, "nanosleep");
--
-- -----------
-- -- Clock --
-- -----------
--
-- function Clock return Duration is
-- TV : aliased C_Time.timeval;
--
-- Result : Integer;
-- pragma Unreferenced (Result);
--
-- begin
-- -- The return codes for gettimeofday are as follows (from man pages):
-- -- EPERM settimeofday is called by someone other than the superuser
-- -- EINVAL Timezone (or something else) is invalid
-- -- EFAULT One of tv or tz pointed outside accessible address space
--
-- -- None of these codes signal a potential clock skew, hence the return
-- -- value is never checked.
--
-- Result := gettimeofday (TV'Access, null);
-- return C_Time.To_Duration (TV);
-- end Clock;
--
-- -----------------
-- -- Timed_Delay --
-- -----------------
--
-- procedure Timed_Delay
-- (Time : Duration;
-- Mode : Integer)
-- is
-- Request : aliased C_Time.timespec;
-- Remaind : aliased C_Time.timespec;
-- Rel_Time : Duration;
-- Abs_Time : Duration;
-- Base_Time : constant Duration := Clock;
-- Check_Time : Duration := Base_Time;
--
-- Result : Integer;
-- pragma Unreferenced (Result);
--
-- begin
-- if Mode = Relative then
-- Rel_Time := Time;
-- Abs_Time := Time + Check_Time;
-- else
-- Rel_Time := Time - Check_Time;
-- Abs_Time := Time;
-- end if;
--
-- if Rel_Time > 0.0 then
-- loop
-- Request := C_Time.To_Timespec (Rel_Time);
-- Result := nanosleep (Request'Access, Remaind'Access);
-- Check_Time := Clock;
--
-- exit when Abs_Time <= Check_Time or else Check_Time < Base_Time;
--
-- Rel_Time := Abs_Time - Check_Time;
-- end loop;
-- end if;
-- end Timed_Delay;
--
-- ----------------
-- -- Initialize --
-- ----------------
--
-- procedure Initialize is
-- begin
-- null;
-- end Initialize;
--
--end System.OS_Primitives;
-diff --git a/src/gcc/ada/libgnat/s-osprim__solaris.adb b/src/gcc/ada/libgnat/s-osprim__solaris.adb
-deleted file mode 100644
-index 70c8dc4..0000000
---- a/src/gcc/ada/libgnat/s-osprim__solaris.adb
-+++ /dev/null
-@@ -1,115 +0,0 @@
--------------------------------------------------------------------------------
---- --
---- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
---- --
---- S Y S T E M . O S _ P R I M I T I V E S --
---- --
---- B o d y --
---- --
---- Copyright (C) 1998-2024, Free Software Foundation, Inc. --
---- --
---- GNARL 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- --
---- ware Foundation; either version 3, or (at your option) any later ver- --
---- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
---- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
---- or FITNESS FOR A PARTICULAR PURPOSE. --
---- --
---- As a special exception under Section 7 of GPL version 3, you are granted --
---- additional permissions described in the GCC Runtime Library Exception, --
---- version 3.1, as published by the Free Software Foundation. --
---- --
---- You should have received a copy of the GNU General Public License and --
---- a copy of the GCC Runtime Library Exception along with this program; --
---- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
---- <http://www.gnu.org/licenses/>. --
---- --
---- GNARL was developed by the GNARL team at Florida State University. --
---- Extensive contributions were provided by Ada Core Technologies, Inc. --
---- --
--------------------------------------------------------------------------------
--
---- This version uses gettimeofday and select
---- This file is suitable for Solaris (32 and 64 bits).
--
--with System.C_Time;
--
--package body System.OS_Primitives is
--
-- -- ??? These definitions are duplicated from System.OS_Interface
-- -- because we don't want to depend on any package. Consider removing
-- -- these declarations in System.OS_Interface and move these ones in
-- -- the spec.
--
-- procedure gettimeofday
-- (tv : not null access C_Time.timeval;
-- tz : Address := Null_Address);
-- pragma Import (C, gettimeofday, "gettimeofday");
--
-- procedure C_select
-- (n : Integer := 0;
-- readfds,
-- writefds,
-- exceptfds : Address := Null_Address;
-- timeout : not null access C_Time.timeval);
-- pragma Import (C, C_select, "select");
--
-- -----------
-- -- Clock --
-- -----------
--
-- function Clock return Duration is
-- TV : aliased C_Time.timeval;
--
-- begin
-- gettimeofday (TV'Access);
-- return C_Time.To_Duration (TV);
-- end Clock;
--
-- -----------------
-- -- Timed_Delay --
-- -----------------
--
-- procedure Timed_Delay
-- (Time : Duration;
-- Mode : Integer)
-- is
-- Rel_Time : Duration;
-- Abs_Time : Duration;
-- Base_Time : constant Duration := Clock;
-- Check_Time : Duration := Base_Time;
-- timeval : aliased C_Time.timeval;
--
-- begin
-- if Mode = Relative then
-- Rel_Time := Time;
-- Abs_Time := Time + Check_Time;
-- else
-- Rel_Time := Time - Check_Time;
-- Abs_Time := Time;
-- end if;
--
-- if Rel_Time > 0.0 then
-- loop
-- timeval := C_Time.To_Timeval (Rel_Time);
--
-- C_select (timeout => timeval'Unchecked_Access);
-- Check_Time := Clock;
--
-- exit when Abs_Time <= Check_Time or else Check_Time < Base_Time;
--
-- Rel_Time := Abs_Time - Check_Time;
-- end loop;
-- end if;
-- end Timed_Delay;
--
-- ----------------
-- -- Initialize --
-- ----------------
--
-- procedure Initialize is
-- begin
-- null;
-- end Initialize;
--
--end System.OS_Primitives;
-diff --git a/src/gcc/ada/libgnat/s-osprim__x32.adb b/src/gcc/ada/libgnat/s-osprim__x32.adb
-deleted file mode 100644
-index 644c41c..0000000
---- a/src/gcc/ada/libgnat/s-osprim__x32.adb
-+++ /dev/null
-@@ -1,123 +0,0 @@
--------------------------------------------------------------------------------
---- --
---- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
---- --
---- S Y S T E M . O S _ P R I M I T I V E S --
---- --
---- B o d y --
---- --
---- Copyright (C) 2013-2024, Free Software Foundation, Inc. --
---- --
---- GNARL 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- --
---- ware Foundation; either version 3, or (at your option) any later ver- --
---- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
---- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
---- or FITNESS FOR A PARTICULAR PURPOSE. --
---- --
---- As a special exception under Section 7 of GPL version 3, you are granted --
---- additional permissions described in the GCC Runtime Library Exception, --
---- version 3.1, as published by the Free Software Foundation. --
---- --
---- You should have received a copy of the GNU General Public License and --
---- a copy of the GCC Runtime Library Exception along with this program; --
---- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
---- <http://www.gnu.org/licenses/>. --
---- --
---- GNARL was developed by the GNARL team at Florida State University. --
---- Extensive contributions were provided by Ada Core Technologies, Inc. --
---- --
--------------------------------------------------------------------------------
--
---- This version is for Linux/x32
--
--with System.C_Time;
--
--package body System.OS_Primitives is
--
-- -- ??? These definitions are duplicated from System.OS_Interface
-- -- because we don't want to depend on any package. Consider removing
-- -- these declarations in System.OS_Interface and move these ones in
-- -- the spec.
--
-- function nanosleep (rqtp, rmtp : not null access C_Time.timespec)
-- return Integer;
-- pragma Import (C, nanosleep, "nanosleep");
--
-- -----------
-- -- Clock --
-- -----------
--
-- function Clock return Duration is
-- TV : aliased C_Time.timeval;
-- Result : Integer;
-- pragma Unreferenced (Result);
--
-- function gettimeofday
-- (Tv : access C_Time.timeval;
-- Tz : System.Address := System.Null_Address) return Integer;
-- pragma Import (C, gettimeofday, "gettimeofday");
--
-- begin
-- -- The return codes for gettimeofday are as follows (from man pages):
-- -- EPERM settimeofday is called by someone other than the superuser
-- -- EINVAL Timezone (or something else) is invalid
-- -- EFAULT One of tv or tz pointed outside accessible address space
--
-- -- None of these codes signal a potential clock skew, hence the return
-- -- value is never checked.
--
-- Result := gettimeofday (TV'Access, System.Null_Address);
-- return C_Time.To_Duration (TV);
-- end Clock;
--
-- -----------------
-- -- Timed_Delay --
-- -----------------
--
-- procedure Timed_Delay
-- (Time : Duration;
-- Mode : Integer)
-- is
-- Request : aliased C_Time.timespec;
-- Remaind : aliased C_Time.timespec;
-- Rel_Time : Duration;
-- Abs_Time : Duration;
-- Base_Time : constant Duration := Clock;
-- Check_Time : Duration := Base_Time;
--
-- Result : Integer;
-- pragma Unreferenced (Result);
--
-- begin
-- if Mode = Relative then
-- Rel_Time := Time;
-- Abs_Time := Time + Check_Time;
-- else
-- Rel_Time := Time - Check_Time;
-- Abs_Time := Time;
-- end if;
--
-- if Rel_Time > 0.0 then
-- loop
-- Request := C_Time.To_Timespec (Rel_Time);
-- Result := nanosleep (Request'Access, Remaind'Access);
-- Check_Time := Clock;
--
-- exit when Abs_Time <= Check_Time or else Check_Time < Base_Time;
--
-- Rel_Time := Abs_Time - Check_Time;
-- end loop;
-- end if;
-- end Timed_Delay;
--
-- ----------------
-- -- Initialize --
-- ----------------
--
-- procedure Initialize is
-- begin
-- null;
-- end Initialize;
--
--end System.OS_Primitives;
---
-2.39.2
-
diff --git a/debian/patches/0008-Ada-import-nanosleep-from-System.OS_Primitives.Timed.diff b/debian/patches/0008-Ada-import-nanosleep-from-System.OS_Primitives.Timed.diff
deleted file mode 100644
index 9fed4ad0..00000000
--- a/debian/patches/0008-Ada-import-nanosleep-from-System.OS_Primitives.Timed.diff
+++ /dev/null
@@ -1,74 +0,0 @@
-From 2bcae0199842035b99ae28659f821b51fbc9b537 Mon Sep 17 00:00:00 2001
-From: Nicolas Boulenguez <nicolas.boulenguez@free.fr>
-Date: Wed, 3 Apr 2024 17:43:50 +0200
-Subject: [PATCH 8/9] Ada: import nanosleep from
- System.OS_Primitives.Timed_Delay
-
-It improves readability to import this C function in the file where it
-is actually used.
----
- gcc/ada/libgnat/s-optide.adb | 7 +++++++
- gcc/ada/libgnat/s-osprim__posix.adb | 9 ---------
- gcc/ada/libgnat/s-osprim__posix2008.adb | 8 --------
- 3 files changed, 7 insertions(+), 17 deletions(-)
-
-diff --git a/src/gcc/ada/libgnat/s-optide.adb b/src/gcc/ada/libgnat/s-optide.adb
-index e15493c..4ad16a2 100644
---- a/src/gcc/ada/libgnat/s-optide.adb
-+++ b/src/gcc/ada/libgnat/s-optide.adb
-@@ -36,6 +36,13 @@ procedure Timed_Delay
- (Time : Duration;
- Mode : Integer)
- is
-+
-+ function nanosleep (rqtp, rmtp : not null access C_Time.timespec)
-+ return Integer
-+ with Import,
-+ Convention => C,
-+ External_Name => "nanosleep";
-+
- Request : aliased C_Time.timespec;
- Remaind : aliased C_Time.timespec;
- Rel_Time : Duration;
-diff --git a/src/gcc/ada/libgnat/s-osprim__posix.adb b/src/gcc/ada/libgnat/s-osprim__posix.adb
-index bb9a28d..b331d5c 100644
---- a/src/gcc/ada/libgnat/s-osprim__posix.adb
-+++ b/src/gcc/ada/libgnat/s-osprim__posix.adb
-@@ -34,15 +34,6 @@ with System.C_Time;
-
- package body System.OS_Primitives is
-
-- -- ??? These definitions are duplicated from System.OS_Interface
-- -- because we don't want to depend on any package. Consider removing
-- -- these declarations in System.OS_Interface and move these ones in
-- -- the spec.
--
-- function nanosleep (rqtp, rmtp : not null access C_Time.timespec)
-- return Integer;
-- pragma Import (C, nanosleep, "nanosleep");
--
- -----------
- -- Clock --
- -----------
-diff --git a/src/gcc/ada/libgnat/s-osprim__posix2008.adb b/src/gcc/ada/libgnat/s-osprim__posix2008.adb
-index 377fb3a..7f44efa 100644
---- a/src/gcc/ada/libgnat/s-osprim__posix2008.adb
-+++ b/src/gcc/ada/libgnat/s-osprim__posix2008.adb
-@@ -39,14 +39,6 @@ package body System.OS_Primitives is
-
- subtype int is System.CRTL.int;
-
-- -- ??? These definitions are duplicated from System.OS_Interface because
-- -- we don't want to depend on any package. Consider removing these
-- -- declarations in System.OS_Interface and move these ones to the spec.
--
-- function nanosleep (rqtp, rmtp : not null access C_Time.timespec)
-- return Integer;
-- pragma Import (C, nanosleep, "nanosleep");
--
- -----------
- -- Clock --
- -----------
---
-2.39.2
-
diff --git a/debian/patches/0009-Ada-select-64-bits-time-functions-from-GNU-libc-when.diff b/debian/patches/0009-Ada-select-64-bits-time-functions-from-GNU-libc-when.diff
index 9186b209..059ba67f 100644
--- a/debian/patches/0009-Ada-select-64-bits-time-functions-from-GNU-libc-when.diff
+++ b/debian/patches/0009-Ada-select-64-bits-time-functions-from-GNU-libc-when.diff
@@ -1,22 +1,28 @@
-From a40087b15892f6870d51842b1f6a8f019bcbee3b Mon Sep 17 00:00:00 2001
-From: Nicolas Boulenguez <nicolas.boulenguez@free.fr>
+From 40f8f487e14bff98c270fc559c7ea814ccf1534a Mon Sep 17 00:00:00 2001
+From: Nicolas Boulenguez <nicolas@debian.org>
Date: Fri, 26 Apr 2024 20:08:21 +0200
-Subject: [PATCH 9/9] Ada: select 64 bits time functions from GNU libc when
- __USE_TIME_BITS64
+Subject: [PATCH 2/8] Ada: select 64 bits time functions from GNU libc when
+ __USE_TIME64_REDIRECTS [PR114065]
-else Ada.Calendar returns random dates on system affected by the
-Y2038 Glibc transition (pr114065).
+Without this, on system affected by the Y2038 Glibc transition,
+Ada.Calendar imports the 32 bits version of the C date functions but
+reads 64 bits types from memory.
+
+The interaction of __USE_TIME64_REDIRECTS, __TIMESIZE==32 and
+__USE_TIME_BITS64 has changed with libc 2.39 (fix by Simon Chopin).
+
+PR ada/114065
+Signed-off-by: Nicolas Boulenguez <nicolas@debian.org>
---
gcc/ada/libgnarl/a-exetim__posix.adb | 5 ++++-
gcc/ada/libgnarl/s-osinte__gnu.ads | 14 ++++++++++----
gcc/ada/libgnarl/s-osinte__kfreebsd-gnu.ads | 14 ++++++++++----
gcc/ada/libgnarl/s-osinte__linux.ads | 10 +++++++---
gcc/ada/libgnat/g-spogwa.adb | 4 +++-
- gcc/ada/libgnat/s-optide.adb | 3 ++-
- gcc/ada/libgnat/s-osprim__posix.adb | 4 +++-
- gcc/ada/libgnat/s-osprim__posix2008.adb | 3 ++-
+ gcc/ada/libgnat/s-osprim__posix.adb | 7 +++++--
+ gcc/ada/libgnat/s-osprim__posix2008.adb | 6 ++++--
gcc/ada/s-oscons-tmplt.c | 16 ++++++++++++++++
- 9 files changed, 57 insertions(+), 16 deletions(-)
+ 8 files changed, 59 insertions(+), 17 deletions(-)
diff --git a/src/gcc/ada/libgnarl/a-exetim__posix.adb b/src/gcc/ada/libgnarl/a-exetim__posix.adb
index db873fb..7fbd6c1 100644
@@ -42,7 +48,7 @@ index db873fb..7fbd6c1 100644
function pthread_getcpuclockid
diff --git a/src/gcc/ada/libgnarl/s-osinte__gnu.ads b/src/gcc/ada/libgnarl/s-osinte__gnu.ads
-index b4597c5..90ef2d5 100644
+index b4597c5..08884ec 100644
--- a/src/gcc/ada/libgnarl/s-osinte__gnu.ads
+++ b/src/gcc/ada/libgnarl/s-osinte__gnu.ads
@@ -39,6 +39,7 @@
@@ -188,22 +194,8 @@ index 530a6cd..598f3fc 100644
Timeout_V : aliased System.C_Time.timeval;
Timeout_A : access System.C_Time.timeval;
-diff --git a/src/gcc/ada/libgnat/s-optide.adb b/src/gcc/ada/libgnat/s-optide.adb
-index 4ad16a2..a9025d0 100644
---- a/src/gcc/ada/libgnat/s-optide.adb
-+++ b/src/gcc/ada/libgnat/s-optide.adb
-@@ -41,7 +41,8 @@ is
- return Integer
- with Import,
- Convention => C,
-- External_Name => "nanosleep";
-+ External_Name => (if OS_Constants.Glibc_Use_Time_Bits64
-+ then "__nanosleep64" else "nanosleep");
-
- Request : aliased C_Time.timespec;
- Remaind : aliased C_Time.timespec;
diff --git a/src/gcc/ada/libgnat/s-osprim__posix.adb b/src/gcc/ada/libgnat/s-osprim__posix.adb
-index b331d5c..f647968 100644
+index bb9a28d..9e86121 100644
--- a/src/gcc/ada/libgnat/s-osprim__posix.adb
+++ b/src/gcc/ada/libgnat/s-osprim__posix.adb
@@ -31,6 +31,7 @@
@@ -214,7 +206,17 @@ index b331d5c..f647968 100644
package body System.OS_Primitives is
-@@ -47,7 +48,8 @@ package body System.OS_Primitives is
+@@ -41,7 +42,8 @@ package body System.OS_Primitives is
+
+ function nanosleep (rqtp, rmtp : not null access C_Time.timespec)
+ return Integer;
+- pragma Import (C, nanosleep, "nanosleep");
++ pragma Import (C, nanosleep, (if OS_Constants.Glibc_Use_Time_Bits64
++ then "__nanosleep64" else "nanosleep"));
+
+ -----------
+ -- Clock --
+@@ -56,7 +58,8 @@ package body System.OS_Primitives is
function gettimeofday
(Tv : access C_Time.timeval;
Tz : System.Address := System.Null_Address) return Integer;
@@ -225,10 +227,20 @@ index b331d5c..f647968 100644
begin
-- The return codes for gettimeofday are as follows (from man pages):
diff --git a/src/gcc/ada/libgnat/s-osprim__posix2008.adb b/src/gcc/ada/libgnat/s-osprim__posix2008.adb
-index 7f44efa..0dbde83 100644
+index 377fb3a..76823c1 100644
--- a/src/gcc/ada/libgnat/s-osprim__posix2008.adb
+++ b/src/gcc/ada/libgnat/s-osprim__posix2008.adb
-@@ -54,7 +54,8 @@ package body System.OS_Primitives is
+@@ -45,7 +45,8 @@ package body System.OS_Primitives is
+
+ function nanosleep (rqtp, rmtp : not null access C_Time.timespec)
+ return Integer;
+- pragma Import (C, nanosleep, "nanosleep");
++ pragma Import (C, nanosleep, (if OS_Constants.Glibc_Use_Time_Bits64
++ then "__nanosleep64" else "nanosleep"));
+
+ -----------
+ -- Clock --
+@@ -62,7 +63,8 @@ package body System.OS_Primitives is
function clock_gettime
(clock_id : clockid_t;
tp : access C_Time.timespec) return int;
@@ -239,11 +251,11 @@ index 7f44efa..0dbde83 100644
begin
Result := clock_gettime (CLOCK_REALTIME, TS'Unchecked_Access);
diff --git a/src/gcc/ada/s-oscons-tmplt.c b/src/gcc/ada/s-oscons-tmplt.c
-index 5beb929..8551d78 100644
+index e5dad44..a64e578 100644
--- a/src/gcc/ada/s-oscons-tmplt.c
+++ b/src/gcc/ada/s-oscons-tmplt.c
@@ -1775,6 +1775,22 @@ CNS(MAX_tv_sec, "")
- CND(SIZEOF_tv_nsec, "tv_nsec, long except on x32");
+ CND(SIZEOF_tv_nsec, "tv_nsec");
}
+/*
diff --git a/debian/rules.patch b/debian/rules.patch
index 7bb6c802..1f9937cf 100644
--- a/debian/rules.patch
+++ b/debian/rules.patch
@@ -32,14 +32,7 @@ debian_patches += \
# libstdc++-pic \
debian_patches += \
- 0001-Ada-remove-conversions-with-C-struct-timeval-from-GN \
- 0002-Ada-remove-conversions-with-C-struct-timespec-from-A \
- 0003-Ada-remove-conversions-with-C-time_t-from-System.OS_ \
0004-Ada-merge-all-timeval-and-timespec-definitions-and-c \
- 0005-Ada-drop-unneeded-x32-variant-of-System.Linux \
- 0006-Ada-drop-unneeded-posix2008-variant-of-System.Parame \
- 0007-Ada-drop-unneeded-darwin-solaris-x32-variants-of-Sys \
- 0008-Ada-import-nanosleep-from-System.OS_Primitives.Timed \
0009-Ada-select-64-bits-time-functions-from-GNU-libc-when \
gcc-textdomain \
gcc-distro-specs \
--
2.39.2
Reply to: