Commit 6989bc1f by Arnaud Charlet

[multiple changes]

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

	* sem_aggr.adb (Resolve_Record_Aggregate): Do style check on component
	name.
	* sem_ch10.adb (Analyze_Subunit): Do style check on parent unit name.
	* sem_ch8.adb (Find_Direct_Name): For non-overloadable entities, do
	style check.
	* sem_res.adb (Resolve_Entity_Name): Do style check for enumeration
	literals.

2010-06-22  Vincent Celier  <celier@adacore.com>

	* make.adb (Scan_Make_Arg): No longer pass -nostdlib to the compiler as
	it has no effect. Always pass -nostdlib to gnatlink, even on VMS.

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

	* g-socthi-mingw.adb: Fix implementation of the vectored sockets on
	Windows.
	(C_Recvmsg): Make sure the routine is atomic. Also fully
	fill vectors in the proper order.
	(C_Sendmsg): Make sure the routine is atomic.

From-SVN: r161144
parent 964f13da
2010-06-22 Robert Dewar <dewar@adacore.com> 2010-06-22 Robert Dewar <dewar@adacore.com>
* sem_aggr.adb (Resolve_Record_Aggregate): Do style check on component
name.
* sem_ch10.adb (Analyze_Subunit): Do style check on parent unit name.
* sem_ch8.adb (Find_Direct_Name): For non-overloadable entities, do
style check.
* sem_res.adb (Resolve_Entity_Name): Do style check for enumeration
literals.
2010-06-22 Vincent Celier <celier@adacore.com>
* make.adb (Scan_Make_Arg): No longer pass -nostdlib to the compiler as
it has no effect. Always pass -nostdlib to gnatlink, even on VMS.
2010-06-22 Pascal Obry <obry@adacore.com>
* g-socthi-mingw.adb: Fix implementation of the vectored sockets on
Windows.
(C_Recvmsg): Make sure the routine is atomic. Also fully
fill vectors in the proper order.
(C_Sendmsg): Make sure the routine is atomic.
2010-06-22 Robert Dewar <dewar@adacore.com>
* sem_ch8.adb: Update comment. * sem_ch8.adb: Update comment.
* sem_res.adb: Minor code reorganization (use Ekind_In). * sem_res.adb: Minor code reorganization (use Ekind_In).
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2009, AdaCore -- -- Copyright (C) 2001-2010, AdaCore --
-- -- -- --
-- 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- --
...@@ -37,8 +37,13 @@ ...@@ -37,8 +37,13 @@
-- This version is for NT -- This version is for NT
with Interfaces.C.Strings; use Interfaces.C.Strings; with Ada.Streams; use Ada.Streams;
with System; use System; with Ada.Unchecked_Conversion;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with System; use System;
with System.Storage_Elements; use System.Storage_Elements;
with GNAT.Task_Lock;
package body GNAT.Sockets.Thin is package body GNAT.Sockets.Thin is
...@@ -273,8 +278,10 @@ package body GNAT.Sockets.Thin is ...@@ -273,8 +278,10 @@ package body GNAT.Sockets.Thin is
is is
use type C.size_t; use type C.size_t;
Res : C.int; Res : C.int;
Count : C.int := 0; Count : C.int := 0;
Locked : Boolean := False;
-- Set to false when the lock is activated
MH : Msghdr; MH : Msghdr;
for MH'Address use Msg; for MH'Address use Msg;
...@@ -283,26 +290,105 @@ package body GNAT.Sockets.Thin is ...@@ -283,26 +290,105 @@ package body GNAT.Sockets.Thin is
for Iovec'Address use MH.Msg_Iov; for Iovec'Address use MH.Msg_Iov;
pragma Import (Ada, Iovec); pragma Import (Ada, Iovec);
Iov_Index : Integer;
Current_Iovec : Vector_Element;
function To_Access is new Ada.Unchecked_Conversion
(System.Address, Stream_Element_Reference);
pragma Warnings (Off, Stream_Element_Reference);
Req : Request_Type (Name => N_Bytes_To_Read);
begin begin
-- Windows does not provide an implementation of recvmsg(). The spec for -- Windows does not provide an implementation of recvmsg(). The spec for
-- WSARecvMsg() is incompatible with the data types we define, and is -- WSARecvMsg() is incompatible with the data types we define, and is
-- not available in all versions of Windows. So, we use C_Recv instead. -- not available in all versions of Windows. So, we use C_Recv instead.
for J in Iovec'Range loop -- First, wait for some data to be available if socket is blocking
declare
Selector : Selector_Type;
R_Socket_Set : Socket_Set_Type;
W_Socket_Set : Socket_Set_Type;
Status : Selector_Status;
Req : Request_Type (Name => Non_Blocking_IO);
begin
Control_Socket (Socket_Type (S), Req);
if not Req.Enabled then
-- We are in a blocking IO mode
Create_Selector (Selector);
Set (R_Socket_Set, Socket_Type (S));
Check_Selector (Selector, R_Socket_Set, W_Socket_Set, Status);
Close_Selector (Selector);
end if;
end;
GNAT.Task_Lock.Lock;
Locked := True;
-- Check how much data are available
Control_Socket (Socket_Type (S), Req);
-- Fill the vectors
Iov_Index := -1;
Current_Iovec := (Base => null, Length => 0);
loop
if Current_Iovec.Length = 0 then
Iov_Index := Iov_Index + 1;
exit when Iov_Index > Integer (Iovec'Last);
Current_Iovec := Iovec (SOSC.Msg_Iovlen_T (Iov_Index));
end if;
Res := Res :=
C_Recv C_Recv
(S, (S,
Iovec (J).Base.all'Address, Current_Iovec.Base.all'Address,
C.int (Iovec (J).Length), C.int (Current_Iovec.Length),
Flags); Flags);
if Res < 0 then if Res < 0 then
Task_Lock.Unlock;
return System.CRTL.ssize_t (Res); return System.CRTL.ssize_t (Res);
elsif Res = 0 then
exit;
else else
pragma Assert (Stream_Element_Count (Res) <= Current_Iovec.Length);
Count := Count + Res; Count := Count + Res;
Current_Iovec.Length :=
Current_Iovec.Length - Stream_Element_Count (Res);
Current_Iovec.Base :=
To_Access (Current_Iovec.Base.all'Address
+ Storage_Offset (Res));
-- If we have read all the data that was initially available,
-- do not attempt to receive more, since this might block, or
-- merge data from successive datagrams in case of a datagram-
-- oriented socket.
exit when Natural (Count) >= Req.Size;
end if; end if;
end loop; end loop;
Task_Lock.Unlock;
return System.CRTL.ssize_t (Count); return System.CRTL.ssize_t (Count);
exception
when others =>
if Locked then
Task_Lock.Unlock;
end if;
raise;
end C_Recvmsg; end C_Recvmsg;
-------------- --------------
...@@ -428,7 +514,10 @@ package body GNAT.Sockets.Thin is ...@@ -428,7 +514,10 @@ package body GNAT.Sockets.Thin is
-- not available in all versions of Windows. So, we'll use C_Sendto -- not available in all versions of Windows. So, we'll use C_Sendto
-- instead. -- instead.
Task_Lock.Lock;
for J in Iovec'Range loop for J in Iovec'Range loop
Res := Res :=
C_Sendto C_Sendto
(S, (S,
...@@ -439,13 +528,20 @@ package body GNAT.Sockets.Thin is ...@@ -439,13 +528,20 @@ package body GNAT.Sockets.Thin is
Tolen => C.int (MH.Msg_Namelen)); Tolen => C.int (MH.Msg_Namelen));
if Res < 0 then if Res < 0 then
Task_Lock.Unlock;
return System.CRTL.ssize_t (Res); return System.CRTL.ssize_t (Res);
else else
Count := Count + Res; Count := Count + Res;
end if; end if;
end loop; end loop;
Task_Lock.Unlock;
return System.CRTL.ssize_t (Count); return System.CRTL.ssize_t (Count);
exception
when others =>
Task_Lock.Unlock;
raise;
end C_Sendmsg; end C_Sendmsg;
-------------- --------------
......
...@@ -8213,17 +8213,11 @@ package body Make is ...@@ -8213,17 +8213,11 @@ package body Make is
elsif Argv (2 .. Argv'Last) = "nostdlib" then elsif Argv (2 .. Argv'Last) = "nostdlib" then
No_Stdlib := True; -- Pass -nstdlib to gnatbind and gnatlink
Add_Switch (Argv, Compiler, And_Save => And_Save); No_Stdlib := True;
Add_Switch (Argv, Binder, And_Save => And_Save); Add_Switch (Argv, Binder, And_Save => And_Save);
Add_Switch (Argv, Linker, And_Save => And_Save);
-- On Open VMS, do not pass -nostdlib to gnatlink, it will disable
-- linking with all standard library files.
if not OpenVMS then
Add_Switch (Argv, Linker, And_Save => And_Save);
end if;
elsif Argv (2 .. Argv'Last) = "nostdinc" then elsif Argv (2 .. Argv'Last) = "nostdinc" then
......
...@@ -54,6 +54,7 @@ with Sinfo; use Sinfo; ...@@ -54,6 +54,7 @@ with Sinfo; use Sinfo;
with Snames; use Snames; with Snames; use Snames;
with Stringt; use Stringt; with Stringt; use Stringt;
with Stand; use Stand; with Stand; use Stand;
with Style; use Style;
with Targparm; use Targparm; with Targparm; use Targparm;
with Tbuild; use Tbuild; with Tbuild; use Tbuild;
with Uintp; use Uintp; with Uintp; use Uintp;
...@@ -3779,7 +3780,15 @@ package body Sem_Aggr is ...@@ -3779,7 +3780,15 @@ package body Sem_Aggr is
New_Assoc := First (New_Assoc_List); New_Assoc := First (New_Assoc_List);
while Present (New_Assoc) loop while Present (New_Assoc) loop
Component := First (Choices (New_Assoc)); Component := First (Choices (New_Assoc));
exit when Chars (Selectr) = Chars (Component);
if Chars (Selectr) = Chars (Component) then
if Style_Check then
Check_Identifier (Selectr, Entity (Component));
end if;
exit;
end if;
Next (New_Assoc); Next (New_Assoc);
end loop; end loop;
......
...@@ -2140,6 +2140,19 @@ package body Sem_Ch10 is ...@@ -2140,6 +2140,19 @@ package body Sem_Ch10 is
-- Start of processing for Analyze_Subunit -- Start of processing for Analyze_Subunit
begin begin
if Style_Check then
declare
Nam : Node_Id := Name (Unit (N));
begin
if Nkind (Nam) = N_Selected_Component then
Nam := Selector_Name (Nam);
end if;
Check_Identifier (Nam, Par_Unit);
end;
end if;
if not Is_Empty_List (Context_Items (N)) then if not Is_Empty_List (Context_Items (N)) then
-- Save current use clauses -- Save current use clauses
......
...@@ -4377,13 +4377,18 @@ package body Sem_Ch8 is ...@@ -4377,13 +4377,18 @@ package body Sem_Ch8 is
return; return;
end if; end if;
-- Set the entity. Note that the reason we call Set_Entity here, as -- Set the entity. Note that the reason we call Set_Entity for the
-- opposed to Set_Entity_With_Style_Check is that in the overloaded -- overloadable case, as opposed to Set_Entity_With_Style_Check is
-- case, the initial call can set the wrong homonym. The call that -- that in the overloaded case, the initial call can set the wrong
-- sets the right homonym is in Sem_Res and that call does use -- homonym. The call that sets the right homonym is in Sem_Res and
-- Set_Entity_With_Style_Check, so we don't miss a style check. -- that call does use Set_Entity_With_Style_Check, so we don't miss
-- a style check.
Set_Entity (N, E);
if Is_Overloadable (E) then
Set_Entity (N, E);
else
Set_Entity_With_Style_Check (N, E);
end if;
if Is_Type (E) then if Is_Type (E) then
Set_Etype (N, E); Set_Etype (N, E);
......
...@@ -5793,6 +5793,14 @@ package body Sem_Res is ...@@ -5793,6 +5793,14 @@ package body Sem_Res is
Set_Etype (N, Typ); Set_Etype (N, Typ);
Eval_Named_Real (N); Eval_Named_Real (N);
-- For enumeration literals, we need to make sure that a proper style
-- check is done, since such literals are overloaded, and thus we did
-- not do a style check during the first phase of analysis.
elsif Ekind (E) = E_Enumeration_Literal then
Set_Entity_With_Style_Check (N, E);
Eval_Entity_Name (N);
-- Allow use of subtype only if it is a concurrent type where we are -- Allow use of subtype only if it is a concurrent type where we are
-- currently inside the body. This will eventually be expanded into a -- currently inside the body. This will eventually be expanded into a
-- call to Self (for tasks) or _object (for protected objects). Any -- call to Self (for tasks) or _object (for protected objects). Any
...@@ -5847,7 +5855,6 @@ package body Sem_Res is ...@@ -5847,7 +5855,6 @@ package body Sem_Res is
and then not In_Spec_Expression and then not In_Spec_Expression
and then not Is_Imported (E) and then not Is_Imported (E)
then then
if No_Initialization (Parent (E)) if No_Initialization (Parent (E))
or else (Present (Full_View (E)) or else (Present (Full_View (E))
and then No_Initialization (Parent (Full_View (E)))) and then No_Initialization (Parent (Full_View (E))))
......
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