+2009-11-23 Eric Botcazou <ebotcazou@adacore.com>
+ Laurent GUERBY <laurent@guerby.net>
+
+ PR ada/42153
+ * s-osinte-linux.ads (struct_timeval): Delete.
+ * s-osinte-hpux.ads (struct_timeval, To_Duration, To_Timeval):
+ Delete.
+ * s-osinte-kfreebsd-gnu.ads: Likewise.
+ * s-osinte-rtems.ads: Likewise.
+ * s-osinte-aix.ads: Likewise.
+ * s-osinte-hpux-dce.ads: Likewise.
+ * s-osinte-darwin.ads: Likewise.
+ * s-osinte-solaris-posix.ads: Likewise.
+ * s-osinte-irix.ads: Likewise.
+ * s-osinte-solaris.ads: Likewise.
+ * s-osinte-hpux-dce.adb (To_Duration, To_Timeval): Delete.
+ * s-osinte-irix.adb: Likewise.
+ * s-osinte-solaris.adb: Likewise.
+ * s-osinte-rtems.adb: Likewise. Minor reformatting.
+ * s-osinte-aix.adb (To_Duration, To_Timeval): Delete.
+ (clock_gettime): Use cal.c timeval_to_duration.
+ * s-osinte-darwin.adb: Likewise.
+
2009-11-23 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* adaint.h: Assume large file support on IRIX only if _LFAPI.
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 --
------------------------
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 : long;
- F : Duration;
-
- begin
- S := long (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
- struct_timeval'
- (tv_sec => S,
- tv_usec => long (Long_Long_Integer (F * 10#1#E6)));
- end To_Timeval;
-
-------------------
-- clock_gettime --
-------------------
tp : access timespec)
return int
is
- pragma Warnings (Off, clock_id);
+ pragma Unreferenced (clock_id);
+
+ -- Darwin threads don't have clock_gettime, so use
+ -- gettimeofday() instead.
+
+ 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;
- tv : aliased struct_timeval;
function gettimeofday
- (tv : access struct_timeval;
- tz : System.Address := System.Null_Address)
- return int;
+ (Tv : access timeval;
+ Tz : System.Address := System.Null_Address) return int;
pragma Import (C, gettimeofday, "gettimeofday");
begin
- Result := gettimeofday (tv'Unchecked_Access);
- tp.all := To_Timespec (To_Duration (tv));
+ 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);
return Result;
end clock_gettime;
function clock_gettime
(clock_id : clockid_t;
tp : access timespec) return int;
- -- AIX threads don't have clock_gettime, so use gettimeofday() instead
function To_Duration (TS : timespec) return Duration;
pragma Inline (To_Duration);
pragma Convention (C, struct_timezone);
type struct_timezone_ptr is access all struct_timezone;
- type struct_timeval is private;
- -- This is needed on systems that do not have clock_gettime() but do have
- -- gettimeofday().
-
- function To_Duration (TV : struct_timeval) return Duration;
- pragma Inline (To_Duration);
-
- function To_Timeval (D : Duration) return struct_timeval;
- pragma Inline (To_Timeval);
-
-------------------------
-- Priority Scheduling --
-------------------------
type clockid_t is new int;
CLOCK_REALTIME : constant clockid_t := 0;
- type struct_timeval is record
- tv_sec : long;
- tv_usec : long;
- end record;
- pragma Convention (C, struct_timeval);
-
type pthread_attr_t is new System.Address;
pragma Convention (C, pthread_attr_t);
-- typedef struct __pt_attr *pthread_attr_t;
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 --
------------------------
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 (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 => int32_t (Long_Long_Integer (F * 10#1#E6)));
- end To_Timeval;
-
-------------------
-- clock_gettime --
-------------------
tp : access timespec) return int
is
pragma Unreferenced (clock_id);
+
+ -- AIX threads don't have clock_gettime, so use
+ -- gettimeofday() instead.
+
+ 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;
- tv : aliased struct_timeval;
function gettimeofday
- (tv : access struct_timeval;
- tz : System.Address := System.Null_Address) return int;
+ (Tv : access timeval;
+ Tz : System.Address := System.Null_Address) return int;
pragma Import (C, gettimeofday, "gettimeofday");
begin
- Result := gettimeofday (tv'Unchecked_Access);
- tp.all := To_Timespec (To_Duration (tv));
+ 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);
return Result;
end clock_gettime;
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);
-
-------------------------
-- Priority Scheduling --
-------------------------
type clockid_t is new int;
CLOCK_REALTIME : constant clockid_t := 0;
- type struct_timeval is record
- tv_sec : time_t;
- tv_usec : int32_t;
- end record;
- pragma Convention (C, struct_timeval);
-
--
-- Darwin specific signal implementation
--
tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
end To_Timespec;
- 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;
-
- 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;
-
-------------------------
-- POSIX.1c Section 3 --
-------------------------
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);
-
-------------------------
-- Priority Scheduling --
-------------------------
type clockid_t is new int;
CLOCK_REALTIME : constant clockid_t := 1;
- type struct_timeval is record
- tv_sec : time_t;
- tv_usec : time_t;
- end record;
- pragma Convention (C, struct_timeval);
-
type cma_t_address is new System.Address;
type cma_t_handle is record
pragma Convention (C, struct_timezone);
type struct_timezone_ptr is access all struct_timezone;
- type struct_timeval is private;
- -- This is needed on systems that do not have clock_gettime()
- -- but do have gettimeofday().
-
- function To_Duration (TV : struct_timeval) return Duration;
- pragma Inline (To_Duration);
-
- function To_Timeval (D : Duration) return struct_timeval;
- pragma Inline (To_Timeval);
-
-------------------------
-- Priority Scheduling --
-------------------------
type clockid_t is new int;
CLOCK_REALTIME : constant clockid_t := 1;
- type struct_timeval is record
- tv_sec : time_t;
- tv_usec : time_t;
- end record;
- pragma Convention (C, struct_timeval);
-
type pthread_attr_t is new int;
type pthread_condattr_t is new int;
type pthread_mutexattr_t is new int;
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_Timespec --
-----------------
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;
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);
-
-------------------------
-- Priority Scheduling --
-------------------------
CLOCK_SGI_CYCLE : constant clockid_t := 2;
CLOCK_SGI_FAST : constant clockid_t := 3;
- type struct_timeval is record
- tv_sec : time_t;
- tv_usec : time_t;
- end record;
- pragma Convention (C, struct_timeval);
-
type array_type_9 is array (Integer range 0 .. 4) of long;
type pthread_attr_t is record
X_X_D : array_type_9;
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);
end record;
pragma Convention (C, timespec);
- type struct_timeval is record
- tv_sec : time_t;
- tv_usec : time_t;
- end record;
- pragma Convention (C, struct_timeval);
-
type pthread_attr_t is record
detachstate : int;
schedpolicy : int;
end record;
pragma Convention (C, timespec);
- type struct_timeval is record
- tv_sec : time_t;
- tv_usec : time_t;
- end record;
- pragma Convention (C, struct_timeval);
-
type pthread_attr_t is record
detachstate : int;
schedpolicy : int;
tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
end To_Timespec;
- 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;
-
- function To_Timeval (D : Duration) return struct_timeval is
- S : int;
- F : Duration;
- begin
- S := int (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 => int (Long_Long_Integer (F * 10#1#E6)));
- end To_Timeval;
+ ------------------
+ -- pthread_init --
+ ------------------
procedure pthread_init is
begin
null;
end pthread_init;
+ --------------------
+ -- Get_Stack_Base --
+ --------------------
+
function Get_Stack_Base (thread : pthread_t) return Address is
pragma Warnings (Off, thread);
return Null_Address;
end Get_Stack_Base;
+ -----------------
+ -- sigaltstack --
+ -----------------
+
function sigaltstack
(ss : not null access stack_t;
oss : access stack_t) return int 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);
-
-------------------------
-- Priority Scheduling --
-------------------------
type clockid_t is new rtems_id;
CLOCK_REALTIME : constant clockid_t := 1;
- type struct_timeval is record
- tv_sec : int;
- tv_usec : int;
- end record;
- pragma Convention (C, struct_timeval);
-
type pthread_attr_t is record
is_initialized : int;
stackaddr : System.Address;
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);
-
-------------------------
-- Priority Scheduling --
-------------------------
type clockid_t is new int;
CLOCK_REALTIME : constant clockid_t := 0;
- type struct_timeval is record
- tv_sec : time_t;
- tv_usec : time_t;
- end record;
- pragma Convention (C, struct_timeval);
-
type pthread_attr_t is record
pthread_attrp : System.Address;
end record;
tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
end To_Timespec;
- -----------------
- -- 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_Timeval --
- ----------------
-
- function To_Timeval (D : Duration) return struct_timeval is
- S : long;
- F : Duration;
-
- begin
- S := long (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
- struct_timeval'
- (tv_sec => S,
- tv_usec => long (Long_Long_Integer (F * 10#1#E6)));
- end To_Timeval;
-
------------------
-- pthread_init --
------------------
function To_Timespec (D : Duration) return timespec;
pragma Inline (To_Timespec);
- type struct_timeval is private;
- -- This is needed on systems that do not have clock_gettime()
- -- but do have gettimeofday().
-
- function To_Duration (TV : struct_timeval) return Duration;
- pragma Inline (To_Duration);
-
- function To_Timeval (D : Duration) return struct_timeval;
- pragma Inline (To_Timeval);
-
-------------
-- Process --
-------------
type clockid_t is new int;
CLOCK_REALTIME : constant clockid_t := 0;
- type struct_timeval is record
- tv_sec : long;
- tv_usec : long;
- end record;
- pragma Convention (C, struct_timeval);
-
type array_type_9 is array (0 .. 3) of unsigned_char;
type record_type_3 is record
flag : array_type_9;