* config/arm/elf.h (ASM_OUTPUT_ALIGNED_COMMON): Remove definition.
[official-gcc.git] / gcc / ada / osint-b.adb
blobfc4941e95678fbf8052d4a04afde018ad3b1189a
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- O S I N T - B --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2001 Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 with Hostparm;
28 with Namet; use Namet;
29 with Opt; use Opt;
31 package body Osint.B is
33 Binder_Output_Time_Stamps_Set : Boolean := False;
35 Old_Binder_Output_Time_Stamp : Time_Stamp_Type;
36 New_Binder_Output_Time_Stamp : Time_Stamp_Type;
37 Recording_Time_From_Last_Bind : Boolean := False;
39 -------------------------
40 -- Close_Binder_Output --
41 -------------------------
43 procedure Close_Binder_Output is
44 begin
45 Close (Output_FD);
47 if Recording_Time_From_Last_Bind then
48 New_Binder_Output_Time_Stamp := File_Stamp (Output_File_Name);
49 Binder_Output_Time_Stamps_Set := True;
50 end if;
51 end Close_Binder_Output;
53 --------------------------
54 -- Create_Binder_Output --
55 --------------------------
57 procedure Create_Binder_Output
58 (Output_File_Name : String;
59 Typ : Character;
60 Bfile : out Name_Id)
62 File_Name : String_Ptr;
63 Findex1 : Natural;
64 Findex2 : Natural;
65 Flength : Natural;
67 begin
68 if Output_File_Name /= "" then
69 Name_Buffer (Output_File_Name'Range) := Output_File_Name;
70 Name_Buffer (Output_File_Name'Last + 1) := ASCII.NUL;
72 if Typ = 's' then
73 Name_Buffer (Output_File_Name'Last) := 's';
74 end if;
76 Name_Len := Output_File_Name'Last;
78 else
79 Name_Buffer (1) := 'b';
80 File_Name := File_Names (Current_File_Name_Index);
82 Findex1 := File_Name'First;
84 -- The ali file might be specified by a full path name. However,
85 -- the binder generated file should always be created in the
86 -- current directory, so the path might need to be stripped away.
87 -- In addition to the default directory_separator allow the '/' to
88 -- act as separator since this is allowed in MS-DOS and OS2 ports.
90 for J in reverse File_Name'Range loop
91 if File_Name (J) = Directory_Separator
92 or else File_Name (J) = '/'
93 then
94 Findex1 := J + 1;
95 exit;
96 end if;
97 end loop;
99 Findex2 := File_Name'Last;
100 while File_Name (Findex2) /= '.' loop
101 Findex2 := Findex2 - 1;
102 end loop;
104 Flength := Findex2 - Findex1;
106 if Maximum_File_Name_Length > 0 then
108 -- Make room for the extra two characters in "b?"
110 while Int (Flength) > Maximum_File_Name_Length - 2 loop
111 Findex2 := Findex2 - 1;
112 Flength := Findex2 - Findex1;
113 end loop;
114 end if;
116 Name_Buffer (3 .. Flength + 2) := File_Name (Findex1 .. Findex2 - 1);
117 Name_Buffer (Flength + 3) := '.';
119 -- C bind file, name is b_xxx.c
121 if Typ = 'c' then
122 Name_Buffer (2) := '_';
123 Name_Buffer (Flength + 4) := 'c';
124 Name_Buffer (Flength + 5) := ASCII.NUL;
125 Name_Len := Flength + 4;
127 -- Ada bind file, name is b~xxx.adb or b~xxx.ads
128 -- (with $ instead of ~ in VMS)
130 else
131 if Hostparm.OpenVMS then
132 Name_Buffer (2) := '$';
133 else
134 Name_Buffer (2) := '~';
135 end if;
137 Name_Buffer (Flength + 4) := 'a';
138 Name_Buffer (Flength + 5) := 'd';
139 Name_Buffer (Flength + 6) := Typ;
140 Name_Buffer (Flength + 7) := ASCII.NUL;
141 Name_Len := Flength + 6;
142 end if;
143 end if;
145 Bfile := Name_Find;
147 if Recording_Time_From_Last_Bind then
148 Old_Binder_Output_Time_Stamp := File_Stamp (Bfile);
149 end if;
151 Create_File_And_Check (Output_FD, Text);
152 end Create_Binder_Output;
154 --------------------
155 -- More_Lib_Files --
156 --------------------
158 function More_Lib_Files return Boolean renames More_Files;
160 ------------------------
161 -- Next_Main_Lib_File --
162 ------------------------
164 function Next_Main_Lib_File return File_Name_Type renames Next_Main_File;
166 --------------------------------
167 -- Record_Time_From_Last_Bind --
168 --------------------------------
170 procedure Record_Time_From_Last_Bind is
171 begin
172 Recording_Time_From_Last_Bind := True;
173 end Record_Time_From_Last_Bind;
175 -------------------------
176 -- Time_From_Last_Bind --
177 -------------------------
179 function Time_From_Last_Bind return Nat is
180 Old_Y : Nat;
181 Old_M : Nat;
182 Old_D : Nat;
183 Old_H : Nat;
184 Old_Mi : Nat;
185 Old_S : Nat;
186 New_Y : Nat;
187 New_M : Nat;
188 New_D : Nat;
189 New_H : Nat;
190 New_Mi : Nat;
191 New_S : Nat;
193 type Month_Data is array (Int range 1 .. 12) of Int;
194 Cumul : constant Month_Data := (0, 0, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7);
195 -- Represents the difference in days from a period compared to the
196 -- same period if all months had 31 days, i.e:
198 -- Cumul (m) = 31x(m-1) - (number of days from 01/01 to m/01)
200 Res : Int;
202 begin
203 if not Recording_Time_From_Last_Bind
204 or else not Binder_Output_Time_Stamps_Set
205 or else Old_Binder_Output_Time_Stamp = Empty_Time_Stamp
206 then
207 return Nat'Last;
208 end if;
210 Split_Time_Stamp
211 (Old_Binder_Output_Time_Stamp,
212 Old_Y, Old_M, Old_D, Old_H, Old_Mi, Old_S);
214 Split_Time_Stamp
215 (New_Binder_Output_Time_Stamp,
216 New_Y, New_M, New_D, New_H, New_Mi, New_S);
218 Res := New_Mi - Old_Mi;
220 -- 60 minutes in an hour
222 Res := Res + 60 * (New_H - Old_H);
224 -- 24 hours in a day
226 Res := Res + 60 * 24 * (New_D - Old_D);
228 -- Almost 31 days in a month
230 Res := Res + 60 * 24 *
231 (31 * (New_M - Old_M) - Cumul (New_M) + Cumul (Old_M));
233 -- 365 days in a year
235 Res := Res + 60 * 24 * 365 * (New_Y - Old_Y);
237 return Res;
238 end Time_From_Last_Bind;
240 -----------------------
241 -- Write_Binder_Info --
242 -----------------------
244 procedure Write_Binder_Info (Info : String) renames Write_Info;
246 begin
247 Set_Program (Binder);
248 end Osint.B;