Commit 9763f8c8 by Arnaud Charlet

[multiple changes]

2009-06-25  Ed Falis  <falis@adacore.com>

	* s-vxwext-rtp.ads: Add missing declaration

2009-06-25  Matthew Gingell  <gingell@adacore.com>

	* a-stwise.adb, a-stzsea.adb (Count, Index): Avoid local copy on stack,
	speed up unmapped case.

2009-06-25  Vincent Celier  <celier@adacore.com>

	* prj-nmsc.adb (Check): Change error message for illegal abstract
	projects.

2009-06-25  Robert Dewar  <dewar@adacore.com>

	* gnat_ugn.texi: Add note on use of -gnatct for ASIS

2009-06-25  Emmanuel Briot  <briot@adacore.com>

	* fmap.ads: Add documentation on mapping files

From-SVN: r148930
parent 3cb71167
2009-06-25 Ed Falis <falis@adacore.com>
* s-vxwext-rtp.ads: Add missing declaration
2009-06-25 Matthew Gingell <gingell@adacore.com>
* a-stwise.adb, a-stzsea.adb (Count, Index): Avoid local copy on stack,
speed up unmapped case.
2009-06-25 Vincent Celier <celier@adacore.com>
* prj-nmsc.adb (Check): Change error message for illegal abstract
projects.
2009-06-25 Robert Dewar <dewar@adacore.com>
* gnat_ugn.texi: Add note on use of -gnatct for ASIS
2009-06-25 Emmanuel Briot <briot@adacore.com>
* fmap.ads: Add documentation on mapping files
2009-06-25 Robert Dewar <dewar@adacore.com> 2009-06-25 Robert Dewar <dewar@adacore.com>
* exp_ch6.adb, g-socket.ads, g-socket.adb, sem_ch3.adb: Minor * exp_ch6.adb, g-socket.ads, g-socket.adb, sem_ch3.adb: Minor
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Ada.Strings.Wide_Maps; use Ada.Strings.Wide_Maps; with Ada.Strings.Wide_Maps; use Ada.Strings.Wide_Maps;
with System; use System;
package body Ada.Strings.Wide_Search is package body Ada.Strings.Wide_Search is
...@@ -72,44 +73,57 @@ package body Ada.Strings.Wide_Search is ...@@ -72,44 +73,57 @@ package body Ada.Strings.Wide_Search is
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity) Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural return Natural
is is
N : Natural; PL1 : constant Integer := Pattern'Length - 1;
J : Natural; Num : Natural;
Ind : Natural;
Cur : Natural;
begin begin
if Pattern = "" then if Pattern = "" then
raise Pattern_Error; raise Pattern_Error;
end if; end if;
-- Handle the case of non-identity mappings by creating a mapped Num := 0;
-- string and making a recursive call using the identity mapping Ind := Source'First;
-- on this mapped string.
-- Unmapped case
if Mapping'Address = Wide_Maps.Identity'Address then
Ind := Source'First;
while Ind <= Source'Length - PL1 loop
if Pattern = Source (Ind .. Ind + PL1) then
Num := Num + 1;
Ind := Ind + Pattern'Length;
else
Ind := Ind + 1;
end if;
end loop;
if Mapping /= Wide_Maps.Identity then -- Mapped case
declare
Mapped_Source : Wide_String (Source'Range);
begin else
for J in Source'Range loop Ind := Source'First;
Mapped_Source (J) := Value (Mapping, Source (J)); while Ind <= Source'Length - PL1 loop
Cur := Ind;
for K in Pattern'Range loop
if Pattern (K) /= Value (Mapping, Source (Cur)) then
Ind := Ind + 1;
goto Cont;
else
Cur := Cur + 1;
end if;
end loop; end loop;
return Count (Mapped_Source, Pattern); Num := Num + 1;
end; Ind := Ind + Pattern'Length;
end if;
N := 0; <<Cont>>
J := Source'First; null;
end loop;
end if;
while J <= Source'Last - (Pattern'Length - 1) loop -- Return result
if Source (J .. J + (Pattern'Length - 1)) = Pattern then
N := N + 1;
J := J + Pattern'Length;
else
J := J + 1;
end if;
end loop;
return N; return Num;
end Count; end Count;
function Count function Count
...@@ -117,14 +131,43 @@ package body Ada.Strings.Wide_Search is ...@@ -117,14 +131,43 @@ package body Ada.Strings.Wide_Search is
Pattern : Wide_String; Pattern : Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural
is is
Mapped_Source : Wide_String (Source'Range); PL1 : constant Integer := Pattern'Length - 1;
Num : Natural;
Ind : Natural;
Cur : Natural;
begin begin
for J in Source'Range loop if Pattern = "" then
Mapped_Source (J) := Mapping (Source (J)); raise Pattern_Error;
end if;
-- Check for null pointer in case checks are off
if Mapping = null then
raise Constraint_Error;
end if;
Num := 0;
Ind := Source'First;
while Ind <= Source'Last - PL1 loop
Cur := Ind;
for K in Pattern'Range loop
if Pattern (K) /= Mapping (Source (Cur)) then
Ind := Ind + 1;
goto Cont;
else
Cur := Cur + 1;
end if;
end loop;
Num := Num + 1;
Ind := Ind + Pattern'Length;
<<Cont>>
null;
end loop; end loop;
return Count (Mapped_Source, Pattern); return Num;
end Count; end Count;
function Count function Count
...@@ -166,8 +209,8 @@ package body Ada.Strings.Wide_Search is ...@@ -166,8 +209,8 @@ package body Ada.Strings.Wide_Search is
end if; end if;
end loop; end loop;
-- Here if J indexes 1st char of token, and all chars -- Here if J indexes first char of token, and all chars after J
-- after J are in the token -- are in the token.
Last := Source'Last; Last := Source'Last;
return; return;
...@@ -191,41 +234,88 @@ package body Ada.Strings.Wide_Search is ...@@ -191,41 +234,88 @@ package body Ada.Strings.Wide_Search is
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity) Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural return Natural
is is
PL1 : constant Integer := Pattern'Length - 1;
Ind : Natural;
Cur : Natural;
begin begin
if Pattern = "" then if Pattern = "" then
raise Pattern_Error; raise Pattern_Error;
end if; end if;
-- Handle the case of non-identity mappings by creating a mapped -- Forwards case
-- string and making a recursive call using the identity mapping
-- on this mapped string. if Going = Forward then
Ind := Source'First;
if Mapping /= Identity then -- Unmapped forward case
declare
Mapped_Source : Wide_String (Source'Range);
begin if Mapping'Address = Wide_Maps.Identity'Address then
for J in Source'Range loop for J in 1 .. Source'Length - PL1 loop
Mapped_Source (J) := Value (Mapping, Source (J)); if Pattern = Source (Ind .. Ind + PL1) then
return Ind;
else
Ind := Ind + 1;
end if;
end loop; end loop;
return Index (Mapped_Source, Pattern, Going); -- Mapped forward case
end;
end if;
if Going = Forward then else
for J in Source'First .. Source'Last - Pattern'Length + 1 loop for J in 1 .. Source'Length - PL1 loop
if Pattern = Source (J .. J + Pattern'Length - 1) then Cur := Ind;
return J;
end if;
end loop;
else -- Going = Backward for K in Pattern'Range loop
for J in reverse Source'First .. Source'Last - Pattern'Length + 1 loop if Pattern (K) /= Value (Mapping, Source (Cur)) then
if Pattern = Source (J .. J + Pattern'Length - 1) then goto Cont1;
return J; else
end if; Cur := Cur + 1;
end loop; end if;
end loop;
return Ind;
<<Cont1>>
Ind := Ind + 1;
end loop;
end if;
-- Backwards case
else
-- Unmapped backward case
Ind := Source'Last - PL1;
if Mapping'Address = Wide_Maps.Identity'Address then
for J in reverse 1 .. Source'Length - PL1 loop
if Pattern = Source (Ind .. Ind + PL1) then
return Ind;
else
Ind := Ind - 1;
end if;
end loop;
-- Mapped backward case
else
for J in reverse 1 .. Source'Length - PL1 loop
Cur := Ind;
for K in Pattern'Range loop
if Pattern (K) /= Value (Mapping, Source (Cur)) then
goto Cont2;
else
Cur := Cur + 1;
end if;
end loop;
return Ind;
<<Cont2>>
Ind := Ind - 1;
end loop;
end if;
end if; end if;
-- Fall through if no match found. Note that the loops are skipped -- Fall through if no match found. Note that the loops are skipped
...@@ -240,14 +330,68 @@ package body Ada.Strings.Wide_Search is ...@@ -240,14 +330,68 @@ package body Ada.Strings.Wide_Search is
Going : Direction := Forward; Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural
is is
Mapped_Source : Wide_String (Source'Range); PL1 : constant Integer := Pattern'Length - 1;
Ind : Natural;
Cur : Natural;
begin begin
for J in Source'Range loop if Pattern = "" then
Mapped_Source (J) := Mapping (Source (J)); raise Pattern_Error;
end loop; end if;
-- Check for null pointer in case checks are off
if Mapping = null then
raise Constraint_Error;
end if;
-- Forwards case
if Going = Forward then
Ind := Source'First;
for J in 1 .. Source'Length - PL1 loop
Cur := Ind;
for K in Pattern'Range loop
if Pattern (K) /= Mapping.all (Source (Cur)) then
goto Cont1;
else
Cur := Cur + 1;
end if;
end loop;
return Ind;
<<Cont1>>
Ind := Ind + 1;
end loop;
-- Backwards case
else
Ind := Source'Last - PL1;
for J in reverse 1 .. Source'Length - PL1 loop
Cur := Ind;
for K in Pattern'Range loop
if Pattern (K) /= Mapping.all (Source (Cur)) then
goto Cont2;
else
Cur := Cur + 1;
end if;
end loop;
return Ind;
return Index (Mapped_Source, Pattern, Going); <<Cont2>>
Ind := Ind - 1;
end loop;
end if;
-- Fall through if no match found. Note that the loops are skipped
-- completely in the case of the pattern being longer than the source.
return 0;
end Index; end Index;
function Index function Index
...@@ -257,6 +401,8 @@ package body Ada.Strings.Wide_Search is ...@@ -257,6 +401,8 @@ package body Ada.Strings.Wide_Search is
Going : Direction := Forward) return Natural Going : Direction := Forward) return Natural
is is
begin begin
-- Forwards case
if Going = Forward then if Going = Forward then
for J in Source'Range loop for J in Source'Range loop
if Belongs (Source (J), Set, Test) then if Belongs (Source (J), Set, Test) then
...@@ -264,7 +410,9 @@ package body Ada.Strings.Wide_Search is ...@@ -264,7 +410,9 @@ package body Ada.Strings.Wide_Search is
end if; end if;
end loop; end loop;
else -- Going = Backward -- Backwards case
else
for J in reverse Source'Range loop for J in reverse Source'Range loop
if Belongs (Source (J), Set, Test) then if Belongs (Source (J), Set, Test) then
return J; return J;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Ada.Strings.Wide_Wide_Maps; use Ada.Strings.Wide_Wide_Maps; with Ada.Strings.Wide_Wide_Maps; use Ada.Strings.Wide_Wide_Maps;
with System; use System;
package body Ada.Strings.Wide_Wide_Search is package body Ada.Strings.Wide_Wide_Search is
...@@ -73,44 +74,58 @@ package body Ada.Strings.Wide_Wide_Search is ...@@ -73,44 +74,58 @@ package body Ada.Strings.Wide_Wide_Search is
Wide_Wide_Maps.Identity) Wide_Wide_Maps.Identity)
return Natural return Natural
is is
N : Natural; PL1 : constant Integer := Pattern'Length - 1;
J : Natural; Num : Natural;
Ind : Natural;
Cur : Natural;
begin begin
if Pattern = "" then if Pattern = "" then
raise Pattern_Error; raise Pattern_Error;
end if; end if;
-- Handle the case of non-identity mappings by creating a mapped Num := 0;
-- string and making a recursive call using the identity mapping Ind := Source'First;
-- on this mapped string.
if Mapping /= Wide_Wide_Maps.Identity then -- Unmapped case
declare
Mapped_Source : Wide_Wide_String (Source'Range);
begin if Mapping'Address = Wide_Wide_Maps.Identity'Address then
for J in Source'Range loop Ind := Source'First;
Mapped_Source (J) := Value (Mapping, Source (J)); while Ind <= Source'Length - PL1 loop
if Pattern = Source (Ind .. Ind + PL1) then
Num := Num + 1;
Ind := Ind + Pattern'Length;
else
Ind := Ind + 1;
end if;
end loop;
-- Mapped case
else
Ind := Source'First;
while Ind <= Source'Length - PL1 loop
Cur := Ind;
for K in Pattern'Range loop
if Pattern (K) /= Value (Mapping, Source (Cur)) then
Ind := Ind + 1;
goto Cont;
else
Cur := Cur + 1;
end if;
end loop; end loop;
return Count (Mapped_Source, Pattern); Num := Num + 1;
end; Ind := Ind + Pattern'Length;
<<Cont>>
null;
end loop;
end if; end if;
N := 0; -- Return result
J := Source'First;
while J <= Source'Last - (Pattern'Length - 1) loop return Num;
if Source (J .. J + (Pattern'Length - 1)) = Pattern then
N := N + 1;
J := J + Pattern'Length;
else
J := J + 1;
end if;
end loop;
return N;
end Count; end Count;
function Count function Count
...@@ -119,14 +134,43 @@ package body Ada.Strings.Wide_Wide_Search is ...@@ -119,14 +134,43 @@ package body Ada.Strings.Wide_Wide_Search is
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
return Natural return Natural
is is
Mapped_Source : Wide_Wide_String (Source'Range); PL1 : constant Integer := Pattern'Length - 1;
Num : Natural;
Ind : Natural;
Cur : Natural;
begin begin
for J in Source'Range loop if Pattern = "" then
Mapped_Source (J) := Mapping (Source (J)); raise Pattern_Error;
end if;
-- Check for null pointer in case checks are off
if Mapping = null then
raise Constraint_Error;
end if;
Num := 0;
Ind := Source'First;
while Ind <= Source'Last - PL1 loop
Cur := Ind;
for K in Pattern'Range loop
if Pattern (K) /= Mapping (Source (Cur)) then
Ind := Ind + 1;
goto Cont;
else
Cur := Cur + 1;
end if;
end loop;
Num := Num + 1;
Ind := Ind + Pattern'Length;
<<Cont>>
null;
end loop; end loop;
return Count (Mapped_Source, Pattern); return Num;
end Count; end Count;
function Count function Count
...@@ -168,8 +212,8 @@ package body Ada.Strings.Wide_Wide_Search is ...@@ -168,8 +212,8 @@ package body Ada.Strings.Wide_Wide_Search is
end if; end if;
end loop; end loop;
-- Here if J indexes 1st char of token, and all chars -- Here if J indexes first char of token, and all chars after J
-- after J are in the token -- are in the token.
Last := Source'Last; Last := Source'Last;
return; return;
...@@ -194,41 +238,88 @@ package body Ada.Strings.Wide_Wide_Search is ...@@ -194,41 +238,88 @@ package body Ada.Strings.Wide_Wide_Search is
Wide_Wide_Maps.Identity) Wide_Wide_Maps.Identity)
return Natural return Natural
is is
PL1 : constant Integer := Pattern'Length - 1;
Ind : Natural;
Cur : Natural;
begin begin
if Pattern = "" then if Pattern = "" then
raise Pattern_Error; raise Pattern_Error;
end if; end if;
-- Handle the case of non-identity mappings by creating a mapped -- Forwards case
-- string and making a recursive call using the identity mapping
-- on this mapped string. if Going = Forward then
Ind := Source'First;
if Mapping /= Identity then -- Unmapped forward case
declare
Mapped_Source : Wide_Wide_String (Source'Range);
begin if Mapping'Address = Wide_Wide_Maps.Identity'Address then
for J in Source'Range loop for J in 1 .. Source'Length - PL1 loop
Mapped_Source (J) := Value (Mapping, Source (J)); if Pattern = Source (Ind .. Ind + PL1) then
return Ind;
else
Ind := Ind + 1;
end if;
end loop; end loop;
return Index (Mapped_Source, Pattern, Going); -- Mapped forward case
end;
end if;
if Going = Forward then else
for J in Source'First .. Source'Last - Pattern'Length + 1 loop for J in 1 .. Source'Length - PL1 loop
if Pattern = Source (J .. J + Pattern'Length - 1) then Cur := Ind;
return J;
end if;
end loop;
else -- Going = Backward for K in Pattern'Range loop
for J in reverse Source'First .. Source'Last - Pattern'Length + 1 loop if Pattern (K) /= Value (Mapping, Source (Cur)) then
if Pattern = Source (J .. J + Pattern'Length - 1) then goto Cont1;
return J; else
end if; Cur := Cur + 1;
end loop; end if;
end loop;
return Ind;
<<Cont1>>
Ind := Ind + 1;
end loop;
end if;
-- Backwards case
else
-- Unmapped backward case
Ind := Source'Last - PL1;
if Mapping'Address = Wide_Wide_Maps.Identity'Address then
for J in reverse 1 .. Source'Length - PL1 loop
if Pattern = Source (Ind .. Ind + PL1) then
return Ind;
else
Ind := Ind - 1;
end if;
end loop;
-- Mapped backward case
else
for J in reverse 1 .. Source'Length - PL1 loop
Cur := Ind;
for K in Pattern'Range loop
if Pattern (K) /= Value (Mapping, Source (Cur)) then
goto Cont2;
else
Cur := Cur + 1;
end if;
end loop;
return Ind;
<<Cont2>>
Ind := Ind - 1;
end loop;
end if;
end if; end if;
-- Fall through if no match found. Note that the loops are skipped -- Fall through if no match found. Note that the loops are skipped
...@@ -244,14 +335,68 @@ package body Ada.Strings.Wide_Wide_Search is ...@@ -244,14 +335,68 @@ package body Ada.Strings.Wide_Wide_Search is
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
return Natural return Natural
is is
Mapped_Source : Wide_Wide_String (Source'Range); PL1 : constant Integer := Pattern'Length - 1;
Ind : Natural;
Cur : Natural;
begin begin
for J in Source'Range loop if Pattern = "" then
Mapped_Source (J) := Mapping (Source (J)); raise Pattern_Error;
end loop; end if;
-- Check for null pointer in case checks are off
if Mapping = null then
raise Constraint_Error;
end if;
-- Forwards case
if Going = Forward then
Ind := Source'First;
for J in 1 .. Source'Length - PL1 loop
Cur := Ind;
for K in Pattern'Range loop
if Pattern (K) /= Mapping.all (Source (Cur)) then
goto Cont1;
else
Cur := Cur + 1;
end if;
end loop;
return Ind;
<<Cont1>>
Ind := Ind + 1;
end loop;
-- Backwards case
else
Ind := Source'Last - PL1;
for J in reverse 1 .. Source'Length - PL1 loop
Cur := Ind;
for K in Pattern'Range loop
if Pattern (K) /= Mapping.all (Source (Cur)) then
goto Cont2;
else
Cur := Cur + 1;
end if;
end loop;
return Ind;
return Index (Mapped_Source, Pattern, Going); <<Cont2>>
Ind := Ind - 1;
end loop;
end if;
-- Fall through if no match found. Note that the loops are skipped
-- completely in the case of the pattern being longer than the source.
return 0;
end Index; end Index;
function Index function Index
...@@ -261,6 +406,8 @@ package body Ada.Strings.Wide_Wide_Search is ...@@ -261,6 +406,8 @@ package body Ada.Strings.Wide_Wide_Search is
Going : Direction := Forward) return Natural Going : Direction := Forward) return Natural
is is
begin begin
-- Forwards case
if Going = Forward then if Going = Forward then
for J in Source'Range loop for J in Source'Range loop
if Belongs (Source (J), Set, Test) then if Belongs (Source (J), Set, Test) then
...@@ -268,7 +415,9 @@ package body Ada.Strings.Wide_Wide_Search is ...@@ -268,7 +415,9 @@ package body Ada.Strings.Wide_Wide_Search is
end if; end if;
end loop; end loop;
else -- Going = Backward -- Backwards case
else
for J in reverse Source'Range loop for J in reverse Source'Range loop
if Belongs (Source (J), Set, Test) then if Belongs (Source (J), Set, Test) then
return J; return J;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2001-2007, Free Software Foundation, Inc. -- -- Copyright (C) 2001-2009, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -25,6 +25,15 @@ ...@@ -25,6 +25,15 @@
-- This package keeps two mappings: from unit names to file names, -- This package keeps two mappings: from unit names to file names,
-- and from file names to path names. -- and from file names to path names.
--
-- This mapping is used to communicate between the builder (gnatmake or
-- gprbuild) and the compiler. The format of this mapping file is the
-- following:
-- For each source file, there are three lines in the mapping file:
-- Unit name with %b or %s added depending on whether it is a body or a spec
-- File name
-- Path name (set to '/' if the file should be ignored in fact, ie for
-- a Locally_Removed_File in a project)
with Namet; use Namet; with Namet; use Namet;
......
...@@ -6996,6 +6996,8 @@ This not normally required, but is used by separate analysis tools. ...@@ -6996,6 +6996,8 @@ This not normally required, but is used by separate analysis tools.
Typically Typically
these tools do the necessary compilations automatically, so you should these tools do the necessary compilations automatically, so you should
not have to specify this switch in normal operation. not have to specify this switch in normal operation.
Note that the combination of switches @option{-gnatct} generates a tree
in the form required by ASIS applications.
@item -gnatu @item -gnatu
@cindex @option{-gnatu} (@command{gcc}) @cindex @option{-gnatu} (@command{gcc})
...@@ -881,8 +881,8 @@ package body Prj.Nmsc is ...@@ -881,8 +881,8 @@ package body Prj.Nmsc is
else else
Error_Msg Error_Msg
(Project, In_Tree, (Project, In_Tree,
"an abstract project needs to have no language, " & "at least one of Source_Files, Source_Dirs or Languages " &
"no sources or no source directories", "must be declared empty for an abstract project",
Project.Location); Project.Location);
end if; end if;
end; end;
......
...@@ -81,4 +81,13 @@ package System.VxWorks.Ext is ...@@ -81,4 +81,13 @@ package System.VxWorks.Ext is
function Set_Time_Slice (ticks : int) return int; function Set_Time_Slice (ticks : int) return int;
pragma Inline (Set_Time_Slice); pragma Inline (Set_Time_Slice);
--------------------------------
-- Processor Affinity for SMP --
--------------------------------
function taskCpuAffinitySet (tid : t_id; CPU : int) return int;
pragma Convention (C, taskCpuAffinitySet);
-- For SMP run-times set the CPU affinity.
-- For uniprocessor systems return ERROR status.
end System.VxWorks.Ext; end System.VxWorks.Ext;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment