]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Ada: Add System.C_Time and GNAT.C_Time units to libgnat
authorNicolas Boulenguez <nicolas@debian.org>
Fri, 25 Jul 2025 13:02:06 +0000 (15:02 +0200)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 31 Jul 2025 15:41:00 +0000 (17:41 +0200)
The first unit provides the time_t, timeval and timespec types corresponding
to the C types defined by the OS, as well as various conversion functions.

The second unit is a mere renaming of the first under the GNAT hierarchy.

This removes C time types and conversions under System, and from bodies and
private parts under GNAT, while keeping visible types and conversions under
GNAT as Obsolescent.

[changelog]
PR ada/114065
* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add g-c_time$(objext) and
s-c_time$(objext).
(Aarch64/Android): Do not use s-osinte__android.adb.
(SPARC/Solaris): Do not use s-osprim__solaris.adb.
(x86/Solaris): Likewise.
(LynxOS178): Do not use s-parame__posix2008.ads.
(RTEMS): Likewise.
(x32/Linux): Likewise, as well as s-linux__x32.ads.  Replace
s-osprim__x32.adb with s-osprim__posix.adb.
(LIBGNAT_OBJS): Remove cal.o.
* cal.c: Delete.
* doc/gnat_rm/the_gnat_library.rst (GNAT.C_Time): New entry.
(GNAT.Calendar): Do not mention the obsolete conversion functions.
* impunit.adb (Non_Imp_File_Names_95): Add g-c_time.
* libgnarl/a-exetim__posix.adb: Add with clause for System.C_Time
(Clock): Use type and functions from System.C_Time.
* libgnarl/s-linux.ads: Remove with clause for System.Parameters.
Remove declarations of C time types.
* libgnarl/s-linux__alpha.ads: Likewise.
* libgnarl/s-linux__android-aarch64.ads: Likewise.
* libgnarl/s-linux__android-arm.ads: Likewise.
* libgnarl/s-linux__hppa.ads: Likewise.
* libgnarl/s-linux__loongarch.ads: Likewise.
* libgnarl/s-linux__mips.ads: Likewise.
* libgnarl/s-linux__riscv.ads: Likewise.
* libgnarl/s-linux__sparc.ads: Likewise.
* libgnarl/s-osinte__aix.ads: Likewise.
* libgnarl/s-osinte__android.ads: Likewise.
* libgnarl/s-osinte__cheribsd.ads: Likewise.
* libgnarl/s-osinte__darwin.ads: Likewise.
* libgnarl/s-osinte__dragonfly.ads: Likewise.
* libgnarl/s-osinte__freebsd.ads: Likewise.
* libgnarl/s-osinte__gnu.ads: Likewise.
* libgnarl/s-osinte__hpux.ads: Likewise.
* libgnarl/s-osinte__kfreebsd-gnu.ads: Likewise.
* libgnarl/s-osinte__linux.ads: Likewise.
* libgnarl/s-osinte__lynxos178e.ads: Likewise.
* libgnarl/s-osinte__qnx.ads: Likewise.
* libgnarl/s-osinte__rtems.ads: Likewise.
* libgnarl/s-osinte__solaris.ads: Likewise.
* libgnarl/s-osinte__vxworks.ads: Likewise.
* libgnarl/s-qnx.ads: Likewise.
* libgnarl/s-linux__x32.ads: Delete.
* libgnarl/s-osinte__darwin.adb (To_Duration): Remove.
(To_Timespec): Likewise.
* libgnarl/s-osinte__aix.adb: Likewise.
* libgnarl/s-osinte__dragonfly.adb: Likewise.
* libgnarl/s-osinte__freebsd.adb: Likewise.
* libgnarl/s-osinte__gnu.adb: Likewise.
* libgnarl/s-osinte__lynxos178.adb: Likewise.
* libgnarl/s-osinte__posix.adb: Likewise.
* libgnarl/s-osinte__qnx.adb: Likewise.
* libgnarl/s-osinte__rtems.adb: Likewise.
* libgnarl/s-osinte__solaris.adb: Likewise.
* libgnarl/s-osinte__vxworks.adb: Likewise.
* libgnarl/s-osinte__x32.adb: Likewise.
* libgnarl/s-taprop__solaris.adb: Add with clause for System.C_Time.
(Monotonic_Clock): Use type and functions from System.C_Time.
(RT_Resolution): Likewise.
(Timed_Sleep): Likewise.
(Timed_Delay): Likewise.
* libgnarl/s-taprop__vxworks.adb: Likewise.
* libgnarl/s-tpopmo.adb: Likewise.
* libgnarl/s-osinte__android.adb: Delete.
* libgnat/g-c_time.ads: New file.
* libgnat/g-calend.adb: Delegate to System.C_Time.
* libgnat/g-calend.ads: Likewise.
* libgnat/g-socket.adb: Likewise.
* libgnat/g-socthi.adb: Likewise.
* libgnat/g-socthi__vxworks.adb: Likewise.
* libgnat/g-sothco.ads: Likewise.
* libgnat/g-spogwa.adb: Likewise.
* libgnat/s-c_time.adb: New file.
* libgnat/s-c_time.ads: Likewise.
* libgnat/s-optide.adb: Import nanosleep here.
* libgnat/s-os_lib.ads (time_t): Remove.
(To_Ada): Adjust.
(To_C): Likewise.
* libgnat/s-os_lib.adb: Likewise.
* libgnat/s-osprim__darwin.adb: Delegate to System.C_Time.
* libgnat/s-osprim__posix.adb: Likewise.
* libgnat/s-osprim__posix2008.adb: Likewise.
* libgnat/s-osprim__rtems.adb: Likewise.
* libgnat/s-osprim__unix.adb: Likewise.
* libgnat/s-osprim__solaris.adb: Delete.
* libgnat/s-osprim__x32.adb: Likewise.
* libgnat/s-parame.ads (time_t_bits): Remove.
* libgnat/s-parame__hpux.ads: Likewise.
* libgnat/s-parame__vxworks.ads: Likewise.
* libgnat/s-parame__posix2008.ads: Delete.
* s-oscons-tmplt.c (SIZEOF_tv_nsec): New constant.

71 files changed:
gcc/ada/Makefile.rtl
gcc/ada/cal.c [deleted file]
gcc/ada/doc/gnat_rm/the_gnat_library.rst
gcc/ada/impunit.adb
gcc/ada/libgnarl/a-exetim__posix.adb
gcc/ada/libgnarl/s-linux.ads
gcc/ada/libgnarl/s-linux__alpha.ads
gcc/ada/libgnarl/s-linux__android-aarch64.ads
gcc/ada/libgnarl/s-linux__android-arm.ads
gcc/ada/libgnarl/s-linux__hppa.ads
gcc/ada/libgnarl/s-linux__loongarch.ads
gcc/ada/libgnarl/s-linux__mips.ads
gcc/ada/libgnarl/s-linux__riscv.ads
gcc/ada/libgnarl/s-linux__sparc.ads
gcc/ada/libgnarl/s-linux__x32.ads [deleted file]
gcc/ada/libgnarl/s-osinte__aix.adb
gcc/ada/libgnarl/s-osinte__aix.ads
gcc/ada/libgnarl/s-osinte__android.ads
gcc/ada/libgnarl/s-osinte__cheribsd.ads
gcc/ada/libgnarl/s-osinte__darwin.adb
gcc/ada/libgnarl/s-osinte__darwin.ads
gcc/ada/libgnarl/s-osinte__dragonfly.adb
gcc/ada/libgnarl/s-osinte__dragonfly.ads
gcc/ada/libgnarl/s-osinte__freebsd.adb
gcc/ada/libgnarl/s-osinte__freebsd.ads
gcc/ada/libgnarl/s-osinte__gnu.adb
gcc/ada/libgnarl/s-osinte__gnu.ads
gcc/ada/libgnarl/s-osinte__hpux.ads
gcc/ada/libgnarl/s-osinte__kfreebsd-gnu.ads
gcc/ada/libgnarl/s-osinte__linux.ads
gcc/ada/libgnarl/s-osinte__lynxos178.adb
gcc/ada/libgnarl/s-osinte__lynxos178e.ads
gcc/ada/libgnarl/s-osinte__posix.adb
gcc/ada/libgnarl/s-osinte__qnx.adb
gcc/ada/libgnarl/s-osinte__qnx.ads
gcc/ada/libgnarl/s-osinte__rtems.adb
gcc/ada/libgnarl/s-osinte__rtems.ads
gcc/ada/libgnarl/s-osinte__solaris.adb
gcc/ada/libgnarl/s-osinte__solaris.ads
gcc/ada/libgnarl/s-osinte__vxworks.adb
gcc/ada/libgnarl/s-osinte__vxworks.ads
gcc/ada/libgnarl/s-osinte__x32.adb
gcc/ada/libgnarl/s-qnx.ads
gcc/ada/libgnarl/s-taprop__solaris.adb
gcc/ada/libgnarl/s-taprop__vxworks.adb
gcc/ada/libgnarl/s-tpopmo.adb
gcc/ada/libgnat/g-c_time.ads [moved from gcc/ada/libgnarl/s-osinte__android.adb with 59% similarity]
gcc/ada/libgnat/g-calend.adb
gcc/ada/libgnat/g-calend.ads
gcc/ada/libgnat/g-socket.adb
gcc/ada/libgnat/g-socthi.adb
gcc/ada/libgnat/g-socthi__vxworks.adb
gcc/ada/libgnat/g-sothco.ads
gcc/ada/libgnat/g-spogwa.adb
gcc/ada/libgnat/s-c_time.adb [new file with mode: 0644]
gcc/ada/libgnat/s-c_time.ads [new file with mode: 0644]
gcc/ada/libgnat/s-optide.adb
gcc/ada/libgnat/s-os_lib.adb
gcc/ada/libgnat/s-os_lib.ads
gcc/ada/libgnat/s-osprim__darwin.adb
gcc/ada/libgnat/s-osprim__posix.adb
gcc/ada/libgnat/s-osprim__posix2008.adb
gcc/ada/libgnat/s-osprim__rtems.adb
gcc/ada/libgnat/s-osprim__solaris.adb [deleted file]
gcc/ada/libgnat/s-osprim__unix.adb
gcc/ada/libgnat/s-osprim__x32.adb [deleted file]
gcc/ada/libgnat/s-parame.ads
gcc/ada/libgnat/s-parame__hpux.ads
gcc/ada/libgnat/s-parame__posix2008.ads [deleted file]
gcc/ada/libgnat/s-parame__vxworks.ads
gcc/ada/s-oscons-tmplt.c

index 50e683aa80a78d9ed744d060d2eea489328419c0..b383d9dc73ce3d187335bdde9ba5619ad2ad296a 100644 (file)
@@ -415,6 +415,7 @@ GNATRTL_NONTASKING_OBJS= \
   g-busorg$(objext) \
   g-byorma$(objext) \
   g-bytswa$(objext) \
+  g-c_time$(objext) \
   g-calend$(objext) \
   g-casuti$(objext) \
   g-catiio$(objext) \
@@ -535,6 +536,7 @@ GNATRTL_NONTASKING_OBJS= \
   s-boarop$(objext) \
   s-boustr$(objext) \
   s-bytswa$(objext) \
+  s-c_time$(objext) \
   s-carsi8$(objext) \
   s-carun8$(objext) \
   s-casi16$(objext) \
@@ -1418,7 +1420,6 @@ ifeq ($(strip $(filter-out arm% aarch64 linux-android%,$(target_cpu) $(target_os
   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
   s-intman.adb<libgnarl/s-intman__android.adb \
   s-osinte.ads<libgnarl/s-osinte__android.ads \
-  s-osinte.adb<libgnarl/s-osinte__android.adb \
   s-oslock.ads<libgnat/s-oslock__posix.ads \
   s-osprim.adb<libgnat/s-osprim__posix.adb \
   s-parame.adb<libgnat/s-parame__aarch64-linux.adb \
@@ -1531,7 +1532,7 @@ ifeq ($(strip $(filter-out sparc% sun solaris%,$(target_cpu) $(target_vendor) $(
   s-osinte.adb<libgnarl/s-osinte__solaris.adb \
   s-osinte.ads<libgnarl/s-osinte__solaris.ads \
   s-oslock.ads<libgnat/s-oslock__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 \
@@ -1580,7 +1581,7 @@ ifeq ($(strip $(filter-out %86 %x86_64 solaris2%,$(target_cpu) $(target_os))),)
   s-osinte.adb<libgnarl/s-osinte__solaris.adb \
   s-osinte.ads<libgnarl/s-osinte__solaris.ads \
   s-oslock.ads<libgnat/s-oslock__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 \
@@ -2146,7 +2147,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
@@ -2173,7 +2173,6 @@ ifeq ($(strip $(filter-out rtems%,$(target_os))),)
   s-oslock.ads<libgnat/s-oslock__posix.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 \
@@ -2941,13 +2940,11 @@ 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 \
   s-oslock.ads<libgnat/s-oslock__posix.ads \
-  s-osprim.adb<libgnat/s-osprim__x32.adb \
-  s-parame.ads<libgnat/s-parame__posix2008.ads \
+  s-osprim.adb<libgnat/s-osprim__posix.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 \
@@ -3194,7 +3191,7 @@ LIBGNAT_TARGET_PAIRS += \
 # library.  LIBGNAT_OBJS is the list of object files for libgnat.
 # thread.c is special as put into GNATRTL_TASKING_OBJS
 LIBGNAT_OBJS = adadecode.o adaint.o argv.o aux-io.o                    \
-  cal.o cio.o cstreams.o ctrl_c.o                                      \
+  cio.o cstreams.o ctrl_c.o                                            \
   env.o errno.o exit.o expect.o final.o rtfinal.o rtinit.o             \
   init.o initialize.o locales.o mkdir.o                                        \
   raise.o seh_init.o socket.o sysdep.o                                 \
diff --git a/gcc/ada/cal.c b/gcc/ada/cal.c
deleted file mode 100644 (file)
index 0a61e0f..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
- *                                                                          *
- *                         GNAT COMPILER COMPONENTS                         *
- *                                                                          *
- *                                   C A L                                  *
- *                                                                          *
- *                          C Implementation File                           *
- *                                                                          *
- *          Copyright (C) 1992-2025, 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 file contains routines marked with pragmas Import in package       */
-/*  GNAT.Calendar. It is used to do Duration to timeval conversion.         */
-/*  These are simple wrapper functions to abstract the fact that the C      */
-/*  struct timeval fields are not normalized (they are generally            */
-/*  defined as int or long values).                                         */
-
-#if defined (__vxworks)
-#ifdef __RTP__
-#include <time.h>
-#include <version.h>
-#if (_WRS_VXWORKS_MAJOR == 7) || (_WRS_VXWORKS_MINOR != 0)
-#include <sys/time.h>
-#endif
-#else
-#include <sys/times.h>
-#endif
-#elif defined (__nucleus__)
-#include <time.h>
-#else
-#include <sys/time.h>
-#endif
-
-#ifdef __MINGW32__
-#include "mingw32.h"
-#include <winsock.h>
-#endif
-
-void
-__gnat_timeval_to_duration (struct timeval *t, long long *sec, long *usec)
-{
-  *sec  = (long long) t->tv_sec;
-  *usec = (long) t->tv_usec;
-}
-
-void
-__gnat_duration_to_timeval (long long sec, long usec, struct timeval *t)
-{
-  /* here we are doing implicit conversion to the struct timeval
-     fields types. */
-
-  t->tv_sec = sec;
-  t->tv_usec = usec;
-}
index d041090eab067ce5d01de47dd7e06933211921d4..29642aa897091c65aadc50e9984a83a338a24167 100644 (file)
@@ -663,6 +663,18 @@ sequences for various UCS input formats.
 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
 Machine-specific implementations are available in some cases.
 
+.. _`GNAT.C_Time_(g-c_time.ads)`:
+
+``GNAT.C_Time`` (:file:`g-c_time.ads`)
+======================================
+
+.. index:: GNAT.C_Time (g-c_time.ads)
+
+.. index:: Time
+
+Provides the time_t, timeval and timespec types corresponding to the C
+types defined by the OS, as well as various conversion functions.
+
 .. _`GNAT.Calendar_(g-calend.ads)`:
 
 ``GNAT.Calendar`` (:file:`g-calend.ads`)
@@ -674,8 +686,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)`:
 
index edb04a20f418b7fbf36eebcd308a699322c3b06a..712d46c54abbdf074a7b0349ae635a200ad62b5f 100644 (file)
@@ -250,6 +250,7 @@ package body Impunit is
     ("g-busorg", F),  -- GNAT.Bubble_Sort_G
     ("g-byorma", F),  -- GNAT.Byte_Order_Mark
     ("g-bytswa", F),  -- GNAT.Byte_Swapping
+    ("g-c_time", F),  -- GNAT.C_Time
     ("g-calend", F),  -- GNAT.Calendar
     ("g-catiio", F),  -- GNAT.Calendar.Time_IO
     ("g-casuti", F),  -- GNAT.Case_Util
index ee27ff29f1564ed5175ca0372ec1f2accc0f9ee3..a57689e0847de2b05d4243cb392f7c76799d225c 100644 (file)
@@ -34,8 +34,9 @@
 with Ada.Task_Identification;  use Ada.Task_Identification;
 with Ada.Unchecked_Conversion;
 
-with System.Tasking;
+with System.C_Time;
 with System.OS_Interface; use System.OS_Interface;
+with System.Tasking;
 with System.Task_Primitives.Operations; use System.Task_Primitives.Operations;
 
 with Interfaces.C; use Interfaces.C;
@@ -98,7 +99,7 @@ package body Ada.Execution_Time is
      (T : Ada.Task_Identification.Task_Id :=
         Ada.Task_Identification.Current_Task) return CPU_Time
    is
-      TS       : aliased timespec;
+      TS       : aliased System.C_Time.timespec;
       Clock_Id : aliased Interfaces.C.int;
       Result   : Interfaces.C.int;
 
@@ -112,7 +113,7 @@ package body Ada.Execution_Time is
 
       function clock_gettime
         (clock_id : Interfaces.C.int;
-         tp       : access timespec)
+         tp       : access System.C_Time.timespec)
          return Interfaces.C.int;
       pragma Import (C, clock_gettime, "clock_gettime");
       --  Function from the POSIX.1b Realtime Extensions library
@@ -139,7 +140,7 @@ package body Ada.Execution_Time is
         (clock_id => Clock_Id, tp => TS'Unchecked_Access);
       pragma Assert (Result = 0);
 
-      return To_CPU_Time (To_Duration (TS));
+      return To_CPU_Time (System.C_Time.To_Duration (TS));
    end Clock;
 
    --------------------------
index 62176f1bd9684dcdf3af60e1df54309bfe66089c..f41a67bd8a3ad96dfb0a98e4dd2ced3ff6221601 100644 (file)
@@ -36,7 +36,6 @@
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package
 
 with Interfaces.C;
-with System.Parameters;
 
 package System.Linux is
    pragma Preelaborate;
@@ -45,24 +44,8 @@ package System.Linux is
    -- Time --
    ----------
 
-   subtype long        is Interfaces.C.long;
-   subtype suseconds_t is Interfaces.C.long;
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-        .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
    subtype clockid_t   is Interfaces.C.int;
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
-   type timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, timeval);
-
    -----------
    -- Errno --
    -----------
index 855e6672e365deb052f2a6fa79d609d25123bc26..c05b90c04cb7679963d250ca1f3aed471719c519 100644 (file)
@@ -36,7 +36,6 @@
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package.
 
 with Interfaces.C;
-with System.Parameters;
 
 package System.Linux is
    pragma Preelaborate;
@@ -45,24 +44,8 @@ package System.Linux is
    -- Time --
    ----------
 
-   subtype long        is Interfaces.C.long;
-   subtype suseconds_t is Interfaces.C.long;
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
    subtype clockid_t   is Interfaces.C.int;
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
-   type timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, timeval);
-
    -----------
    -- Errno --
    -----------
index 537c46b5d3cc7346677c79612e73f5bf3f852474..c7a69fa29c013f7c4f94172269a27ee6c1f3d4fb 100644 (file)
@@ -36,7 +36,6 @@
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package
 
 with Interfaces.C;
-with System.Parameters;
 
 package System.Linux is
    pragma Preelaborate;
@@ -45,24 +44,8 @@ package System.Linux is
    -- Time --
    ----------
 
-   subtype long        is Interfaces.C.long;
-   subtype suseconds_t is Interfaces.C.long;
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
    subtype clockid_t   is Interfaces.C.int;
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
-   type timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, timeval);
-
    -----------
    -- Errno --
    -----------
index 07bca55f6c47d43f68a2201268d9921f18c3fbbd..fdc14c387fb90ff3bb802c9a3ab252ac953a4f71 100644 (file)
@@ -36,7 +36,6 @@
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package
 
 with Interfaces.C;
-with System.Parameters;
 
 package System.Linux is
    pragma Preelaborate;
@@ -45,24 +44,8 @@ package System.Linux is
    -- Time --
    ----------
 
-   subtype long        is Interfaces.C.long;
-   subtype suseconds_t is Interfaces.C.long;
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
    subtype clockid_t   is Interfaces.C.int;
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
-   type timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, timeval);
-
    -----------
    -- Errno --
    -----------
index a3ce02bcb6e70d2c8e5293b89ce1837cf606bd36..e249846cd3021b30f3e78ed1faffd432be7c0ead 100644 (file)
@@ -36,7 +36,6 @@
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package.
 
 with Interfaces.C;
-with System.Parameters;
 
 package System.Linux is
    pragma Preelaborate;
@@ -45,24 +44,8 @@ package System.Linux is
    -- Time --
    ----------
 
-   subtype long        is Interfaces.C.long;
-   subtype suseconds_t is Interfaces.C.long;
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
    subtype clockid_t   is Interfaces.C.int;
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
-   type timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, timeval);
-
    -----------
    -- Errno --
    -----------
index e0eaaa47e71dbeca116415b2c9bc4ca72ccb5217..20e3d909c0e021e1ee69ce2bbfbe21c9c93ab49c 100644 (file)
@@ -35,7 +35,6 @@
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package
 
 with Interfaces.C;
-with System.Parameters;
 
 package System.Linux is
    pragma Preelaborate;
@@ -44,25 +43,8 @@ package System.Linux is
    -- Time --
    ----------
 
-   subtype int         is Interfaces.C.int;
-   subtype long        is Interfaces.C.long;
-   subtype suseconds_t is Interfaces.C.long;
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
    subtype clockid_t   is Interfaces.C.int;
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
-   type timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, timeval);
-
    -----------
    -- Errno --
    -----------
index 3ad7f45379eb3bb5e084e1c5d520b77d1b9d60b3..6a575c7a865e2f71e02cc9812df140b98200391d 100644 (file)
@@ -35,7 +35,6 @@
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package
 
 with Interfaces.C;
-with System.Parameters;
 
 package System.Linux is
    pragma Preelaborate;
@@ -44,25 +43,8 @@ package System.Linux is
    -- Time --
    ----------
 
-   subtype int         is Interfaces.C.int;
-   subtype long        is Interfaces.C.long;
-   subtype suseconds_t is Interfaces.C.long;
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
    subtype clockid_t   is Interfaces.C.int;
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
-   type timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, timeval);
-
    -----------
    -- Errno --
    -----------
@@ -125,8 +107,8 @@ package System.Linux is
 
    --  struct_sigaction offsets
 
-   sa_handler_pos : constant := int'Size / 8;
-   sa_mask_pos    : constant := int'Size / 8 +
+   sa_handler_pos : constant := Interfaces.C.int'Size / 8;
+   sa_mask_pos    : constant := Interfaces.C.int'Size / 8 +
                                 Standard'Address_Size / 8;
    sa_flags_pos   : constant := 0;
 
index 867cb1fa8070588be9f724aaf0bc255cb901d58c..ad0a07b8c5060b6531152d4a3f1ceb3ee8c302b2 100644 (file)
@@ -35,7 +35,6 @@
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package
 
 with Interfaces.C;
-with System.Parameters;
 
 package System.Linux is
    pragma Preelaborate;
@@ -44,25 +43,8 @@ package System.Linux is
    -- Time --
    ----------
 
-   subtype int         is Interfaces.C.int;
-   subtype long        is Interfaces.C.long;
-   subtype suseconds_t is Interfaces.C.long;
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
    subtype clockid_t   is Interfaces.C.int;
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
-   type timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, timeval);
-
    -----------
    -- Errno --
    -----------
@@ -125,8 +107,8 @@ package System.Linux is
    --  struct_sigaction offsets
 
    sa_handler_pos : constant := 0;
-   sa_mask_pos    : constant := long'Size / 8;
-   sa_flags_pos   : constant := long'Size / 8 + 128;
+   sa_mask_pos    : constant := Interfaces.C.long'Size / 8;
+   sa_flags_pos   : constant := Interfaces.C.long'Size / 8 + 128;
 
    SA_SIGINFO  : constant := 16#04#;
    SA_ONSTACK  : constant := 16#08000000#;
index 5ff201cf832c44e6dba0c2421be249a673aa7c3d..037834617d726087d42f1e10b8ce54326b9a1de4 100644 (file)
@@ -36,7 +36,6 @@
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package
 
 with Interfaces.C;
-with System.Parameters;
 
 package System.Linux is
    pragma Preelaborate;
@@ -45,24 +44,8 @@ package System.Linux is
    -- Time --
    ----------
 
-   subtype long        is Interfaces.C.long;
-   subtype suseconds_t is Interfaces.C.long;
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
    subtype clockid_t   is Interfaces.C.int;
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
-   type timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, timeval);
-
    -----------
    -- Errno --
    -----------
diff --git a/gcc/ada/libgnarl/s-linux__x32.ads b/gcc/ada/libgnarl/s-linux__x32.ads
deleted file mode 100644 (file)
index 6144b8b..0000000
+++ /dev/null
@@ -1,133 +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-2025, 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;
-
-with System.Parameters;
-
-package System.Linux is
-   pragma Preelaborate;
-
-   ----------
-   -- Time --
-   ----------
-
-   subtype suseconds_t is Long_Long_Integer;
-   --  Note that suseconds_t is 64 bits.
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-   subtype clockid_t   is Interfaces.C.int;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : Long_Long_Integer;
-      --  Note that tv_nsec is 64 bits.
-   end record;
-   pragma Convention (C, timespec);
-
-   type timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, timeval);
-
-   -----------
-   -- 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;
index da057d47cf5b7652cd00a6d1280769730df951e4..3a2df424d91bf1327dd3c5f1374d1cca172fe8e5 100644 (file)
@@ -35,15 +35,6 @@ package body System.OS_Interface is
 
    use Interfaces.C;
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
-   end To_Duration;
-
    ------------------------
    -- To_Target_Priority --
    ------------------------
@@ -72,29 +63,6 @@ package body System.OS_Interface is
       end if;
    end To_Target_Priority;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F is negative due to a round-up, adjust for positive F value
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(tv_sec => S,
-                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
    -----------------
    -- sched_yield --
    -----------------
index 1e115b80d6fb46daea7c73b07f1430bfaa3af316..eb417a2cc9994f4c2ec6c69d32d61a2f68352a6e 100644 (file)
@@ -43,8 +43,8 @@ with Ada.Unchecked_Conversion;
 with Interfaces.C;
 with Interfaces.C.Extensions;
 
+with System.C_Time;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -200,26 +200,18 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported
 
-   type timespec is private;
-
    type clockid_t is new long_long;
 
    function clock_gettime
      (clock_id : clockid_t;
-      tp       : access timespec) return int;
+      tp       : access C_Time.timespec) return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    type struct_timezone is record
       tz_minuteswest : int;
       tz_dsttime     : int;
@@ -420,7 +412,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    --------------------------
@@ -543,15 +535,6 @@ private
 
    type pid_t is new int;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    type pthread_attr_t is new System.Address;
    pragma Convention (C, pthread_attr_t);
    --  typedef struct __pt_attr        *pthread_attr_t;
index 4383860ed2b11cc0a7aee0b7a5c5d633c7c0c7e3..bf774fc491af7db613df29ba2f09256609a5aaf1 100644 (file)
@@ -42,10 +42,10 @@ with Ada.Unchecked_Conversion;
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.Linux;
 with System.OS_Constants;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -213,25 +213,17 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported
 
-   type timespec is private;
-
    type clockid_t is new int;
 
    function clock_gettime
-     (clock_id : clockid_t; tp : access timespec) return int;
+     (clock_id : clockid_t; tp : access C_Time.timespec) return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    function sysconf (name : int) return long;
    pragma Import (C, sysconf);
 
@@ -463,7 +455,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    --------------------------
@@ -630,15 +622,6 @@ private
 
    type pid_t is new int;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    type unsigned_long_long_t is mod 2 ** 64;
    --  Local type only used to get the alignment of this type below
 
index d9dae354d41e930adb6965457c73b40f874f3a71..350fa1f15ad9c8a0638ddedb5ff0ceb689c97578 100644 (file)
@@ -44,8 +44,8 @@ with Ada.Unchecked_Conversion;
 with Interfaces;
 with Interfaces.C;
 
+with System.C_Time;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -232,30 +232,22 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
 
-   type timespec is private;
-
-   function nanosleep (rqtp, rmtp : access timespec) return int;
+   function nanosleep (rqtp, rmtp : access C_Time.timespec) return int;
    pragma Import (C, nanosleep, "nanosleep");
 
    type clockid_t is new int;
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
    function clock_gettime
      (clock_id : clockid_t;
-      tp       : access timespec)
+      tp       : access C_Time.timespec)
       return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    type struct_timezone is record
       tz_minuteswest : int;
       tz_dsttime     : int;
@@ -463,7 +455,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    --------------------------
@@ -664,15 +656,6 @@ private
 
    Self_PID : constant pid_t := 0;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      ts_sec  : time_t;
-      ts_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    type pthread_t           is new System.Address;
    type pthread_attr_t      is new System.Address;
    type pthread_mutexattr_t is new System.Address;
index f512210d3437ae60e77f9bb2130406193669e4bd..eeafbdbef8f16ae03c2034af1127175fa36caa7d 100644 (file)
@@ -36,15 +36,6 @@ with Interfaces.C.Extensions;
 package body System.OS_Interface is
    use Interfaces.C;
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
-   end To_Duration;
-
    ------------------------
    -- To_Target_Priority --
    ------------------------
@@ -56,37 +47,13 @@ package body System.OS_Interface is
       return Interfaces.C.int (Prio);
    end To_Target_Priority;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(tv_sec => S,
-        tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
    -------------------
    -- clock_gettime --
    -------------------
 
    function clock_gettime
      (clock_id : clockid_t;
-      tp       : access timespec) return int
+      tp       : access C_Time.timespec) return int
    is
       pragma Unreferenced (clock_id);
 
@@ -94,33 +61,18 @@ package body System.OS_Interface is
 
       use Interfaces;
 
-      type timeval is array (1 .. 3) of C.long;
-      --  The timeval array is sized to contain long_long sec and long usec.
-      --  If long_long'Size = long'Size then it will be overly large but that
-      --  won't effect the implementation since it's not accessed directly.
-
-      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;
-      TV     : aliased timeval;
+      TV     : aliased C_Time.timeval;
       Result : int;
 
       function gettimeofday
-        (Tv : access timeval;
+        (Tv : access C_Time.timeval;
          Tz : System.Address := System.Null_Address) return int;
       pragma Import (C, gettimeofday, "gettimeofday");
 
    begin
       Result := gettimeofday (TV'Access, System.Null_Address);
       pragma Assert (Result = 0);
-      timeval_to_duration (TV'Access, sec'Access, usec'Access);
-      tp.all := To_Timespec (Duration (sec) + Duration (usec) / Micro);
+      tp.all := C_Time.To_Timespec (TV);
       return Result;
    end clock_gettime;
 
@@ -130,13 +82,12 @@ package body System.OS_Interface is
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int
+      res      : access C_Time.timespec) return int
    is
       pragma Unreferenced (clock_id);
 
       --  Darwin Threads don't have clock_getres.
 
-      Nano   : constant := 10**9;
       nsec   : int := 0;
       Result : int := -1;
 
@@ -145,7 +96,7 @@ package body System.OS_Interface is
 
    begin
       nsec := clock_get_res;
-      res.all := To_Timespec (Duration (0.0) + Duration (nsec) / Nano);
+      res.all := C_Time.Nanoseconds_To_Timespec (nsec);
 
       if nsec > 0 then
          Result := 0;
index ea62f24cbc0d6cfc508c1e1eef0606db947f2f5d..1b2a40b3cbe8c03ef29c53b704b873d6785ffe78 100644 (file)
@@ -40,9 +40,9 @@
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.OS_Constants;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -184,23 +184,15 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported
 
-   type timespec is private;
-
    type clockid_t is new int;
 
    function clock_gettime
      (clock_id : clockid_t;
-      tp       : access timespec) return int;
+      tp       : access C_Time.timespec) return int;
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
-
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
+      res      : access C_Time.timespec) return int;
 
    -------------------------
    -- Priority Scheduling --
@@ -397,7 +389,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    --------------------------
@@ -517,15 +509,6 @@ private
 
    type pid_t is new int32_t;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    --
    --  Darwin specific signal implementation
    --
index 73061d9eeb0c0f94a2ad85c9b1f52d312cf73d30..adfbaeb27fc71570eebc80270ee38ff611d64afb 100644 (file)
@@ -69,15 +69,6 @@ package body System.OS_Interface is
       null;
    end pthread_init;
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.ts_sec) + Duration (TS.ts_nsec) / 10#1#E9;
-   end To_Duration;
-
    ------------------------
    -- To_Target_Priority --
    ------------------------
@@ -89,28 +80,4 @@ package body System.OS_Interface is
       return Interfaces.C.int (Prio);
    end To_Target_Priority;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(ts_sec => S,
-                       ts_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
 end System.OS_Interface;
index 00dc11de27455b2091881c1fc139144cac386520..9e7b88e3c6e993a3e34f9c9b46c8a0af0b29d218 100644 (file)
@@ -43,8 +43,8 @@ with Ada.Unchecked_Conversion;
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -198,30 +198,22 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
 
-   type timespec is private;
-
-   function nanosleep (rqtp, rmtp : access timespec)  return int;
+   function nanosleep (rqtp, rmtp : access C_Time.timespec)  return int;
    pragma Import (C, nanosleep, "nanosleep");
 
    type clockid_t is new unsigned_long;
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
    function clock_gettime
      (clock_id : clockid_t;
-      tp       : access timespec)
+      tp       : access C_Time.timespec)
       return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    type struct_timezone is record
       tz_minuteswest : int;
       tz_dsttime     : int;
@@ -432,7 +424,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    Relative_Timed_Wait : constant Boolean := False;
@@ -636,15 +628,6 @@ private
 
    type pid_t is new int;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      ts_sec  : time_t;
-      ts_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    type pthread_t           is new System.Address;
    type pthread_attr_t      is new System.Address;
    type pthread_mutexattr_t is new System.Address;
index a3240bb38d18b061b3a18442bf3064fff62e7382..4516935bbc8e88629bc5d601f002eb6867e41e9b 100644 (file)
@@ -69,15 +69,6 @@ package body System.OS_Interface is
       null;
    end pthread_init;
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.ts_sec) + Duration (TS.ts_nsec) / 10#1#E9;
-   end To_Duration;
-
    ------------------------
    -- To_Target_Priority --
    ------------------------
@@ -89,27 +80,4 @@ package body System.OS_Interface is
       return Interfaces.C.int (Prio);
    end To_Target_Priority;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(ts_sec => S,
-                       ts_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
 end System.OS_Interface;
index b10270a4cc49d1fb7ab315b69d32f9f02d8cd5c1..027f81d060bfec26b47312c9f6bf11ffb0ad8a02 100644 (file)
@@ -43,8 +43,8 @@ with Ada.Unchecked_Conversion;
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -198,30 +198,22 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
 
-   type timespec is private;
-
-   function nanosleep (rqtp, rmtp : access timespec) return int;
+   function nanosleep (rqtp, rmtp : access C_Time.timespec) return int;
    pragma Import (C, nanosleep, "nanosleep");
 
    type clockid_t is new int;
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
    function clock_gettime
      (clock_id : clockid_t;
-      tp       : access timespec)
+      tp       : access C_Time.timespec)
       return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    type struct_timezone is record
       tz_minuteswest : int;
       tz_dsttime     : int;
@@ -431,7 +423,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    --------------------------
@@ -633,15 +625,6 @@ private
    type pid_t is new int;
    Self_PID : constant pid_t := 0;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      ts_sec  : time_t;
-      ts_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    type pthread_t           is new System.Address;
    type pthread_attr_t      is new System.Address;
    type pthread_mutexattr_t is new System.Address;
index 675cd0d939906681a2ffba791c9fdf772dfe9aa2..2c70f0dea157ce37d0e60b8657c2c32ddeac8494 100644 (file)
@@ -93,15 +93,6 @@ package body System.OS_Interface is
       return 0;
    end pthread_setschedparam;
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
-   end To_Duration;
-
    ------------------------
    -- To_Target_Priority --
    ------------------------
@@ -113,28 +104,4 @@ package body System.OS_Interface is
       return Interfaces.C.int (Prio);
    end To_Target_Priority;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(tv_sec => S,
-                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
 end System.OS_Interface;
index 870059d09670a5ee543a96bb7cd9f0ba97165385..18410c60415e776bdc0db5fe25a61b871c911a74 100644 (file)
@@ -42,8 +42,8 @@ with Ada.Unchecked_Conversion;
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -210,9 +210,7 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
 
-   type timespec is private;
-
-   function nanosleep (rqtp, rmtp : access timespec) return int;
+   function nanosleep (rqtp, rmtp : access C_Time.timespec) return int;
    pragma Import (C, nanosleep, "nanosleep");
 
    type clockid_t is new int;
@@ -221,21 +219,15 @@ package System.OS_Interface is
    --  From: /usr/include/time.h
    function clock_gettime
      (clock_id : clockid_t;
-      tp       : access timespec)
+      tp       : access C_Time.timespec)
       return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    --  From: /usr/include/unistd.h
    function sysconf (name : int) return long;
    pragma Import (C, sysconf);
@@ -487,7 +479,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    Relative_Timed_Wait : constant Boolean := False;
@@ -656,15 +648,6 @@ private
 
    type pid_t is new int;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    --  From: /usr/include/pthread/pthreadtypes.h:
    --  typedef struct __pthread_attr pthread_attr_t;
    --  /usr/include/i386-gnu/bits/thread-attr.h: struct __pthread_attr...
index 9d0f26d50f705ef32dbb2555b02d20c55cb113fc..60fab698113bc49cd31a59e254b75fb7dfdb7690 100644 (file)
@@ -42,8 +42,8 @@ with Ada.Unchecked_Conversion;
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -181,26 +181,18 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported
 
-   type timespec is private;
-
    type clockid_t is new int;
 
    function clock_gettime
      (clock_id : clockid_t;
-      tp       : access timespec) return int;
+      tp       : access C_Time.timespec) return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    type struct_timezone is record
       tz_minuteswest : int;
       tz_dsttime     : int;
@@ -400,7 +392,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    --------------------------
@@ -517,15 +509,6 @@ private
 
    type pid_t is new int;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    type pthread_attr_t is new int;
    type pthread_condattr_t is new int;
    type pthread_mutexattr_t is new int;
index 9924659cce5de8a91aace2625e3d19a1558fd1cf..fc6d7a992f198afcb54c0935462384f7dd61d281 100644 (file)
@@ -42,8 +42,8 @@ with Ada.Unchecked_Conversion;
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -205,9 +205,7 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
 
-   type timespec is private;
-
-   function nanosleep (rqtp, rmtp : access timespec) return int;
+   function nanosleep (rqtp, rmtp : access C_Time.timespec) return int;
    pragma Import (C, nanosleep, "nanosleep");
 
    type clockid_t is new int;
@@ -215,21 +213,15 @@ package System.OS_Interface is
 
    function clock_gettime
      (clock_id : clockid_t;
-      tp       : access timespec)
+      tp       : access C_Time.timespec)
       return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    function sysconf (name : int) return long;
    pragma Import (C, sysconf);
 
@@ -430,7 +422,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    --------------------------
@@ -602,15 +594,6 @@ private
 
    type pid_t is new int;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    type pthread_attr_t is record
       detachstate   : int;
       schedpolicy   : int;
index 7aeb15da523b3495ba236ccf2d5e2c63308d41fb..2c6b353a5e0ffd296fe8570339c8ae411de9ab21 100644 (file)
@@ -42,6 +42,7 @@ with Ada.Unchecked_Conversion;
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.Linux;
 with System.OS_Constants;
 with System.OS_Locks;
@@ -54,8 +55,6 @@ package System.OS_Interface is
 
    pragma Linker_Options ("-lpthread");
 
-   use type System.Linux.time_t;
-
    subtype int            is Interfaces.C.int;
    subtype char           is Interfaces.C.char;
    subtype short          is Interfaces.C.short;
@@ -229,26 +228,17 @@ package System.OS_Interface is
    -- Time --
    ----------
 
-   subtype time_t    is System.Linux.time_t;
-   subtype timespec  is System.Linux.timespec;
-   subtype timeval   is System.Linux.timeval;
    subtype clockid_t is System.Linux.clockid_t;
 
    function clock_gettime
-     (clock_id : clockid_t; tp : access timespec) return int;
+     (clock_id : clockid_t; tp : access C_Time.timespec) return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    function sysconf (name : int) return long;
    pragma Import (C, sysconf);
 
@@ -457,7 +447,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    --------------------------
index 88758a954f8ae6d31c3e9b003ef84a8b078eecf7..beeefb617fe9b837477ed83634568cc9f751f068 100644 (file)
@@ -85,15 +85,6 @@ package body System.OS_Interface is
       return int (sysconf (SC_PAGESIZE));
    end Get_Page_Size;
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
-   end To_Duration;
-
    ------------------------
    -- To_Target_Priority --
    ------------------------
@@ -105,29 +96,6 @@ package body System.OS_Interface is
       return Interfaces.C.int (Prio);
    end To_Target_Priority;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F is negative due to a round-up, adjust for positive F value
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(tv_sec => S,
-                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
    -------------
    -- sigwait --
    -------------
index 8b31e204acb5ec1e0708531ded53b2a7ce6c2e4b..dcc36b25185779be18e5ebdfae60103ec27f0d34 100644 (file)
@@ -42,9 +42,9 @@ with Ada.Unchecked_Conversion;
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.Multiprocessors;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -193,26 +193,18 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported
 
-   type timespec is private;
-
    type clockid_t is new int;
 
    function clock_gettime
      (clock_id : clockid_t;
-      tp       : access timespec) return int;
+      tp       : access C_Time.timespec) return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    type struct_timezone is record
       tz_minuteswest : int;
       tz_dsttime     : int;
@@ -220,8 +212,6 @@ package System.OS_Interface is
    pragma Convention (C, struct_timezone);
    type struct_timezone_ptr is access all struct_timezone;
 
-   type struct_timeval is private;
-
    -------------------------
    -- Priority Scheduling --
    -------------------------
@@ -415,7 +405,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    --------------------------
@@ -541,23 +531,6 @@ private
 
    type pid_t is new long;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type suseconds_t is new int;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
-   type struct_timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, struct_timeval);
-
    type st_attr is record
       stksize      : int;
       prio         : int;
index 1cb4f23aec6ee1f7ff7901fd5ee1ad2205b7e69f..2d9baeb7f363272be87c6a609945a372cd6be770 100644 (file)
@@ -36,6 +36,7 @@
 --  that are needed by children of System.
 
 with Interfaces.C; use Interfaces.C;
+
 package body System.OS_Interface is
 
    --------------------
@@ -58,15 +59,6 @@ package body System.OS_Interface is
       null;
    end pthread_init;
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
-   end To_Duration;
-
    ------------------------
    -- To_Target_Priority --
    ------------------------
@@ -78,28 +70,4 @@ package body System.OS_Interface is
       return Interfaces.C.int (Prio);
    end To_Target_Priority;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(tv_sec => S,
-                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
 end System.OS_Interface;
index 720022548df1ea24c2a6dd2a138fa00ccbe5b217..bf95b0eab34fe99094b039fc072cde818c2011c4 100644 (file)
@@ -36,6 +36,7 @@
 --  that are needed by children of System.
 
 with Interfaces.C; use Interfaces.C;
+
 package body System.OS_Interface is
 
    -----------------
@@ -70,15 +71,6 @@ package body System.OS_Interface is
       null;
    end pthread_init;
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
-   end To_Duration;
-
    ------------------------
    -- To_Target_Priority --
    ------------------------
@@ -90,28 +82,4 @@ package body System.OS_Interface is
       return Interfaces.C.int (Prio);
    end To_Target_Priority;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(tv_sec => S,
-                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
 end System.OS_Interface;
index ea940d86330dac658a8110f1f7995e9d1033a8ba..ee13235d891b61eee596da94bf144f3a649a50b2 100644 (file)
@@ -41,9 +41,9 @@ with Ada.Unchecked_Conversion;
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.OS_Constants;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -213,25 +213,17 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported
 
-   type timespec is private;
-
    type clockid_t is new int;
 
    function clock_gettime
-     (clock_id : clockid_t; tp : access timespec) return int;
+     (clock_id : clockid_t; tp : access C_Time.timespec) return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    -------------------------
    -- Priority Scheduling --
    -------------------------
@@ -418,7 +410,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    --------------------------
@@ -572,15 +564,6 @@ private
 
    type pid_t is new int;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    type unsigned_long_long_t is mod 2 ** 64;
    --  Local type only used to get the alignment of this type below
 
index c0f6c265b509b011f58789752fbb00a39a991aa5..efd602e73f82edc3d1855d48fed4be20d2bd7d7a 100644 (file)
@@ -92,15 +92,6 @@ package body System.OS_Interface is
      return int
      with Import, External_Name => "rtems_semaphore_release", Convention => C;
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
-   end To_Duration;
-
    ------------------------
    -- To_Target_Priority --
    ------------------------
@@ -112,27 +103,6 @@ package body System.OS_Interface is
       return Interfaces.C.int (Prio);
    end To_Target_Priority;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to round-up, adjust for positive F value
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-      return timespec'(tv_sec => S,
-                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
    -----------------------------
    -- Binary_Semaphore_Create --
    -----------------------------
index 21b1be8a306a4b6b8713618de9d73070af60234c..184d4897836442789a76a61d7da09db525e807c3 100644 (file)
@@ -52,9 +52,9 @@
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.OS_Constants;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -181,8 +181,6 @@ package System.OS_Interface is
    Time_Slice_Supported : constant Boolean := True;
    --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
 
-   type timespec is private;
-
    type clockid_t is new int;
 
    CLOCK_REALTIME  : constant clockid_t;
@@ -190,20 +188,14 @@ package System.OS_Interface is
 
    function clock_gettime
      (clock_id : clockid_t;
-      tp       : access timespec) return int;
+      tp       : access C_Time.timespec) return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
    function clock_getres
      (clock_id : clockid_t;
-      res      : access timespec) return int;
+      res      : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    -------------------------
    -- Priority Scheduling --
    -------------------------
@@ -428,7 +420,7 @@ package System.OS_Interface is
    function pthread_cond_timedwait
      (cond    : access pthread_cond_t;
       mutex   : access pthread_mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
 
    --------------------------
@@ -454,8 +446,8 @@ package System.OS_Interface is
    type struct_sched_param is record
       sched_priority      : int;
       ss_low_priority     : int;
-      ss_replenish_period : timespec;
-      ss_initial_budget   : timespec;
+      ss_replenish_period : C_Time.timespec;
+      ss_initial_budget   : C_Time.timespec;
       sched_ss_max_repl   : int;
    end record;
    pragma Convention (C, struct_sched_param);
@@ -591,15 +583,6 @@ private
 
    type pid_t is new int;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    CLOCK_REALTIME :  constant clockid_t := System.OS_Constants.CLOCK_REALTIME;
    CLOCK_MONOTONIC : constant clockid_t := System.OS_Constants.CLOCK_MONOTONIC;
 
index e5626fc4f0d85c2aa48451d0edd2eabc99739b83..78144efdbcdbac575c548050b7d2115063ca170b 100644 (file)
 --  This package encapsulates all direct interfaces to OS services
 --  that are needed by children of System.
 
-with Interfaces.C; use Interfaces.C;
-
 package body System.OS_Interface is
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
-   end To_Duration;
-
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(tv_sec  => S,
-                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
    ------------------
    -- pthread_init --
    ------------------
index d62dd37110eb9db39e365a879531a7876c1f67a1..e9b59fe1ca925d1c89df4dbdf047cb530d2a761e 100644 (file)
@@ -42,8 +42,8 @@ with Ada.Unchecked_Conversion;
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.OS_Locks;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -241,24 +241,16 @@ package System.OS_Interface is
    -- Time --
    ----------
 
-   type timespec is private;
-
    type clockid_t is new int;
 
    function clock_gettime
-     (clock_id : clockid_t; tp : access timespec) return int;
+     (clock_id : clockid_t; tp : access C_Time.timespec) return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
    function clock_getres
-     (clock_id : clockid_t; res : access timespec) return int;
+     (clock_id : clockid_t; res : access C_Time.timespec) return int;
    pragma Import (C, clock_getres, "clock_getres");
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-
    function sysconf (name : int) return long;
    pragma Import (C, sysconf);
 
@@ -347,7 +339,7 @@ package System.OS_Interface is
    function cond_timedwait
      (cond    : access cond_t;
       mutex   : access mutex_t;
-      abstime : access timespec) return int;
+      abstime : access C_Time.timespec) return int;
    pragma Import (C, cond_timedwait, "cond_timedwait");
 
    function cond_signal (cond : access cond_t) return int;
@@ -526,15 +518,6 @@ private
 
    type pid_t is new long;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    type array_type_9 is array (0 .. 3) of unsigned_char;
    type record_type_3 is record
       flag  : array_type_9;
index 5c227a1e54c83430d7d1909877bcedece2f3e5cc..0b2b5d442698a32c5d547f62476e5efb54412efb 100644 (file)
@@ -41,38 +41,6 @@ package body System.OS_Interface is
    Low_Priority : constant := 255;
    --  VxWorks native (default) lowest scheduling priority
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.ts_sec) + Duration (TS.ts_nsec) / 10#1#E9;
-   end To_Duration;
-
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F is negative due to a round-up, adjust for positive F value
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(ts_sec  => S,
-                       ts_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
    -------------------------
    -- To_VxWorks_Priority --
    -------------------------
index a4095735bd6d91f6710455b47db4e00aea4937b5..ecb63440a5dbe0a21c88c0d21f99123a5a9c6125 100644 (file)
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.VxWorks;
 with System.VxWorks.Ext;
 with System.Multiprocessors;
-with System.Parameters;
 
 package System.OS_Interface is
    pragma Preelaborate;
@@ -244,37 +244,13 @@ package System.OS_Interface is
    -- Time --
    ----------
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-   --  Time_t here used to be unsigned to match the VxWorks header declaration.
-   --  The header declaration has changed in newer releases and is now signed
-   --  for applications.
-
-   type timespec is record
-      ts_sec  : time_t;
-      ts_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
    type clockid_t is new int;
 
-   function To_Duration (TS : timespec) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timespec (D : Duration) return timespec;
-   pragma Inline (To_Timespec);
-   --  Convert a Duration value to a timespec value. Note that in VxWorks,
-   --  timespec is always non-negative (since time_t is defined above as
-   --  unsigned long). This means that there is a potential problem if a
-   --  negative argument is passed for D. However, in actual usage, the
-   --  value of the input argument D is always non-negative, so no problem
-   --  arises in practice.
-
    function To_Clock_Ticks (D : Duration) return int;
    --  Convert a duration value (in seconds) into clock ticks
 
    function clock_gettime
-     (clock_id : clockid_t; tp : access timespec) return int;
+     (clock_id : clockid_t; tp : access C_Time.timespec) return int;
    pragma Import (C, clock_gettime, "clock_gettime");
 
    ----------------------
index 27313a4bcc07aba9a264e47d7bb47f5bd7a06012..2e6585352d3d0f0f9d28321654e3dfdb832badcf 100644 (file)
@@ -35,7 +35,7 @@
 --  This package encapsulates all direct interfaces to OS services
 --  that are needed by children of System.
 
-with Interfaces.C; use Interfaces.C;
+with Interfaces.C;
 
 package body System.OS_Interface is
 
@@ -59,15 +59,6 @@ package body System.OS_Interface is
       null;
    end pthread_init;
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
-   end To_Duration;
-
    ------------------------
    -- To_Target_Priority --
    ------------------------
@@ -79,28 +70,4 @@ package body System.OS_Interface is
       return Interfaces.C.int (Prio);
    end To_Target_Priority;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(tv_sec => S,
-                       tv_nsec => Long_Long_Integer (F * 10#1#E9));
-   end To_Timespec;
-
 end System.OS_Interface;
index 1197be15ef6c558b0e63cdee7936f6664b3725a1..f342ad67305659253ca88261060aed6cc519db15 100644 (file)
@@ -37,8 +37,6 @@
 
 with Interfaces.C;
 
-with System.Parameters;
-
 package System.QNX is
    pragma Preelaborate;
 
@@ -46,24 +44,8 @@ package System.QNX is
    -- Time --
    ----------
 
-   subtype long        is Interfaces.C.long;
-   subtype suseconds_t is Interfaces.C.long;
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
    subtype clockid_t   is Interfaces.C.int;
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : long;
-   end record;
-   pragma Convention (C, timespec);
-
-   type timeval is record
-      tv_sec  : time_t;
-      tv_usec : suseconds_t;
-   end record;
-   pragma Convention (C, timeval);
-
    -----------
    -- Errno --
    -----------
index 8edc58ea9d804c436b6c794ba68c04d934c21f92..1b65100362c4bb71d8614aec5c066956bd5202ae 100644 (file)
@@ -36,6 +36,7 @@
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.Interrupt_Management;
 with System.Multiprocessors;
 with System.OS_Constants;
@@ -762,12 +763,12 @@ package body System.Task_Primitives.Operations is
    ---------------------
 
    function Monotonic_Clock return Duration is
-      TS     : aliased timespec;
+      TS     : aliased C_Time.timespec;
       Result : Interfaces.C.int;
    begin
       Result := clock_gettime (OSC.CLOCK_RT_Ada, TS'Unchecked_Access);
       pragma Assert (Result = 0);
-      return To_Duration (TS);
+      return C_Time.To_Duration (TS);
    end Monotonic_Clock;
 
    -------------------
@@ -775,13 +776,13 @@ package body System.Task_Primitives.Operations is
    -------------------
 
    function RT_Resolution return Duration is
-      TS     : aliased timespec;
+      TS     : aliased C_Time.timespec;
       Result : Interfaces.C.int;
    begin
       Result := clock_getres (OSC.CLOCK_REALTIME, TS'Unchecked_Access);
       pragma Assert (Result = 0);
 
-      return To_Duration (TS);
+      return C_Time.To_Duration (TS);
    end RT_Resolution;
 
    -----------
@@ -1175,7 +1176,7 @@ package body System.Task_Primitives.Operations is
       Base_Time  : constant Duration := Monotonic_Clock;
       Check_Time : Duration := Base_Time;
       Abs_Time   : Duration;
-      Request    : aliased timespec;
+      Request    : aliased C_Time.timespec;
       Result     : Interfaces.C.int;
 
    begin
@@ -1189,7 +1190,7 @@ package body System.Task_Primitives.Operations is
          else Duration'Min (Check_Time + Max_Sensible_Delay, Time));
 
       if Abs_Time > Check_Time then
-         Request := To_Timespec (Abs_Time);
+         Request := C_Time.To_Timespec (Abs_Time);
          loop
             exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level;
 
@@ -1230,7 +1231,7 @@ package body System.Task_Primitives.Operations is
       Base_Time  : constant Duration := Monotonic_Clock;
       Check_Time : Duration := Base_Time;
       Abs_Time   : Duration;
-      Request    : aliased timespec;
+      Request    : aliased C_Time.timespec;
       Result     : Interfaces.C.int;
       Yielded    : Boolean := False;
 
@@ -1243,7 +1244,7 @@ package body System.Task_Primitives.Operations is
          else Duration'Min (Check_Time + Max_Sensible_Delay, Time));
 
       if Abs_Time > Check_Time then
-         Request := To_Timespec (Abs_Time);
+         Request := C_Time.To_Timespec (Abs_Time);
          Self_ID.Common.State := Delay_Sleep;
 
          pragma Assert (Check_Sleep (Delay_Sleep));
index a0f1885a7e8db04b1144fac79ecf590cb659d4e8..a4dab5fa9d1e6bb7a312c615344c565fc2430d0d 100644 (file)
@@ -38,6 +38,7 @@ with Ada.Unchecked_Conversion;
 
 with Interfaces.C;
 
+with System.C_Time;
 with System.Float_Control;
 with System.Interrupt_Management;
 with System.Multiprocessors;
@@ -681,12 +682,12 @@ package body System.Task_Primitives.Operations is
    ---------------------
 
    function Monotonic_Clock return Duration is
-      TS     : aliased timespec;
+      TS     : aliased C_Time.timespec;
       Result : int;
    begin
       Result := clock_gettime (OSC.CLOCK_RT_Ada, TS'Unchecked_Access);
       pragma Assert (Result = 0);
-      return To_Duration (TS);
+      return C_Time.To_Duration (TS);
    end Monotonic_Clock;
 
    -------------------
index 9ff1ecdc329fb2ee9cc2dcad0ddf30545745603c..547a5e44abcd0a8e1c12b465422eaa95be539ab6 100644 (file)
@@ -31,6 +31,8 @@
 
 --  This is the Monotonic version of this package for Posix and Linux targets.
 
+with System.C_Time;
+
 separate (System.Task_Primitives.Operations)
 package body Monotonic is
 
@@ -54,14 +56,14 @@ package body Monotonic is
    ---------------------
 
    function Monotonic_Clock return Duration is
-      TS     : aliased timespec;
+      TS     : aliased C_Time.timespec;
       Result : Interfaces.C.int;
    begin
       Result := clock_gettime
         (clock_id => OSC.CLOCK_RT_Ada, tp => TS'Unchecked_Access);
       pragma Assert (Result = 0);
 
-      return To_Duration (TS);
+      return C_Time.To_Duration (TS);
    end Monotonic_Clock;
 
    -------------------
@@ -69,14 +71,14 @@ package body Monotonic is
    -------------------
 
    function RT_Resolution return Duration is
-      TS     : aliased timespec;
+      TS     : aliased C_Time.timespec;
       Result : Interfaces.C.int;
 
    begin
       Result := clock_getres (OSC.CLOCK_REALTIME, TS'Unchecked_Access);
       pragma Assert (Result = 0);
 
-      return To_Duration (TS);
+      return C_Time.To_Duration (TS);
    end RT_Resolution;
 
    ----------------------
@@ -150,7 +152,7 @@ package body Monotonic is
       Abs_Time   : Duration;
       P_Abs_Time : Duration;
 
-      Request    : aliased timespec;
+      Request    : aliased C_Time.timespec;
       Result     : Interfaces.C.int;
       Exit_Outer : Boolean := False;
 
@@ -184,7 +186,7 @@ package body Monotonic is
             end if;
             pragma Warnings (On);
 
-            Request := To_Timespec (P_Abs_Time);
+            Request := C_Time.To_Timespec (P_Abs_Time);
 
             Inner : loop
                exit Outer
@@ -236,7 +238,7 @@ package body Monotonic is
       Check_Time : Duration;
       Abs_Time   : Duration;
       P_Abs_Time : Duration;
-      Request    : aliased timespec;
+      Request    : aliased C_Time.timespec;
 
       Result     : Interfaces.C.int;
       Exit_Outer : Boolean := False;
@@ -271,7 +273,7 @@ package body Monotonic is
             end if;
             pragma Warnings (On);
 
-            Request := To_Timespec (P_Abs_Time);
+            Request := C_Time.To_Timespec (P_Abs_Time);
 
             Inner : loop
                exit Outer
similarity index 59%
rename from gcc/ada/libgnarl/s-osinte__android.adb
rename to gcc/ada/libgnat/g-c_time.ads
index 3e36d284c918dadb588f27c580aa14a6b1c9d800..02461955b2f4b5f0d7b3d0aaa511ea490333f50f 100644 (file)
@@ -1,12 +1,12 @@
 ------------------------------------------------------------------------------
 --                                                                          --
---                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
+--                         GNAT RUN-TIME COMPONENTS                         --
 --                                                                          --
---                   S Y S T E M . O S _ I N T E R F A C E                  --
+--                           G N A T . C _ T I M E                          --
 --                                                                          --
---                                   B o d y                                --
+--                                 S p e c                                  --
 --                                                                          --
---                     Copyright (C) 1995-2025, AdaCore                     --
+--                       Copyright (C) 2025, AdaCore                        --
 --                                                                          --
 -- 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- --
 -- 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.     --
+-- GNAT was originally developed  by the GNAT team at  New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  This is an Android version of this package.
+--  This package provides the time_t, timeval and timespec types corresponding
+--  to the C types defined by the OS, as well as various conversion functions.
 
---  This package encapsulates all direct interfaces to OS services
---  that are needed by children of System.
+--  See file s-c_time.ads for full documentation of the interface
 
-with Interfaces.C;            use Interfaces.C;
-
-package body System.OS_Interface is
-
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (TS : timespec) return Duration is
-   begin
-      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
-   end To_Duration;
-
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return timespec'(tv_sec => S,
-                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
-end System.OS_Interface;
+with System.C_Time;
+package GNAT.C_Time renames System.C_Time;
index a2bc77c1cc7b0d6a3ef2aa4f2b3b96d34e4a3535..80b62b7547f570e61f3a859cbca44b5010402cc7 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with Interfaces.C.Extensions;
-
 package body GNAT.Calendar is
    use Ada.Calendar;
-   use Interfaces;
 
    -----------------
    -- Day_In_Year --
@@ -333,25 +330,8 @@ package body GNAT.Calendar is
    -----------------
 
    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;
-
-      pragma Unsuppress (Overflow_Check);
-
    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;
+      return System.C_Time.To_Duration (T.all);
    end To_Duration;
 
    ----------------
@@ -359,45 +339,8 @@ package body GNAT.Calendar is
    ----------------
 
    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;
-
-      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);
-         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);
-
-      return Result;
+      return System.C_Time.To_Timeval (D);
    end To_Timeval;
 
    ------------------
index a3294993aa6dc3457fe759e35c90414e2c049c32..c57b7df7a220734054b0cc30cd4aa91e172e3656 100644 (file)
@@ -40,7 +40,8 @@
 --  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
 
@@ -126,7 +127,7 @@ package GNAT.Calendar is
    --  locale (equivalent to Clock). Due to this simplified behavior, the
    --  implementation does not require expensive system calls on targets such
    --  as Windows.
-   --  WARNING: Split_At_Locale is no longer aware of historic events and may
+   --  WARNING: Time_At_Locale is no longer aware of historic events and may
    --  produce inaccurate results over DST changes which occurred in the past.
 
    function Week_In_Year (Date : Ada.Calendar.Time) return Week_In_Year_Number;
@@ -145,24 +146,18 @@ 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;
+   subtype timeval is System.C_Time.timeval;
+   pragma Obsolescent (timeval, "use type from GNAT.C_Time instead");
 
    function To_Duration (T : not null access timeval) return Duration;
+   pragma Inline (To_Duration);
+   pragma Obsolescent (To_Duration, "use function from GNAT.C_Time instead");
+
    function To_Timeval  (D : Duration) return timeval;
+   pragma Inline (To_Timeval);
+   pragma Obsolescent (To_Timeval, "use function from GNAT.C_Time instead");
 
 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;
index 0fed79177544d69c7dd9ed5f94445fa54c92f5af..346e79d5c46a0c837c97259301c23a6d12a8719b 100644 (file)
@@ -47,6 +47,7 @@ with GNAT.Sockets.Poll;
 with System;               use System;
 with System.Communication; use System.Communication;
 with System.CRTL;          use System.CRTL;
+with System.C_Time;
 with System.Task_Lock;
 
 package body GNAT.Sockets is
@@ -179,13 +180,6 @@ package body GNAT.Sockets is
    function Value (S : System.Address) return String;
    --  Same as Interfaces.C.Strings.Value but taking a System.Address
 
-   function To_Timeval (Val : Timeval_Duration) return Timeval;
-   --  Separate Val in seconds and microseconds
-
-   function To_Duration (Val : Timeval) return Timeval_Duration;
-   --  Reconstruct a Duration value from a Timeval record (seconds and
-   --  microseconds).
-
    function Dedot (Value : String) return String
    is (if Value /= "" and then Value (Value'Last) = '.'
        then Value (Value'First .. Value'Last - 1)
@@ -528,7 +522,7 @@ package body GNAT.Sockets is
       Res  : C.int;
       Last : C.int;
       RSig : Socket_Type := No_Socket;
-      TVal : aliased Timeval;
+      TVal : aliased System.C_Time.timeval;
       TPtr : Timeval_Access;
 
    begin
@@ -543,7 +537,7 @@ package body GNAT.Sockets is
       if Timeout = Forever then
          TPtr := null;
       else
-         TVal := To_Timeval (Timeout);
+         TVal := System.C_Time.To_Timeval (Timeout);
          TPtr := TVal'Unchecked_Access;
       end if;
 
@@ -1423,7 +1417,7 @@ package body GNAT.Sockets is
       U4  : aliased C.unsigned;
       V1  : aliased C.unsigned_char;
       VS  : aliased C.char_array (1 .. NS); -- for devices name
-      VT  : aliased Timeval;
+      VT  : aliased System.C_Time.timeval;
       Len : aliased C.int;
       Add : System.Address;
       Res : C.int;
@@ -1596,8 +1590,10 @@ package body GNAT.Sockets is
                   Opt.Timeout := Duration (U4) / 1000;
                end if;
 
+            elsif System.C_Time.In_Timeval_Duration (VT) then
+               Opt.Timeout := System.C_Time.To_Duration (VT);
             else
-               Opt.Timeout := To_Duration (VT);
+               Opt.Timeout := Forever;
             end if;
 
          when Bind_To_Device =>
@@ -2633,7 +2629,7 @@ package body GNAT.Sockets is
               (1 .. (if Option.Name = Bind_To_Device
                      then C.size_t (ASU.Length (Option.Device) + 1)
                      else 0));
-      VT  : aliased Timeval;
+      VT  : aliased System.C_Time.timeval;
       Len : C.int;
       Add : System.Address := Null_Address;
       Res : C.int;
@@ -2767,7 +2763,7 @@ package body GNAT.Sockets is
                end if;
 
             else
-               VT  := To_Timeval (Option.Timeout);
+               VT  := System.C_Time.To_Timeval (Option.Timeout);
                Len := VT'Size / 8;
                Add := VT'Address;
             end if;
@@ -2865,33 +2861,6 @@ package body GNAT.Sockets is
       return Integer (Socket);
    end To_C;
 
-   -----------------
-   -- To_Duration --
-   -----------------
-
-   function To_Duration (Val : Timeval) return Timeval_Duration is
-      Max_D : constant Long_Long_Integer := Long_Long_Integer (Forever - 0.5);
-      Tv_sec_64 : constant Boolean := SOSC.SIZEOF_tv_sec = 8;
-      --  Need to separate this condition into the constant declaration to
-      --  avoid GNAT warning about "always true" or "always false".
-   begin
-      if Tv_sec_64 then
-         --  Check for possible Duration overflow when Tv_Sec field is 64 bit
-         --  integer.
-
-         if Val.Tv_Sec > time_t (Max_D)
-             or else
-           (Val.Tv_Sec = time_t (Max_D)
-              and then
-            Val.Tv_Usec > suseconds_t ((Forever - Duration (Max_D)) * 1E6))
-         then
-            return Forever;
-         end if;
-      end if;
-
-      return Duration (Val.Tv_Sec) + Duration (Val.Tv_Usec) * 1.0E-6;
-   end To_Duration;
-
    -------------------
    -- To_Host_Entry --
    -------------------
@@ -3041,35 +3010,6 @@ package body GNAT.Sockets is
       return HN.Name (1 .. HN.Length);
    end To_String;
 
-   ----------------
-   -- To_Timeval --
-   ----------------
-
-   function To_Timeval (Val : Timeval_Duration) return Timeval is
-      S  : time_t;
-      uS : suseconds_t;
-
-   begin
-      --  If zero, set result as zero (otherwise it gets rounded down to -1)
-
-      if Val = 0.0 then
-         S  := 0;
-         uS := 0;
-
-      --  Normal case where we do round down
-
-      else
-         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;
-
-      return (S, uS);
-   end To_Timeval;
-
    -----------
    -- Value --
    -----------
index 5540dce04aef6ed4578e9c857bea276445f0c49a..c79b8db868bee6f78b9717a51309c20a769c49f1 100644 (file)
@@ -40,6 +40,8 @@ with GNAT.Task_Lock;
 
 with Interfaces.C; use Interfaces.C;
 
+with System.C_Time;
+
 package body GNAT.Sockets.Thin is
 
    Non_Blocking_Sockets : aliased Fd_Set;
@@ -215,7 +217,7 @@ package body GNAT.Sockets.Thin is
       declare -- unreachable if Thread_Blocking_IO is statically True
          pragma Warnings (On, "unreachable code");
          WSet : aliased Fd_Set;
-         Now  : aliased Timeval;
+         Now  : aliased System.C_Time.timeval;
 
       begin
          Reset_Socket_Set (WSet'Access);
index a3f05b384025fc46b9167eaaad36517e256b3ea4..6ae74eb5f6bf9b95ac3da00db73fb55b62e3c839 100644 (file)
@@ -40,6 +40,8 @@ with GNAT.Task_Lock;
 
 with Interfaces.C; use Interfaces.C;
 
+with System.C_Time;
+
 package body GNAT.Sockets.Thin is
 
    Non_Blocking_Sockets : aliased Fd_Set;
@@ -194,7 +196,7 @@ package body GNAT.Sockets.Thin is
       declare -- unreachable if Thread_Blocking_IO is statically True
          pragma Warnings (On, "unreachable code");
          WSet : aliased Fd_Set;
-         Now  : aliased Timeval;
+         Now  : aliased System.C_Time.timeval;
       begin
          Reset_Socket_Set (WSet'Access);
          loop
index cdf0a16ef086ddf1bfd815059f71672eb121d4a1..ec9b5746f0c6ae1cb8bab57ba59f8a07720fa976 100644 (file)
 --  This package should not be directly with'ed by an applications program.
 
 with Ada.Unchecked_Conversion;
+
 with Interfaces.C.Strings;
-with System.Parameters;
+
+with System.C_Time;
 
 package GNAT.Sockets.Thin_Common is
 
@@ -44,31 +46,23 @@ package GNAT.Sockets.Thin_Common is
    Success : constant C.int :=  0;
    Failure : constant C.int := -1;
 
-   type time_t is
-     range -2 ** (System.Parameters.time_t_bits - 1)
-        .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-   for time_t'Size use System.Parameters.time_t_bits;
-   pragma Convention (C, time_t);
-
-   type suseconds_t is
-     range -2 ** (8 * SOSC.SIZEOF_tv_usec - 1)
-         .. 2 ** (8 * SOSC.SIZEOF_tv_usec - 1) - 1;
-   for suseconds_t'Size use 8 * SOSC.SIZEOF_tv_usec;
-   pragma Convention (C, suseconds_t);
-
-   type Timeval is record
-      Tv_Sec  : time_t;
-      Tv_Usec : suseconds_t;
-   end record;
-   pragma Convention (C, Timeval);
+   subtype time_t is System.C_Time.time_t;
+   pragma Obsolescent (time_t, "use type from GNAT.C_Time instead");
+
+   subtype suseconds_t is System.C_Time.usec_t;
+   pragma Obsolescent (suseconds_t, "use type from GNAT.C_Time instead");
+
+   subtype timeval is System.C_Time.timeval;
+   pragma Obsolescent (timeval, "use type from GNAT.C_Time instead");
 
-   type Timeval_Access is access all Timeval;
+   type Timeval_Access is access all System.C_Time.timeval;
    pragma Convention (C, Timeval_Access);
 
    type socklen_t is mod 2 ** (8 * SOSC.SIZEOF_socklen_t);
    for socklen_t'Size use (8 * SOSC.SIZEOF_socklen_t);
 
-   Immediat : constant Timeval := (0, 0);
+   Immediat : constant System.C_Time.timeval
+     := System.C_Time.Milliseconds_To_Timeval (0);
 
    -------------------------------------------
    -- Mapping tables to low level constants --
index a4bbf962a9f31ea047385148f18bc824d7055ac1..3752b2bf442208972ee4dc82fca56857455e0d40 100644 (file)
@@ -29,7 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with GNAT.Sockets.Thin_Common;
+with System.C_Time;
 
 procedure GNAT.Sockets.Poll.G_Wait
   (Fds : in out Set; Timeout : Interfaces.C.int; Result : out Integer)
@@ -41,11 +41,11 @@ is
       readfds   : access FD_Set_Type;
       writefds  : access FD_Set_Type;
       exceptfds : access FD_Set_Type;
-      timeout   : access Thin_Common.Timeval) return Integer
+      timeout   : access System.C_Time.timeval) return Integer
      with Import => True, Convention => Stdcall, External_Name => "select";
 
-   Timeout_V : aliased Thin_Common.Timeval;
-   Timeout_A : access Thin_Common.Timeval;
+   Timeout_V : aliased System.C_Time.timeval;
+   Timeout_A : access System.C_Time.timeval;
 
    Rfds      : aliased FD_Set_Type;
    Rcount    : Natural := 0;
@@ -63,8 +63,7 @@ begin
 
    if Timeout >= 0 then
       Timeout_A := Timeout_V'Access;
-      Timeout_V.Tv_Sec  := Thin_Common.time_t  (Timeout / 1000);
-      Timeout_V.Tv_Usec := Thin_Common.suseconds_t (Timeout rem 1000 * 1000);
+      Timeout_V := System.C_Time.Milliseconds_To_Timeval (Timeout);
    end if;
 
    Reset_Socket_Set (Rfds);
diff --git a/gcc/ada/libgnat/s-c_time.adb b/gcc/ada/libgnat/s-c_time.adb
new file mode 100644 (file)
index 0000000..70f8a9c
--- /dev/null
@@ -0,0 +1,203 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                         GNAT RUN-TIME COMPONENTS                         --
+--                                                                          --
+--                         S Y S T E M . C _ T I M E                        --
+--                                                                          --
+--                                  B o d y                                 --
+--                                                                          --
+--             Copyright (C) 2025, 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.     --
+--                                                                          --
+------------------------------------------------------------------------------
+
+package body System.C_Time is
+
+   --  Two Duration representations are described in targparm.ads:
+   --   Size      Small       Last = (2**(Size - 1) - 1) * Small
+   --    32    0.02                   42_949_672.94
+   --    64    0.000_000_001       9_223_372_036.854_775_807
+
+   Recip : constant := (if Duration'Size = 32 then 50 else 1_000_000_000);
+   --  The reciprocal of the Small used to write "* Small" as "/ Recip"
+
+   Milli : constant := 1_000;
+   Micro : constant := 1_000_000;
+   Nano  : constant := 1_000_000_000;
+   --  The standard divisors
+
+   pragma Unsuppress (Overflow_Check);
+   --  Overflow may occur during the various conversions
+
+   -------------------------
+   -- In_Timeval_Duration --
+   -------------------------
+
+   --  Immediate : constant Duration := 0.0;
+
+   --  Forever   : constant Duration :=
+   --    Duration'Min (Duration'Last, 1.0 * OS_Constants.MAX_tv_sec);
+
+   --  subtype Timeval_Duration is Duration range Immediate .. Forever;
+
+   function In_Timeval_Duration (T : timeval) return Boolean is
+      Max_Dur  : constant := 2**(Duration'Size - 1) - 1;
+      Max_Sec  : constant := Max_Dur / Recip;
+      Max_Usec : constant := (Max_Dur mod Recip) * Micro / Recip;
+
+      --  When Duration'Size = 64 and time_t'Size = 32, the compiler
+      --  complains that Max_Sec does not fit in time_t, hence cannot
+      --  be compared with T.tv_sec.
+      Safe_Max_Sec : constant :=
+        (if Max_Sec > time_t'Last then time_t'Last else Max_Sec);
+      Safe_Max_Usec : constant :=
+        (if Max_Sec > time_t'Last then usec_t'Last else Max_Usec);
+
+   begin
+      pragma Warnings (Off, "condition is always");
+      return T.tv_sec >= 0
+        and then (T.tv_sec > 0 or else T.tv_usec >= 0)
+        and then T.tv_sec <= Safe_Max_Sec
+        and then (T.tv_sec < Safe_Max_Sec or else T.tv_usec <= Safe_Max_Usec)
+        and then T.tv_sec <= OS_Constants.MAX_tv_sec
+        and then (T.tv_sec < OS_Constants.MAX_tv_sec or else T.tv_usec = 0);
+      pragma Warnings (On, "condition is always");
+   end In_Timeval_Duration;
+
+   -----------------------------
+   -- Milliseconds_To_Timeval --
+   -----------------------------
+
+   function Milliseconds_To_Timeval (M : Interfaces.C.int) return timeval is
+      use Interfaces.C;
+      Q : constant int := M  /  Milli;
+      R : constant int := M rem Milli;
+
+   begin
+      return (tv_sec => time_t (Q), tv_usec => usec_t (R) * (Micro / Milli));
+   end Milliseconds_To_Timeval;
+
+   -----------------------------
+   -- Nanoseconds_To_Timespec --
+   -----------------------------
+
+   function Nanoseconds_To_Timespec (N : Interfaces.C.int) return timespec is
+      use Interfaces.C;
+      Q : constant int := N  /  Nano;
+      R : constant int := N rem Nano;
+
+   begin
+      return (tv_sec => time_t (Q), tv_nsec => nsec_t (R));
+   end Nanoseconds_To_Timespec;
+
+   -----------------
+   -- To_Duration --
+   -----------------
+
+   --  Duration (tv_usec) is OK even when Duration'Size = 32, see above
+
+   function To_Duration (T : timeval) return Duration is
+   begin
+      return Duration (T.tv_sec) + Duration (T.tv_usec) / Micro;
+   end To_Duration;
+
+   --  Duration (tv_nsec) overflows when Duration'Size = 32, see above.
+   --  Scale down nanoseconds by the value of the Small in nanoseconds.
+
+   function To_Duration (T : timespec) return Duration is
+      S : constant := Nano / Recip;
+
+   begin
+      return Duration (T.tv_sec) + Duration (T.tv_nsec / S) / (Nano / S);
+   end To_Duration;
+
+   -----------------
+   -- To_Timespec --
+   -----------------
+
+   function To_Timespec (T : timeval) return timespec is
+   begin
+      return (tv_sec => T.tv_sec, tv_nsec => nsec_t (T.tv_usec) * Milli);
+   end To_Timespec;
+
+   function To_Timespec (D : Duration) return timespec is
+      tv_sec  : time_t;
+      tv_nsec : nsec_t;
+
+   begin
+      if D = 0.0 then
+         tv_sec  := 0;
+         tv_nsec := 0;
+
+      elsif D < 0.0 then
+         tv_sec := time_t (D + 0.5);
+         if D = Duration (tv_sec) then
+            tv_nsec := 0;
+         else
+            tv_nsec := nsec_t ((D - Duration (tv_sec)) * Nano + 0.5);
+         end if;
+
+      else
+         tv_sec := time_t (D - 0.5);
+         if D = Duration (tv_sec) then
+            tv_nsec := 0;
+         else
+            tv_nsec := nsec_t ((D - Duration (tv_sec)) * Nano - 0.5);
+         end if;
+      end if;
+
+      return (tv_sec, tv_nsec);
+   end To_Timespec;
+
+   -----------------
+   -- To_Timeval --
+   -----------------
+
+   function To_Timeval (D : Duration) return timeval is
+      tv_sec  : time_t;
+      tv_usec : usec_t;
+
+   begin
+      if D = 0.0 then
+         tv_sec  := 0;
+         tv_usec := 0;
+
+      elsif D < 0.0 then
+         tv_sec := time_t (D + 0.5);
+         if D = Duration (tv_sec) then
+            tv_usec := 0;
+         else
+            tv_usec := usec_t ((D - Duration (tv_sec)) * Micro + 0.5);
+         end if;
+
+      else
+         tv_sec := time_t (D - 0.5);
+         if D = Duration (tv_sec) then
+            tv_usec := 0;
+         else
+            tv_usec := usec_t ((D - Duration (tv_sec)) * Micro - 0.5);
+         end if;
+      end if;
+
+      return (tv_sec, tv_usec);
+   end To_Timeval;
+
+end System.C_Time;
diff --git a/gcc/ada/libgnat/s-c_time.ads b/gcc/ada/libgnat/s-c_time.ads
new file mode 100644 (file)
index 0000000..626a02d
--- /dev/null
@@ -0,0 +1,93 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                         GNAT RUN-TIME COMPONENTS                         --
+--                                                                          --
+--                         S Y S T E M . C _ T I M E                        --
+--                                                                          --
+--                                  S p e c                                 --
+--                                                                          --
+--             Copyright (C) 2025, 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 package provides the time_t, timeval and timespec types corresponding
+--  to the C types defined by the OS, as well as various conversion functions.
+
+with Interfaces.C;
+
+with System.OS_Constants;
+
+package System.C_Time
+  with Pure
+is
+   --  These two C structs represent durations with different accuracies and
+   --  maximal values.
+
+   type time_t is range -2 ** (OS_Constants.SIZEOF_tv_sec * 8 - 1) ..
+                         2 ** (OS_Constants.SIZEOF_tv_sec * 8 - 1) - 1
+     with Convention => C, Size => OS_Constants.SIZEOF_tv_sec * 8;
+
+   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 timeval is record
+      tv_sec  : time_t;  --  seconds
+      tv_usec : usec_t;  --  microseconds
+   end record
+     with Convention => C;
+
+   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 timespec is record
+      tv_sec  : time_t;  --  seconds
+      tv_nsec : nsec_t;  --  nanoseconds
+   end record
+     with Convention => C;
+
+   --  All conversion functions truncate the result if it is inexact
+
+   function To_Duration (T : timespec) return Duration with Inline;
+   function To_Duration (T : timeval)  return Duration with Inline;
+
+   function To_Timespec (D : Duration) return timespec with Inline;
+   function To_Timeval  (D : Duration) return timeval  with Inline;
+
+   function In_Timeval_Duration (T : timeval) return Boolean with Inline;
+   --  g-socket.adb if not Windows target
+
+   function Milliseconds_To_Timeval (M : Interfaces.C.int) return timeval
+     with Inline;
+   --  g-sothco.ads
+   --  g-spogwa.adb
+
+   function Nanoseconds_To_Timespec (N : Interfaces.C.int) return timespec
+     with Inline;
+   function To_Timespec (T : timeval) return timespec with Inline;
+   --  s-osinte__darwin.adb
+
+end System.C_Time;
index 6abe6d3a0e69da8e0024c942855d0eceb25090bd..e39c7cbe2d20afdcae393e8b69897fc9c3fe628d 100644 (file)
@@ -36,8 +36,13 @@ procedure Timed_Delay
   (Time : Duration;
    Mode : Integer)
 is
-   Request    : aliased timespec;
-   Remaind    : aliased timespec;
+
+   function nanosleep (rqtp, rmtp : not null access C_Time.timespec)
+                       return Integer;
+   pragma Import (C, nanosleep, "nanosleep");
+
+   Request    : aliased C_Time.timespec;
+   Remaind    : aliased C_Time.timespec;
    Rel_Time   : Duration;
    Abs_Time   : Duration;
    Base_Time  : constant Duration := Clock;
@@ -71,7 +76,7 @@ begin
          end if;
          pragma Warnings (On);
 
-         Request := To_Timespec (Time_Chunk);
+         Request := C_Time.To_Timespec (Time_Chunk);
          Result := nanosleep (Request'Access, Remaind'Access);
 
          Check_Time := Clock;
index b07bdeadd0920644ca54e54e39c6644cfa579f33..d0a0ad34859d16c27e51c7a6380d7752fe0d57b7 100644 (file)
@@ -2985,7 +2985,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;
@@ -3023,9 +3023,9 @@ package body System.OS_Lib is
    -- To_C --
    ----------
 
-   function To_C (Time : OS_Time) return time_t is
+   function To_C (Time : OS_Time) return Long_Long_Integer is
    begin
-      return time_t (Time);
+      return Long_Long_Integer (Time);
    end To_C;
 
    ------------------
index 38cfc88c4eaa9d7acbd6c174d6529cea66b9d46e..734f4fd50a5da0b34548c551f9732f61d1f31874 100644 (file)
@@ -115,6 +115,12 @@ package System.OS_Lib is
    --  these have Intrinsic convention, so for example it is not permissible
    --  to create accesses to any of these functions.
 
+   function To_Ada (Time : Long_Long_Integer) return OS_Time;
+   --  Convert Long_Long_Integer to OS_Time
+
+   function To_C (Time : OS_Time) return Long_Long_Integer;
+   --  Convert OS_Time to Long_Long_Integer
+
    subtype Year_Type   is Integer range 1900 .. 2099;
    subtype Month_Type  is Integer range    1 ..   12;
    subtype Day_Type    is Integer range    1 ..   31;
@@ -161,27 +167,6 @@ package System.OS_Lib is
    --  component parts to be interpreted in the local time zone, and returns
    --  an OS_Time. Returns Invalid_Time if the creation fails.
 
-   ------------------
-   -- 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;
-   --  Convert C time_t type to OS_Time
-
    ----------------
    -- File Stuff --
    ----------------
@@ -1126,8 +1111,8 @@ private
    pragma Import (Intrinsic, ">");
    pragma Import (Intrinsic, "<=");
    pragma Import (Intrinsic, ">=");
-   pragma Inline (To_C);
    pragma Inline (To_Ada);
+   pragma Inline (To_C);
 
    type Process_Id is new Integer;
    Invalid_Pid : constant Process_Id := -1;
index 28bfcb8c6831dd40906268e01760ba835dced452..7b978a3b486dd6b8316fb37cf652caf7d7ca65ee 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  This version is for darwin
+--  This version is for Darwin
+
+with System.C_Time;
 
-with System.Parameters;
 package body System.OS_Primitives is
 
    --  ??? These definitions are duplicated from System.OS_Interface
@@ -46,27 +47,13 @@ package body System.OS_Primitives is
    pragma Convention (C, struct_timezone);
    type struct_timezone_ptr is access all struct_timezone;
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type struct_timeval is record
-      tv_sec       : time_t;
-      tv_usec      : Integer;
-   end record;
-   pragma Convention (C, struct_timeval);
-
    function gettimeofday
-     (tv : not null access struct_timeval;
+     (tv : not null access C_Time.timeval;
       tz : struct_timezone_ptr) return Integer;
    pragma Import (C, gettimeofday, "gettimeofday");
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : Long_Integer;
-   end record;
-   pragma Convention (C, timespec);
-
-   function nanosleep (rqtp, rmtp : not null access timespec) return Integer;
+   function nanosleep (rqtp, rmtp : not null access C_Time.timespec)
+                      return Integer;
    pragma Import (C, nanosleep, "nanosleep");
 
    -----------
@@ -74,7 +61,7 @@ package body System.OS_Primitives is
    -----------
 
    function Clock return Duration is
-      TV     : aliased struct_timeval;
+      TV     : aliased C_Time.timeval;
 
       Result : Integer;
       pragma Unreferenced (Result);
@@ -89,36 +76,9 @@ package body System.OS_Primitives is
       --  value is never checked.
 
       Result := gettimeofday (TV'Access, null);
-      return Duration (TV.tv_sec) + Duration (TV.tv_usec) / 10#1#E6;
+      return C_Time.To_Duration (TV);
    end Clock;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec;
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return
-        timespec'(tv_sec  => S,
-                  tv_nsec => Long_Integer (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
    -----------------
    -- Timed_Delay --
    -----------------
@@ -127,8 +87,8 @@ package body System.OS_Primitives is
      (Time : Duration;
       Mode : Integer)
    is
-      Request    : aliased timespec;
-      Remaind    : aliased timespec;
+      Request    : aliased C_Time.timespec;
+      Remaind    : aliased C_Time.timespec;
       Rel_Time   : Duration;
       Abs_Time   : Duration;
       Base_Time  : constant Duration := Clock;
@@ -148,7 +108,7 @@ package body System.OS_Primitives is
 
       if Rel_Time > 0.0 then
          loop
-            Request := To_Timespec (Rel_Time);
+            Request := C_Time.To_Timespec (Rel_Time);
             Result := nanosleep (Request'Access, Remaind'Access);
             Check_Time := Clock;
 
index 94d06c325bb2033317e5805b2cab5a4d17c4a0f5..45836ac806d3779a0c0248296cd53d4871ac784b 100644 (file)
 ------------------------------------------------------------------------------
 
 --  This version is for POSIX-like operating systems
-with System.Parameters;
 
-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 time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
+with System.C_Time;
 
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : Long_Integer;
-   end record;
-   pragma Convention (C, timespec);
-
-   function nanosleep (rqtp, rmtp : not null access timespec) return Integer;
-   pragma Import (C, nanosleep, "nanosleep");
+package body System.OS_Primitives is
 
    -----------
    -- Clock --
@@ -57,27 +41,12 @@ package body System.OS_Primitives is
 
    function Clock return Duration is
 
-      type timeval is array (1 .. 3) of Long_Integer;
-      --  The timeval array is sized to contain Long_Long_Integer sec and
-      --  Long_Integer usec. If Long_Long_Integer'Size = Long_Integer'Size then
-      --  it will be overly large but that will not effect the implementation
-      --  since it is not accessed directly.
-
-      procedure timeval_to_duration
-        (T    : not null access timeval;
-         sec  : not null access Long_Long_Integer;
-         usec : not null access Long_Integer);
-      pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
-
-      Micro  : constant := 10**6;
-      sec    : aliased Long_Long_Integer;
-      usec   : aliased Long_Integer;
-      TV     : aliased timeval;
+      TV     : aliased C_Time.timeval;
       Result : Integer;
       pragma Unreferenced (Result);
 
       function gettimeofday
-        (Tv : access timeval;
+        (Tv : access C_Time.timeval;
          Tz : System.Address := System.Null_Address) return Integer;
       pragma Import (C, gettimeofday, "gettimeofday");
 
@@ -91,37 +60,9 @@ package body System.OS_Primitives is
       --  value is never checked.
 
       Result := gettimeofday (TV'Access, System.Null_Address);
-      timeval_to_duration (TV'Access, sec'Access, usec'Access);
-      return Duration (sec) + Duration (usec) / Micro;
+      return C_Time.To_Duration (TV);
    end Clock;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec;
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return
-        timespec'(tv_sec  => S,
-                  tv_nsec => Long_Integer (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
    -----------------
    -- Timed_Delay --
    -----------------
index 78b21c6444d916061ac3a3d3d319895823f4e7f8..fceb37cdd011febfe99f66e03e8c08ac553eceb9 100644 (file)
 --  This version is for POSIX.1-2008-like operating systems
 
 with System.CRTL;
+with System.C_Time;
 with System.OS_Constants;
-with System.Parameters;
+
 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.
-
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : Long_Integer;
-   end record;
-   pragma Convention (C, timespec);
-
-   function nanosleep (rqtp, rmtp : not null access timespec) return Integer;
-   pragma Import (C, nanosleep, "nanosleep");
-
    -----------
    -- Clock --
    -----------
 
    function Clock return Duration is
-      TS     : aliased timespec;
+      TS     : aliased C_Time.timespec;
       Result : int;
 
       type clockid_t is new int;
@@ -68,42 +53,15 @@ package body System.OS_Primitives is
 
       function clock_gettime
         (clock_id : clockid_t;
-         tp       : access timespec) return int;
+         tp       : access C_Time.timespec) return int;
       pragma Import (C, clock_gettime, "clock_gettime");
 
    begin
       Result := clock_gettime (CLOCK_REALTIME, TS'Unchecked_Access);
       pragma Assert (Result = 0);
-      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
+      return C_Time.To_Duration (TS);
    end Clock;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec;
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return
-        timespec'(tv_sec  => S,
-                  tv_nsec => Long_Integer (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
    -----------------
    -- Timed_Delay --
    -----------------
index c8fbc8270ca809eb8106df5590d51444a36c20a9..99644b39424a4ad48735fc1eddc7414a5d5ba89f 100644 (file)
@@ -31,7 +31,8 @@
 
 --  This version is for POSIX-like operating systems
 
-with System.Parameters;
+with System.C_Time;
+
 package body System.OS_Primitives is
 
    --  ??? These definitions are duplicated from System.OS_Interface
@@ -39,16 +40,8 @@ package body System.OS_Primitives is
    --  these declarations in System.OS_Interface and move these ones in
    --  the spec.
 
-   type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-      .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : Long_Integer;
-   end record;
-   pragma Convention (C, timespec);
-
-   function nanosleep (rqtp, rmtp : not null access timespec) return Integer;
+   function nanosleep (rqtp, rmtp : not null access C_Time.timespec)
+                      return Integer;
    pragma Import (C, nanosleep, "nanosleep");
 
    -----------
@@ -56,28 +49,12 @@ package body System.OS_Primitives is
    -----------
 
    function Clock return Duration is
-
-      type timeval is record
-         tv_sec  : time_t;
-         tv_usec : Long_Integer;
-      end record;
-      pragma Convention (C, timeval);
-
-      procedure timeval_to_duration
-        (T    : not null access timeval;
-         sec  : not null access Long_Long_Integer;
-         usec : not null access Long_Integer);
-      pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
-
-      Micro  : constant := 10**6;
-      sec    : aliased Long_Long_Integer;
-      usec   : aliased Long_Integer;
-      TV     : aliased timeval;
+      TV     : aliased C_Time.timeval;
       Result : Integer;
       pragma Unreferenced (Result);
 
       function gettimeofday
-        (Tv : access timeval;
+        (Tv : access C_Time.timeval;
          Tz : System.Address := System.Null_Address) return Integer;
       pragma Import (C, gettimeofday, "gettimeofday");
 
@@ -91,37 +68,9 @@ package body System.OS_Primitives is
       --  value is never checked.
 
       Result := gettimeofday (TV'Access, System.Null_Address);
-      timeval_to_duration (TV'Access, sec'Access, usec'Access);
-      return Duration (sec) + Duration (usec) / Micro;
+      return C_Time.To_Duration (TV);
    end Clock;
 
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec;
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return
-        timespec'(tv_sec  => S,
-                  tv_nsec => Long_Integer (Long_Long_Integer (F * 10#1#E9)));
-   end To_Timespec;
-
    -----------------
    -- Timed_Delay --
    -----------------
@@ -130,8 +79,8 @@ package body System.OS_Primitives is
      (Time : Duration;
       Mode : Integer)
    is
-      Request    : aliased timespec;
-      Remaind    : aliased timespec;
+      Request    : aliased C_Time.timespec;
+      Remaind    : aliased C_Time.timespec;
       Rel_Time   : Duration;
       Abs_Time   : Duration;
       Base_Time  : constant Duration := Clock;
@@ -151,7 +100,7 @@ package body System.OS_Primitives is
 
       if Rel_Time > 0.0 then
          loop
-            Request := To_Timespec (Rel_Time);
+            Request := C_Time.To_Timespec (Rel_Time);
             Result := nanosleep (Request'Access, Remaind'Access);
             Check_Time := Clock;
 
diff --git a/gcc/ada/libgnat/s-osprim__solaris.adb b/gcc/ada/libgnat/s-osprim__solaris.adb
deleted file mode 100644 (file)
index a08feb5..0000000
+++ /dev/null
@@ -1,126 +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-2025, 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).
-
-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_timeval is record
-      tv_sec  : Long_Integer;
-      tv_usec : Long_Integer;
-   end record;
-   pragma Convention (C, struct_timeval);
-
-   procedure gettimeofday
-     (tv : not null access struct_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 struct_timeval);
-   pragma Import (C, C_select, "select");
-
-   -----------
-   -- Clock --
-   -----------
-
-   function Clock return Duration is
-      TV : aliased struct_timeval;
-
-   begin
-      gettimeofday (TV'Access);
-      return Duration (TV.tv_sec) + Duration (TV.tv_usec) / 10#1#E6;
-   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 struct_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.tv_sec := Long_Integer (Rel_Time);
-
-            if Duration (timeval.tv_sec) > Rel_Time then
-               timeval.tv_sec := timeval.tv_sec - 1;
-            end if;
-
-            timeval.tv_usec :=
-              Long_Integer ((Rel_Time - Duration (timeval.tv_sec)) * 10#1#E6);
-
-            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;
index 5848df6f63fce83aae415390ed1d272e4603455b..c48fbe1001f0f8709f321f07075416c7528c2794 100644 (file)
@@ -30,7 +30,9 @@
 ------------------------------------------------------------------------------
 
 --  This version uses gettimeofday and select
---  This file is suitable for OpenNT, Dec Unix and SCO UnixWare.
+--  This file is suitable for Dec Unix, SCO UnixWare and Sun Solaris.
+
+with System.C_Time;
 
 package body System.OS_Primitives is
 
@@ -39,14 +41,8 @@ package body System.OS_Primitives is
    --  these declarations in System.OS_Interface and move these ones in
    --  the spec.
 
-   type struct_timeval is record
-      tv_sec  : Integer;
-      tv_usec : Integer;
-   end record;
-   pragma Convention (C, struct_timeval);
-
    procedure gettimeofday
-     (tv : not null access struct_timeval;
+     (tv : not null access C_Time.timeval;
       tz : Address := Null_Address);
    pragma Import (C, gettimeofday, "gettimeofday");
 
@@ -55,7 +51,7 @@ package body System.OS_Primitives is
       readfds,
       writefds,
       exceptfds : Address := Null_Address;
-      timeout   : not null access struct_timeval);
+      timeout   : not null access C_Time.timeval);
    pragma Import (C, C_select, "select");
 
    -----------
@@ -63,11 +59,11 @@ package body System.OS_Primitives is
    -----------
 
    function Clock return Duration is
-      TV : aliased struct_timeval;
+      TV : aliased C_Time.timeval;
 
    begin
       gettimeofday (TV'Access);
-      return Duration (TV.tv_sec) + Duration (TV.tv_usec) / 10#1#E6;
+      return C_Time.To_Duration (TV);
    end Clock;
 
    -----------------
@@ -82,7 +78,7 @@ package body System.OS_Primitives is
       Abs_Time   : Duration;
       Base_Time  : constant Duration := Clock;
       Check_Time : Duration := Base_Time;
-      timeval    : aliased struct_timeval;
+      timeval    : aliased C_Time.timeval;
 
    begin
       if Mode = Relative then
@@ -95,14 +91,7 @@ package body System.OS_Primitives is
 
       if Rel_Time > 0.0 then
          loop
-            timeval.tv_sec := Integer (Rel_Time);
-
-            if Duration (timeval.tv_sec) > Rel_Time then
-               timeval.tv_sec := timeval.tv_sec - 1;
-            end if;
-
-            timeval.tv_usec :=
-              Integer ((Rel_Time - Duration (timeval.tv_sec)) * 10#1#E6);
+            timeval := C_Time.To_Timeval (Rel_Time);
 
             C_select (timeout => timeval'Unchecked_Access);
             Check_Time := Clock;
diff --git a/gcc/ada/libgnat/s-osprim__x32.adb b/gcc/ada/libgnat/s-osprim__x32.adb
deleted file mode 100644 (file)
index e127107..0000000
+++ /dev/null
@@ -1,170 +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-2025, 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.Parameters;
-
-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 time_t is range -2 ** (System.Parameters.time_t_bits - 1)
-     .. 2 ** (System.Parameters.time_t_bits - 1) - 1;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : Long_Long_Integer;
-   end record;
-   pragma Convention (C, timespec);
-
-   function nanosleep (rqtp, rmtp : not null access timespec) return Integer;
-   pragma Import (C, nanosleep, "nanosleep");
-
-   -----------
-   -- Clock --
-   -----------
-
-   function Clock return Duration is
-      type timeval is array (1 .. 2) of Long_Long_Integer;
-
-      procedure timeval_to_duration
-        (T    : not null access timeval;
-         sec  : not null access Long_Integer;
-         usec : not null access Long_Integer);
-      pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
-
-      Micro  : constant := 10**6;
-      sec    : aliased Long_Integer;
-      usec   : aliased Long_Integer;
-      TV     : aliased timeval;
-      Result : Integer;
-      pragma Unreferenced (Result);
-
-      function gettimeofday
-        (Tv : access 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);
-      timeval_to_duration (TV'Access, sec'Access, usec'Access);
-      return Duration (sec) + Duration (usec) / Micro;
-   end Clock;
-
-   -----------------
-   -- To_Timespec --
-   -----------------
-
-   function To_Timespec (D : Duration) return timespec;
-
-   function To_Timespec (D : Duration) return timespec is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return
-        timespec'(tv_sec  => S,
-                  tv_nsec => Long_Long_Integer (F * 10#1#E9));
-   end To_Timespec;
-
-   -----------------
-   -- Timed_Delay --
-   -----------------
-
-   procedure Timed_Delay
-     (Time : Duration;
-      Mode : Integer)
-   is
-      Request    : aliased timespec;
-      Remaind    : aliased 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 := 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;
index 98284a4d13ec48fe66e49196a312169c5908a780..8587453c947e0cee4ef3d4d92494d9b0efcb7934 100644 (file)
@@ -97,13 +97,6 @@ package System.Parameters is
    --  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 time_t type --
-   ------------------------------------
-
-   time_t_bits : constant := Long_Integer'Size;
-   --  Number of bits in type time_t
-
    ----------------------------------------------
    -- Characteristics of types in Interfaces.C --
    ----------------------------------------------
index a8a7b691802d5ab392b843cf9628acfacc5c2273..832f344a5927d08a069b23385834a3c580c01263 100644 (file)
@@ -96,13 +96,6 @@ package System.Parameters is
    --  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 time_t type --
-   ------------------------------------
-
-   time_t_bits : constant := Long_Integer'Size;
-   --  Number of bits in type time_t
-
    ----------------------------------------------
    -- Characteristics of Types in Interfaces.C --
    ----------------------------------------------
diff --git a/gcc/ada/libgnat/s-parame__posix2008.ads b/gcc/ada/libgnat/s-parame__posix2008.ads
deleted file mode 100644 (file)
index 1cf09c6..0000000
+++ /dev/null
@@ -1,189 +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-2025, 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 time_t type --
-   ------------------------------------
-
-   time_t_bits : constant := Long_Long_Integer'Size;
-   --  Number of bits in type time_t. Use for targets that are Posix 2008
-   --  compliant (fixes the year 2038 time_t overflow).
-
-   ----------------------------------------------
-   -- 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;
index dbaadb404b75b12f9f2d021ce4de5e4721fdcca3..de9afdbb0b2b2946bf5b542b0db4443e4339ef61 100644 (file)
@@ -98,21 +98,6 @@ package System.Parameters is
    --  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 time_t type --
-   ------------------------------------
-
-   --  IMPORTANT NOTE:
-   --  Select the appropriate time_t_bits for the VSB in use, then rebuild
-   --  the runtime using instructions in adainclude/libada.gpr.
-
-   --  time_t_bits : constant := Long_Integer'Size;
-   --  Number of bits in type time_t for SR0650 and before and SR0660 with
-   --  non-default configuration.
-
-   time_t_bits : constant := Long_Long_Integer'Size;
-   --  Number of bits in type time_t for SR0660 with default configuration.
-
    ----------------------------------------------
    -- Characteristics of types in Interfaces.C --
    ----------------------------------------------
index 7a5e987cefc41629c3eb5778e190759215d60af4..74cf1e58553f48d4c34b6d3564798a02067d85ef 100644 (file)
@@ -1764,6 +1764,17 @@ CND(SIZEOF_tv_usec, "tv_usec")
 #endif
 CNS(MAX_tv_sec, "")
 }
+
+{
+  struct timespec ts;
+/*
+   --  Sizes (in bytes) of the components of struct timespec.
+   --  The tv_sec field is the same as in struct timeval.
+*/
+#define SIZEOF_tv_nsec (sizeof (ts.tv_nsec))
+CND(SIZEOF_tv_nsec, "tv_nsec");
+}
+
 /*
 
    --  Sizes of various data types