sh.c (shift_insns_rtx, [...]): Truncate shift counts to avoid out-of-bounds array...
[official-gcc.git] / gcc / ada / s-osinte-posix.adb
blobc6460c2d241efce1480fe3f6a468d962f523cf49
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . O S _ I N T E R F A C E --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1991-1994, Florida State University --
10 -- Copyright (C) 1995-2006, AdaCore --
11 -- --
12 -- GNARL is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNARL; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
21 -- Boston, MA 02110-1301, USA. --
22 -- --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
29 -- --
30 -- GNARL was developed by the GNARL team at Florida State University. --
31 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
32 -- --
33 ------------------------------------------------------------------------------
35 -- This is a GNU/LinuxThreads, Solaris pthread and HP-UX pthread version
36 -- of this package.
38 pragma Polling (Off);
39 -- Turn off polling, we do not want ATC polling to take place during
40 -- tasking operations. It causes infinite loops and other problems.
42 -- This package encapsulates all direct interfaces to OS services
43 -- that are needed by children of System.
45 with Interfaces.C; use Interfaces.C;
46 package body System.OS_Interface is
48 --------------------
49 -- Get_Stack_Base --
50 --------------------
52 function Get_Stack_Base (thread : pthread_t) return Address is
53 pragma Warnings (Off, thread);
55 begin
56 return Null_Address;
57 end Get_Stack_Base;
59 ------------------
60 -- pthread_init --
61 ------------------
63 procedure pthread_init is
64 begin
65 null;
66 end pthread_init;
68 -----------------
69 -- To_Duration --
70 -----------------
72 function To_Duration (TS : timespec) return Duration is
73 begin
74 return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
75 end To_Duration;
77 function To_Duration (TV : struct_timeval) return Duration is
78 begin
79 return Duration (TV.tv_sec) + Duration (TV.tv_usec) / 10#1#E6;
80 end To_Duration;
82 ------------------------
83 -- To_Target_Priority --
84 ------------------------
86 function To_Target_Priority
87 (Prio : System.Any_Priority) return Interfaces.C.int
89 begin
90 return Interfaces.C.int (Prio);
91 end To_Target_Priority;
93 -----------------
94 -- To_Timespec --
95 -----------------
97 function To_Timespec (D : Duration) return timespec is
98 S : time_t;
99 F : Duration;
101 begin
102 S := time_t (Long_Long_Integer (D));
103 F := D - Duration (S);
105 -- If F has negative value due to a round-up, adjust for positive F
106 -- value.
108 if F < 0.0 then
109 S := S - 1;
110 F := F + 1.0;
111 end if;
113 return timespec'(tv_sec => S,
114 tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
115 end To_Timespec;
117 ----------------
118 -- To_Timeval --
119 ----------------
121 function To_Timeval (D : Duration) return struct_timeval is
122 S : time_t;
123 F : Duration;
125 begin
126 S := time_t (Long_Long_Integer (D));
127 F := D - Duration (S);
129 -- If F has negative value due to a round-up, adjust for positive F
130 -- value.
132 if F < 0.0 then
133 S := S - 1;
134 F := F + 1.0;
135 end if;
137 return
138 struct_timeval'
139 (tv_sec => S,
140 tv_usec => time_t (Long_Long_Integer (F * 10#1#E6)));
141 end To_Timeval;
143 end System.OS_Interface;