summaryrefslogtreecommitdiff
path: root/gcc/ada/g-socthi-mingw.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-22 08:49:11 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-22 08:49:11 +0000
commitae1bba3e7a1b3e661b894caca86181a8ae475dac (patch)
tree213782122aa486f0afb1639800affca3d31088a3 /gcc/ada/g-socthi-mingw.adb
parenteaa830b55cd7a824a6c716206a8862c9d2674782 (diff)
downloadgcc-ae1bba3e7a1b3e661b894caca86181a8ae475dac.tar.gz
2010-06-22 Robert Dewar <dewar@adacore.com>
* sem_ch4.adb (Analyze_Conditional_Expression): Defend against malformed tree. * sprint.adb (Sprint_Node_Actual, case N_Conditional_Expression): Ditto. 2010-06-22 Arnaud Charlet <charlet@adacore.com> * s-intman-vxworks.ads: Code clean up. 2010-06-22 Thomas Quinot <quinot@adacore.com> * sem_res.adb (Resolve_Slice): When the prefix is an explicit dereference, construct actual subtype of designated object to generate proper bounds checks. 2010-06-22 Thomas Quinot <quinot@adacore.com> * ali-util.adb, ali-util.ads, gnatbind.adb (Read_ALI): Rename to Read_Withed_ALIs, which is more descriptive. 2010-06-22 Pascal Obry <obry@adacore.com> * g-sothco.ads: Minor reformatting. * g-socthi-mingw.adb: Remove part of work on the C_Recvmsg and C_Sendmsg implementation. (C_Sendmsg): Do not use lock (not needed). (C_Recvmsg): Likewise and also do not wait for incoming data. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161148 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-socthi-mingw.adb')
-rw-r--r--gcc/ada/g-socthi-mingw.adb81
1 files changed, 15 insertions, 66 deletions
diff --git a/gcc/ada/g-socthi-mingw.adb b/gcc/ada/g-socthi-mingw.adb
index 6cf0058e96c..6d7ca23f0b8 100644
--- a/gcc/ada/g-socthi-mingw.adb
+++ b/gcc/ada/g-socthi-mingw.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2001-2010, AdaCore --
+-- Copyright (C) 2001-2010, 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- --
@@ -43,8 +43,6 @@ 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
use type C.unsigned;
@@ -278,10 +276,8 @@ package body GNAT.Sockets.Thin is
is
use type C.size_t;
- Res : C.int;
- Count : C.int := 0;
- Locked : Boolean := False;
- -- Set to false when the lock is activated
+ Res : C.int;
+ Count : C.int := 0;
MH : Msghdr;
for MH'Address use Msg;
@@ -302,33 +298,8 @@ package body GNAT.Sockets.Thin is
begin
-- Windows does not provide an implementation of recvmsg(). The spec for
-- WSARecvMsg() is incompatible with the data types we define, and is
- -- not available in all versions of Windows. So, we use C_Recv instead.
-
- -- 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;
+ -- available starting with Windows Vista and Server 2008 only. So,
+ -- we use C_Recv instead.
-- Check how much data are available
@@ -354,7 +325,6 @@ package body GNAT.Sockets.Thin is
Flags);
if Res < 0 then
- Task_Lock.Unlock;
return System.CRTL.ssize_t (Res);
elsif Res = 0 then
@@ -370,25 +340,15 @@ package body GNAT.Sockets.Thin is
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.
+ -- If all the data that was initially available read, do not
+ -- attempt to receive more, since this might block, or merge data
+ -- from successive datagrams for a datagram-oriented socket.
exit when Natural (Count) >= Req.Size;
end if;
end loop;
- Task_Lock.Unlock;
-
return System.CRTL.ssize_t (Count);
-
- exception
- when others =>
- if Locked then
- Task_Lock.Unlock;
- end if;
- raise;
end C_Recvmsg;
--------------
@@ -411,8 +371,8 @@ package body GNAT.Sockets.Thin is
Last : aliased C.int;
begin
- -- Asynchronous connection failures are notified in the exception fd set
- -- instead of the write fd set. To ensure POSIX compatibility, copy
+ -- Asynchronous connection failures are notified in the exception fd
+ -- set instead of the write fd set. To ensure POSIX compatibility, copy
-- write fd set into exception fd set. Once select() returns, check any
-- socket present in the exception fd set and peek at incoming
-- out-of-band data. If the test is not successful, and the socket is
@@ -511,13 +471,10 @@ package body GNAT.Sockets.Thin is
begin
-- Windows does not provide an implementation of sendmsg(). The spec for
-- WSASendMsg() is incompatible with the data types we define, and is
- -- not available in all versions of Windows. So, we'll use C_Sendto
- -- instead.
-
- Task_Lock.Lock;
+ -- available starting with Windows Vista and Server 2008 only. So
+ -- use C_Sendto instead.
for J in Iovec'Range loop
-
Res :=
C_Sendto
(S,
@@ -528,20 +485,13 @@ package body GNAT.Sockets.Thin is
Tolen => C.int (MH.Msg_Namelen));
if Res < 0 then
- Task_Lock.Unlock;
return System.CRTL.ssize_t (Res);
else
Count := Count + Res;
end if;
end loop;
- Task_Lock.Unlock;
-
return System.CRTL.ssize_t (Count);
- exception
- when others =>
- Task_Lock.Unlock;
- raise;
end C_Sendmsg;
--------------
@@ -563,13 +513,12 @@ package body GNAT.Sockets.Thin is
package body Host_Error_Messages is
-- On Windows, socket and host errors share the same code space, and
- -- error messages are provided by Socket_Error_Message. The default
- -- separate body for Host_Error_Messages is therefore not used in
- -- this case.
+ -- error messages are provided by Socket_Error_Message, so the default
+ -- separate body for Host_Error_Messages is not used in this case.
function Host_Error_Message
(H_Errno : Integer) return C.Strings.chars_ptr
- renames Socket_Error_Message;
+ renames Socket_Error_Message;
end Host_Error_Messages;