1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
11 -- Copyright (C) 1999-2001 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- Extensive contributions were provided by Ada Core Technologies Inc. --
27 ------------------------------------------------------------------------------
29 with Namet
; use Namet
;
30 with Output
; use Output
;
31 with Sinput
; use Sinput
;
32 with Sinput
.L
; use Sinput
.L
;
33 with Fname
.UF
; use Fname
.UF
;
34 with Types
; use Types
;
36 package body Targparm
is
39 (AAM
, CLA
, DEN
, DSP
, FEL
, HIM
, LSI
, MOV
,
40 MRN
, SCD
, SCP
, SNZ
, UAM
, VMS
, ZCD
, ZCG
, ZCF
);
42 Targparm_Flags
: array (Targparm_Tags
) of Boolean := (others => False);
43 -- Flag is set True if corresponding parameter is scanned
45 AAM_Str
: aliased constant Source_Buffer
:= "AAMP";
46 CLA_Str
: aliased constant Source_Buffer
:= "Command_Line_Args";
47 DEN_Str
: aliased constant Source_Buffer
:= "Denorm";
48 DSP_Str
: aliased constant Source_Buffer
:= "Functions_Return_By_DSP";
49 FEL_Str
: aliased constant Source_Buffer
:= "Frontend_Layout";
50 HIM_Str
: aliased constant Source_Buffer
:= "High_Integrity_Mode";
51 LSI_Str
: aliased constant Source_Buffer
:= "Long_Shifts_Inlined";
52 MOV_Str
: aliased constant Source_Buffer
:= "Machine_Overflows";
53 MRN_Str
: aliased constant Source_Buffer
:= "Machine_Rounds";
54 SCD_Str
: aliased constant Source_Buffer
:= "Stack_Check_Default";
55 SCP_Str
: aliased constant Source_Buffer
:= "Stack_Check_Probes";
56 SNZ_Str
: aliased constant Source_Buffer
:= "Signed_Zeros";
57 UAM_Str
: aliased constant Source_Buffer
:= "Use_Ada_Main_Program_Name";
58 VMS_Str
: aliased constant Source_Buffer
:= "OpenVMS";
59 ZCD_Str
: aliased constant Source_Buffer
:= "ZCX_By_Default";
60 ZCG_Str
: aliased constant Source_Buffer
:= "GCC_ZCX_Support";
61 ZCF_Str
: aliased constant Source_Buffer
:= "Front_End_ZCX_Support";
63 type Buffer_Ptr
is access constant Source_Buffer
;
64 Targparm_Str
: array (Targparm_Tags
) of Buffer_Ptr
:=
83 ---------------------------
84 -- Get_Target_Parameters --
85 ---------------------------
87 procedure Get_Target_Parameters
is
90 S
: Source_File_Index
;
92 T
: Source_Buffer_Ptr
;
96 Fatal
: Boolean := False;
97 -- Set True if a fatal error is detected
100 -- Records boolean from system line
103 Name_Buffer
(1 .. 6) := "system";
105 N
:= File_Name_Of_Spec
(Name_Find
);
106 S
:= Load_Source_File
(N
);
108 if S
= No_Source_File
then
109 Write_Line
("fatal error, run-time library not installed correctly");
110 Write_Str
("cannot locate file ");
111 Write_Line
(Name_Buffer
(1 .. Name_Len
));
112 raise Unrecoverable_Error
;
114 -- This must always be the first source file read, and we have defined
115 -- a constant Types.System_Source_File_Index as 1 to reflect this.
118 pragma Assert
(S
= System_Source_File_Index
);
122 P
:= Source_First
(S
);
123 Z
:= Source_Last
(S
);
124 T
:= Source_Text
(S
);
126 while T
(P
.. P
+ 10) /= "end System;" loop
128 for K
in Targparm_Tags
loop
129 if T
(P
+ 3 .. P
+ 2 + Targparm_Str
(K
)'Length) =
132 P
:= P
+ 3 + Targparm_Str
(K
)'Length;
134 if Targparm_Flags
(K
) then
137 ("fatal error: system.ads is incorrectly formatted");
138 Write_Str
("duplicate line for parameter: ");
140 for J
in Targparm_Str
(K
)'Range loop
141 Write_Char
(Targparm_Str
(K
).all (J
));
149 Targparm_Flags
(K
) := True;
152 while T
(P
) /= ':' or else T
(P
+ 1) /= '=' loop
158 while T
(P
) = ' ' loop
162 Result
:= (T
(P
) = 'T');
165 when AAM
=> AAMP_On_Target
:= Result
;
166 when CLA
=> Command_Line_Args_On_Target
:= Result
;
167 when DEN
=> Denorm_On_Target
:= Result
;
168 when DSP
=> Functions_Return_By_DSP_On_Target
:= Result
;
169 when FEL
=> Frontend_Layout_On_Target
:= Result
;
170 when HIM
=> High_Integrity_Mode_On_Target
:= Result
;
171 when LSI
=> Long_Shifts_Inlined_On_Target
:= Result
;
172 when MOV
=> Machine_Overflows_On_Target
:= Result
;
173 when MRN
=> Machine_Rounds_On_Target
:= Result
;
174 when SCD
=> Stack_Check_Default_On_Target
:= Result
;
175 when SCP
=> Stack_Check_Probes_On_Target
:= Result
;
176 when SNZ
=> Signed_Zeros_On_Target
:= Result
;
177 when UAM
=> Use_Ada_Main_Program_Name_On_Target
:= Result
;
178 when VMS
=> OpenVMS_On_Target
:= Result
;
179 when ZCD
=> ZCX_By_Default_On_Target
:= Result
;
180 when ZCG
=> GCC_ZCX_Support_On_Target
:= Result
;
181 when ZCF
=> Front_End_ZCX_Support_On_Target
:= Result
;
188 while T
(P
) /= CR
and then T
(P
) /= LF
loop
193 while T
(P
) = CR
or else T
(P
) = LF
loop
200 Write_Line
("fatal error, system.ads not formatted correctly");
202 raise Unrecoverable_Error
;
206 for K
in Targparm_Tags
loop
207 if not Targparm_Flags
(K
) then
210 ("fatal error: system.ads is incorrectly formatted");
211 Write_Str
("missing line for parameter: ");
213 for J
in Targparm_Str
(K
)'Range loop
214 Write_Char
(Targparm_Str
(K
).all (J
));
224 raise Unrecoverable_Error
;
226 end Get_Target_Parameters
;