aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2009-11-21 12:01:11 +0000
committerLaurent Guerby <guerby@gcc.gnu.org>2009-11-21 12:01:11 +0000
commit435697aae738e1a3b3bb62711d5e15fad9f37b40 (patch)
treeac8a28fe73dc0485fa6d6a2a4fc2a0a67afa2c9a
parente81f2ecf58f3d5d17a0dbf64f608cef15be5b9ca (diff)
downloadgcc-435697aae738e1a3b3bb62711d5e15fad9f37b40.zip
gcc-435697aae738e1a3b3bb62711d5e15fad9f37b40.tar.gz
gcc-435697aae738e1a3b3bb62711d5e15fad9f37b40.tar.bz2
s-osinte-linux.ads (struct_timeval, [...]): Delete.
2009-11-21 Eric Botcazou <ebotcazou@adacore.com> Laurent GUERBY <laurent@guerby.net> * s-osinte-linux.ads (struct_timeval, To_Duration, To_Timeval, gettimeofday): Delete. * s-osinte-posix.adb (To_Duration, To_Timeval): Delete. * s-osprim-posix.adb (struct_timezone, struct_timeval, gettimeofday): Delete. (Clock): Use cal.c timeval_to_duration. * s-taprop-linux.adb (Monotonic_Clock): Likewise. Co-Authored-By: Laurent GUERBY <laurent@guerby.net> From-SVN: r154407
-rw-r--r--gcc/ada/ChangeLog11
-rw-r--r--gcc/ada/s-osinte-linux.ads13
-rw-r--r--gcc/ada/s-osinte-posix.adb31
-rw-r--r--gcc/ada/s-osprim-posix.adb42
-rw-r--r--gcc/ada/s-taprop-linux.adb26
5 files changed, 54 insertions, 69 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 02f4d8c..86f2bcc 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,14 @@
+2009-11-21 Eric Botcazou <ebotcazou@adacore.com>
+ Laurent GUERBY <laurent@guerby.net>
+
+ * s-osinte-linux.ads (struct_timeval, To_Duration, To_Timeval,
+ gettimeofday): Delete.
+ * s-osinte-posix.adb (To_Duration, To_Timeval): Delete.
+ * s-osprim-posix.adb (struct_timezone, struct_timeval,
+ gettimeofday): Delete.
+ (Clock): Use cal.c timeval_to_duration.
+ * s-taprop-linux.adb (Monotonic_Clock): Likewise.
+
2009-11-12 Eric Botcazou <ebotcazou@adacore.com>
Laurent GUERBY <laurent@guerby.net>
diff --git a/gcc/ada/s-osinte-linux.ads b/gcc/ada/s-osinte-linux.ads
index 5d2fdcc..2a620c5 100644
--- a/gcc/ada/s-osinte-linux.ads
+++ b/gcc/ada/s-osinte-linux.ads
@@ -228,19 +228,6 @@ package System.OS_Interface is
function To_Timespec (D : Duration) return timespec;
pragma Inline (To_Timespec);
- type struct_timeval is private;
-
- function To_Duration (TV : struct_timeval) return Duration;
- pragma Inline (To_Duration);
-
- function To_Timeval (D : Duration) return struct_timeval;
- pragma Inline (To_Timeval);
-
- function gettimeofday
- (tv : access struct_timeval;
- tz : System.Address := System.Null_Address) return int;
- pragma Import (C, gettimeofday, "gettimeofday");
-
function sysconf (name : int) return long;
pragma Import (C, sysconf);
diff --git a/gcc/ada/s-osinte-posix.adb b/gcc/ada/s-osinte-posix.adb
index c6460c2..310454a 100644
--- a/gcc/ada/s-osinte-posix.adb
+++ b/gcc/ada/s-osinte-posix.adb
@@ -74,11 +74,6 @@ package body System.OS_Interface is
return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
end To_Duration;
- function To_Duration (TV : struct_timeval) return Duration is
- begin
- return Duration (TV.tv_sec) + Duration (TV.tv_usec) / 10#1#E6;
- end To_Duration;
-
------------------------
-- To_Target_Priority --
------------------------
@@ -114,30 +109,4 @@ package body System.OS_Interface is
tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
end To_Timespec;
- ----------------
- -- To_Timeval --
- ----------------
-
- function To_Timeval (D : Duration) return struct_timeval 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
- struct_timeval'
- (tv_sec => S,
- tv_usec => time_t (Long_Long_Integer (F * 10#1#E6)));
- end To_Timeval;
-
end System.OS_Interface;
diff --git a/gcc/ada/s-osprim-posix.adb b/gcc/ada/s-osprim-posix.adb
index c02ad98..e03a132 100644
--- a/gcc/ada/s-osprim-posix.adb
+++ b/gcc/ada/s-osprim-posix.adb
@@ -38,26 +38,8 @@ package body System.OS_Primitives is
-- these declarations in System.OS_Interface and move these ones in
-- the spec.
- type struct_timezone is record
- tz_minuteswest : Integer;
- tz_dsttime : Integer;
- end record;
- pragma Convention (C, struct_timezone);
- type struct_timezone_ptr is access all struct_timezone;
-
type time_t is new Long_Integer;
- type struct_timeval is record
- tv_sec : time_t;
- tv_usec : Long_Integer;
- end record;
- pragma Convention (C, struct_timeval);
-
- function gettimeofday
- (tv : not null access struct_timeval;
- tz : struct_timezone_ptr) return Integer;
- pragma Import (C, gettimeofday, "gettimeofday");
-
type timespec is record
tv_sec : time_t;
tv_nsec : Long_Integer;
@@ -72,11 +54,26 @@ package body System.OS_Primitives is
-----------
function Clock return Duration is
- TV : aliased struct_timeval;
-
+ type timeval is array (1 .. 2) of 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
@@ -86,8 +83,9 @@ package body System.OS_Primitives is
-- None of these codes signal a potential clock skew, hence the return
-- value is never checked.
- Result := gettimeofday (TV'Access, null);
- return Duration (TV.tv_sec) + Duration (TV.tv_usec) / 10#1#E6;
+ Result := gettimeofday (TV'Access, System.Null_Address);
+ timeval_to_duration (TV'Access, sec'Access, usec'Access);
+ return Duration (sec) + Duration (usec) / Micro;
end Clock;
---------------------
diff --git a/gcc/ada/s-taprop-linux.adb b/gcc/ada/s-taprop-linux.adb
index 46b10a3..0f0773c 100644
--- a/gcc/ada/s-taprop-linux.adb
+++ b/gcc/ada/s-taprop-linux.adb
@@ -589,12 +589,32 @@ package body System.Task_Primitives.Operations is
---------------------
function Monotonic_Clock return Duration is
- TV : aliased struct_timeval;
- Result : Interfaces.C.int;
+ use Interfaces;
+
+ type timeval is array (1 .. 2) of C.long;
+
+ procedure timeval_to_duration
+ (T : not null access timeval;
+ sec : not null access C.long;
+ usec : not null access C.long);
+ pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
+
+ Micro : constant := 10**6;
+ sec : aliased C.long;
+ usec : aliased C.long;
+ TV : aliased timeval;
+ Result : int;
+
+ function gettimeofday
+ (Tv : access 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);
- return To_Duration (TV);
+ timeval_to_duration (TV'Access, sec'Access, usec'Access);
+ return Duration (sec) + Duration (usec) / Micro;
end Monotonic_Clock;
-------------------