Commit 48b351d9 by Arnaud Charlet

[multiple changes]

2010-06-18  Thomas Quinot  <quinot@adacore.com>

	* g-socket.adb, g-socket.ads (Null_Selector): New object.

2010-06-18  Pascal Obry  <obry@adacore.com>

	* gnat_ugn.texi: Minor clarification.

2010-06-18  Emmanuel Briot  <briot@adacore.com>

	* prj-nmsc.adb (Find_Source_Dirs): Minor refactoring to avoid duplicate
	code when using the project dir as the source dir.
	(Search_Directories): use the normalized name for the source directory,
	where symbolic names have potentially been resolved.

2010-06-18  Robert Dewar  <dewar@adacore.com>

	* exp_ch4.adb (Expand_N_Conditional_Expression): Clear Actions field
	when we create N_Expression_With_Actions node.
	(Expand_Short_Circuit): Ditto.

2010-06-18  Robert Dewar  <dewar@adacore.com>

	* exp_util.adb: Minor reformatting.

From-SVN: r160975
parent 6a497607
2010-06-18 Thomas Quinot <quinot@adacore.com> 2010-06-18 Thomas Quinot <quinot@adacore.com>
* g-socket.adb, g-socket.ads (Null_Selector): New object.
2010-06-18 Pascal Obry <obry@adacore.com>
* gnat_ugn.texi: Minor clarification.
2010-06-18 Emmanuel Briot <briot@adacore.com>
* prj-nmsc.adb (Find_Source_Dirs): Minor refactoring to avoid duplicate
code when using the project dir as the source dir.
(Search_Directories): use the normalized name for the source directory,
where symbolic names have potentially been resolved.
2010-06-18 Robert Dewar <dewar@adacore.com>
* exp_ch4.adb (Expand_N_Conditional_Expression): Clear Actions field
when we create N_Expression_With_Actions node.
(Expand_Short_Circuit): Ditto.
2010-06-18 Robert Dewar <dewar@adacore.com>
* exp_util.adb: Minor reformatting.
2010-06-18 Thomas Quinot <quinot@adacore.com>
* types.ads: Clean up obsolete comments * types.ads: Clean up obsolete comments
* tbuild.adb: Minor reformatting. * tbuild.adb: Minor reformatting.
* exp_ch5.adb, sem_intr.adb, sem_ch10.adb, rtsfind.adb, s-shasto.adb, * exp_ch5.adb, sem_intr.adb, sem_ch10.adb, rtsfind.adb, s-shasto.adb,
......
...@@ -4111,6 +4111,7 @@ package body Exp_Ch4 is ...@@ -4111,6 +4111,7 @@ package body Exp_Ch4 is
Make_Expression_With_Actions (Sloc (Thenx), Make_Expression_With_Actions (Sloc (Thenx),
Actions => Then_Actions (N), Actions => Then_Actions (N),
Expression => Relocate_Node (Thenx))); Expression => Relocate_Node (Thenx)));
Set_Then_Actions (N, No_List);
Analyze_And_Resolve (Thenx, Typ); Analyze_And_Resolve (Thenx, Typ);
end if; end if;
...@@ -4119,6 +4120,7 @@ package body Exp_Ch4 is ...@@ -4119,6 +4120,7 @@ package body Exp_Ch4 is
Make_Expression_With_Actions (Sloc (Elsex), Make_Expression_With_Actions (Sloc (Elsex),
Actions => Else_Actions (N), Actions => Else_Actions (N),
Expression => Relocate_Node (Elsex))); Expression => Relocate_Node (Elsex)));
Set_Else_Actions (N, No_List);
Analyze_And_Resolve (Elsex, Typ); Analyze_And_Resolve (Elsex, Typ);
end if; end if;
...@@ -9044,6 +9046,7 @@ package body Exp_Ch4 is ...@@ -9044,6 +9046,7 @@ package body Exp_Ch4 is
Make_Expression_With_Actions (LocR, Make_Expression_With_Actions (LocR,
Expression => Relocate_Node (Right), Expression => Relocate_Node (Right),
Actions => Actlist)); Actions => Actlist));
Set_Actions (N, No_List);
Analyze_And_Resolve (Right, Standard_Boolean); Analyze_And_Resolve (Right, Standard_Boolean);
end if; end if;
......
...@@ -4685,7 +4685,7 @@ package body Exp_Util is ...@@ -4685,7 +4685,7 @@ package body Exp_Util is
-- If it is a scalar type and we need to capture the value, just make -- If it is a scalar type and we need to capture the value, just make
-- a copy. Likewise for a function call, an attribute reference, an -- a copy. Likewise for a function call, an attribute reference, an
-- allocator or an operator. And if we have a volatile reference and -- allocator, or an operator. And if we have a volatile reference and
-- Name_Req is not set (see comments above for Side_Effect_Free). -- Name_Req is not set (see comments above for Side_Effect_Free).
if Is_Elementary_Type (Exp_Type) if Is_Elementary_Type (Exp_Type)
......
...@@ -273,7 +273,8 @@ package body GNAT.Sockets is ...@@ -273,7 +273,8 @@ package body GNAT.Sockets is
function Is_Open (S : Selector_Type) return Boolean; function Is_Open (S : Selector_Type) return Boolean;
-- Return True for an "open" Selector_Type object, i.e. one for which -- Return True for an "open" Selector_Type object, i.e. one for which
-- Create_Selector has been called and Close_Selector has not been called. -- Create_Selector has been called and Close_Selector has not been called,
-- or the null selector.
--------- ---------
-- "+" -- -- "+" --
...@@ -294,6 +295,10 @@ package body GNAT.Sockets is ...@@ -294,6 +295,10 @@ package body GNAT.Sockets is
begin begin
if not Is_Open (Selector) then if not Is_Open (Selector) then
raise Program_Error with "closed selector"; raise Program_Error with "closed selector";
elsif Selector.Is_Null then
raise Program_Error with "null selector";
end if; end if;
-- Send one byte to unblock select system call -- Send one byte to unblock select system call
...@@ -491,7 +496,7 @@ package body GNAT.Sockets is ...@@ -491,7 +496,7 @@ package body GNAT.Sockets is
is is
Res : C.int; Res : C.int;
Last : C.int; Last : C.int;
RSig : constant Socket_Type := Selector.R_Sig_Socket; RSig : Socket_Type := No_Socket;
TVal : aliased Timeval; TVal : aliased Timeval;
TPtr : Timeval_Access; TPtr : Timeval_Access;
...@@ -511,9 +516,12 @@ package body GNAT.Sockets is ...@@ -511,9 +516,12 @@ package body GNAT.Sockets is
TPtr := TVal'Unchecked_Access; TPtr := TVal'Unchecked_Access;
end if; end if;
-- Add read signalling socket -- Add read signalling socket, if present
Set (R_Socket_Set, RSig); if not Selector.Is_Null then
RSig := Selector.R_Sig_Socket;
Set (R_Socket_Set, RSig);
end if;
Last := C.int'Max (C.int'Max (C.int (R_Socket_Set.Last), Last := C.int'Max (C.int'Max (C.int (R_Socket_Set.Last),
C.int (W_Socket_Set.Last)), C.int (W_Socket_Set.Last)),
...@@ -540,7 +548,7 @@ package body GNAT.Sockets is ...@@ -540,7 +548,7 @@ package body GNAT.Sockets is
-- If Select was resumed because of read signalling socket, read this -- If Select was resumed because of read signalling socket, read this
-- data and remove socket from set. -- data and remove socket from set.
if Is_Set (R_Socket_Set, RSig) then if RSig /= No_Socket and then Is_Set (R_Socket_Set, RSig) then
Clear (R_Socket_Set, RSig); Clear (R_Socket_Set, RSig);
Res := Signalling_Fds.Read (C.int (RSig)); Res := Signalling_Fds.Read (C.int (RSig));
...@@ -585,10 +593,9 @@ package body GNAT.Sockets is ...@@ -585,10 +593,9 @@ package body GNAT.Sockets is
procedure Close_Selector (Selector : in out Selector_Type) is procedure Close_Selector (Selector : in out Selector_Type) is
begin begin
if not Is_Open (Selector) then -- Nothing to do if selector already in closed state
-- Selector already in closed state: nothing to do
if Selector.Is_Null or else not Is_Open (Selector) then
return; return;
end if; end if;
...@@ -1425,14 +1432,19 @@ package body GNAT.Sockets is ...@@ -1425,14 +1432,19 @@ package body GNAT.Sockets is
function Is_Open (S : Selector_Type) return Boolean is function Is_Open (S : Selector_Type) return Boolean is
begin begin
-- Either both controlling socket descriptors are valid (case of an if S.Is_Null then
-- open selector) or neither (case of a closed selector). return True;
else
-- Either both controlling socket descriptors are valid (case of an
-- open selector) or neither (case of a closed selector).
pragma Assert ((S.R_Sig_Socket /= No_Socket) pragma Assert ((S.R_Sig_Socket /= No_Socket)
= =
(S.W_Sig_Socket /= No_Socket)); (S.W_Sig_Socket /= No_Socket));
return S.R_Sig_Socket /= No_Socket; return S.R_Sig_Socket /= No_Socket;
end if;
end Is_Open; end Is_Open;
------------ ------------
......
...@@ -422,6 +422,11 @@ package GNAT.Sockets is ...@@ -422,6 +422,11 @@ package GNAT.Sockets is
type Selector_Access is access all Selector_Type; type Selector_Access is access all Selector_Type;
-- Selector objects are used to wait for i/o events to occur on sockets -- Selector objects are used to wait for i/o events to occur on sockets
Null_Selector : constant Selector_Type;
-- The Null_Selector can be used in place of a normal selector without
-- having to call Create_Selector if the use of Abort_Selector is not
-- required.
-- Timeval_Duration is a subtype of Standard.Duration because the full -- Timeval_Duration is a subtype of Standard.Duration because the full
-- range of Standard.Duration cannot be represented in the equivalent C -- range of Standard.Duration cannot be represented in the equivalent C
-- structure. Moreover, negative values are not allowed to avoid system -- structure. Moreover, negative values are not allowed to avoid system
...@@ -1067,7 +1072,7 @@ package GNAT.Sockets is ...@@ -1067,7 +1072,7 @@ package GNAT.Sockets is
-- the situation where a change to the monitored sockets set must be made. -- the situation where a change to the monitored sockets set must be made.
procedure Create_Selector (Selector : out Selector_Type); procedure Create_Selector (Selector : out Selector_Type);
-- Create a new selector -- Initialize (open) a new selector
procedure Close_Selector (Selector : in out Selector_Type); procedure Close_Selector (Selector : in out Selector_Type);
-- Close Selector and all internal descriptors associated; deallocate any -- Close Selector and all internal descriptors associated; deallocate any
...@@ -1110,7 +1115,8 @@ package GNAT.Sockets is ...@@ -1110,7 +1115,8 @@ package GNAT.Sockets is
-- different objects. -- different objects.
procedure Abort_Selector (Selector : Selector_Type); procedure Abort_Selector (Selector : Selector_Type);
-- Send an abort signal to the selector -- Send an abort signal to the selector. The Selector may not be the
-- Null_Selector.
type Fd_Set is private; type Fd_Set is private;
-- ??? This type must not be used directly, it needs to be visible because -- ??? This type must not be used directly, it needs to be visible because
...@@ -1126,14 +1132,28 @@ private ...@@ -1126,14 +1132,28 @@ private
type Socket_Type is new Integer; type Socket_Type is new Integer;
No_Socket : constant Socket_Type := -1; No_Socket : constant Socket_Type := -1;
type Selector_Type is limited record -- A selector is either a null selector, which is always "open" and can
R_Sig_Socket : Socket_Type := No_Socket; -- never be aborted, or a regular selector, which is created "closed",
W_Sig_Socket : Socket_Type := No_Socket; -- becomes "open" when Create_Selector is called, and "closed" again when
-- Signalling sockets used to abort a select operation -- Close_Selector is called.
type Selector_Type (Is_Null : Boolean := False) is limited record
case Is_Null is
when True =>
null;
when False =>
R_Sig_Socket : Socket_Type := No_Socket;
W_Sig_Socket : Socket_Type := No_Socket;
-- Signalling sockets used to abort a select operation
end case;
end record; end record;
pragma Volatile (Selector_Type); pragma Volatile (Selector_Type);
Null_Selector : constant Selector_Type := (Is_Null => True);
type Fd_Set is type Fd_Set is
new System.Storage_Elements.Storage_Array (1 .. SOSC.SIZEOF_fd_set); new System.Storage_Elements.Storage_Array (1 .. SOSC.SIZEOF_fd_set);
for Fd_Set'Alignment use Interfaces.C.long'Alignment; for Fd_Set'Alignment use Interfaces.C.long'Alignment;
......
...@@ -11549,7 +11549,8 @@ regular files. ...@@ -11549,7 +11549,8 @@ regular files.
@noindent @noindent
One or several Naming Patterns may be given as arguments to @code{gnatname}. One or several Naming Patterns may be given as arguments to @code{gnatname}.
Each Naming Pattern is enclosed between double quotes. Each Naming Pattern is enclosed between double quotes (or single
quotes on Windows).
A Naming Pattern is a regular expression similar to the wildcard patterns A Naming Pattern is a regular expression similar to the wildcard patterns
used in file names by the Unix shells or the DOS prompt. used in file names by the Unix shells or the DOS prompt.
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