aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/g-socket.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-05-21 14:45:44 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2014-05-21 14:45:44 +0200
commit601bb6b35ea9a185c360d73a90a3fcd5c9d286fd (patch)
tree01924246c65a2bf6ef0efdfdee15ae7d5b7057f3 /gcc/ada/g-socket.adb
parentda574a866b86e92f0305e68ddb7f1993365fb5dd (diff)
downloadgcc-601bb6b35ea9a185c360d73a90a3fcd5c9d286fd.zip
gcc-601bb6b35ea9a185c360d73a90a3fcd5c9d286fd.tar.gz
gcc-601bb6b35ea9a185c360d73a90a3fcd5c9d286fd.tar.bz2
[multiple changes]
2014-05-21 Javier Miranda <miranda@adacore.com> * exp_ch4.adb (Expand_Allocator_Expression.Apply_Accessibility_Check): Complete previous patch. 2014-05-21 Thomas Quinot <quinot@adacore.com> * g-socket.adb (Read and Write for Datagram_Socket_Stream_Type): Provide a behaviour more consistent with underlying datagram socket: do not attempt to loop over Send_Socket/Receive_Socket iterating along the buffer. 2014-05-21 Hristian Kirtchev <kirtchev@adacore.com> * freeze.adb (Freeze_Record_Type): Ensure that a discriminated or a tagged type is not labelled as volatile. Ensure that a non-volatile type has no volatile components. * sem_ch3.adb (Analyze_Object_Contract): Add local constant Obj_Typ. Code reformatting. Ensure that a discriminated or tagged object is not labelled as volatile. * sem_prag.adb (Process_Atomic_Shared_Volatile): Ensure that pragma Volatile applies to a full type declaration or an object declaration when SPARK mode is on. 2014-05-21 Sergey Rybin <rybin@adacore.com frybin> * gnat_ugn.texi: For ASIS tools, reword the paragraph about providing options needed for compiling the argument source for the situation when a project file can be used as a tool parameter. 2014-05-21 Gary Dismukes <dismukes@adacore.com> * gnat_rm.texi: Minor typo fix. From-SVN: r210697
Diffstat (limited to 'gcc/ada/g-socket.adb')
-rw-r--r--gcc/ada/g-socket.adb111
1 files changed, 44 insertions, 67 deletions
diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb
index d5b74c6..ee4d52a 100644
--- a/gcc/ada/g-socket.adb
+++ b/gcc/ada/g-socket.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2001-2013, AdaCore --
+-- Copyright (C) 2001-2014, AdaCore --
-- --
-- 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- --
@@ -244,13 +244,6 @@ package body GNAT.Sockets is
(Stream : in out Stream_Socket_Stream_Type;
Item : Ada.Streams.Stream_Element_Array);
- procedure Stream_Write
- (Socket : Socket_Type;
- Item : Ada.Streams.Stream_Element_Array;
- To : access Sock_Addr_Type);
- -- Common implementation for the Write operation of Datagram_Socket_Stream_
- -- Type and Stream_Socket_Stream_Type.
-
procedure Wait_On_Socket
(Socket : Socket_Type;
For_Read : Boolean;
@@ -1732,27 +1725,12 @@ package body GNAT.Sockets is
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset)
is
- First : Ada.Streams.Stream_Element_Offset := Item'First;
- Index : Ada.Streams.Stream_Element_Offset := First - 1;
- Max : constant Ada.Streams.Stream_Element_Offset := Item'Last;
-
begin
- loop
- Receive_Socket
- (Stream.Socket,
- Item (First .. Max),
- Index,
- Stream.From);
-
- Last := Index;
-
- -- Exit when all or zero data received. Zero means that the socket
- -- peer is closed.
-
- exit when Index < First or else Index = Max;
-
- First := Index + 1;
- end loop;
+ Receive_Socket
+ (Stream.Socket,
+ Item,
+ Last,
+ Stream.From);
end Read;
----------
@@ -2419,43 +2397,6 @@ package body GNAT.Sockets is
return Stream_Access (S);
end Stream;
- ------------------
- -- Stream_Write --
- ------------------
-
- procedure Stream_Write
- (Socket : Socket_Type;
- Item : Ada.Streams.Stream_Element_Array;
- To : access Sock_Addr_Type)
- is
- First : Ada.Streams.Stream_Element_Offset;
- Index : Ada.Streams.Stream_Element_Offset;
- Max : constant Ada.Streams.Stream_Element_Offset := Item'Last;
-
- begin
- First := Item'First;
- Index := First - 1;
- while First <= Max loop
- Send_Socket (Socket, Item (First .. Max), Index, To);
-
- -- Exit when all or zero data sent. Zero means that the socket has
- -- been closed by peer.
-
- exit when Index < First or else Index = Max;
-
- First := Index + 1;
- end loop;
-
- -- For an empty array, we have First > Max, and hence Index >= Max (no
- -- error, the loop above is never executed). After a successful send,
- -- Index = Max. The only remaining case, Index < Max, is therefore
- -- always an actual send failure.
-
- if Index < Max then
- Raise_Socket_Error (Socket_Errno);
- end if;
- end Stream_Write;
-
----------
-- To_C --
----------
@@ -2695,8 +2636,20 @@ package body GNAT.Sockets is
(Stream : in out Datagram_Socket_Stream_Type;
Item : Ada.Streams.Stream_Element_Array)
is
+ Last : Stream_Element_Offset;
+
begin
- Stream_Write (Stream.Socket, Item, To => Stream.To'Unrestricted_Access);
+ Send_Socket
+ (Stream.Socket,
+ Item,
+ Last,
+ Stream.To);
+
+ -- It is an error if not all of the data has been sent
+
+ if Last /= Item'Last then
+ Raise_Socket_Error (Socket_Errno);
+ end if;
end Write;
-----------
@@ -2707,8 +2660,32 @@ package body GNAT.Sockets is
(Stream : in out Stream_Socket_Stream_Type;
Item : Ada.Streams.Stream_Element_Array)
is
+ First : Ada.Streams.Stream_Element_Offset;
+ Index : Ada.Streams.Stream_Element_Offset;
+ Max : constant Ada.Streams.Stream_Element_Offset := Item'Last;
+
begin
- Stream_Write (Stream.Socket, Item, To => null);
+ First := Item'First;
+ Index := First - 1;
+ while First <= Max loop
+ Send_Socket (Stream.Socket, Item (First .. Max), Index, null);
+
+ -- Exit when all or zero data sent. Zero means that the socket has
+ -- been closed by peer.
+
+ exit when Index < First or else Index = Max;
+
+ First := Index + 1;
+ end loop;
+
+ -- For an empty array, we have First > Max, and hence Index >= Max (no
+ -- error, the loop above is never executed). After a successful send,
+ -- Index = Max. The only remaining case, Index < Max, is therefore
+ -- always an actual send failure.
+
+ if Index < Max then
+ Raise_Socket_Error (Socket_Errno);
+ end if;
end Write;
Sockets_Library_Controller_Object : Sockets_Library_Controller;