From ac72c9c53779907040fa8dfb0caf199cd890ac32 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Wed, 29 Apr 2009 12:49:15 +0200 Subject: [multiple changes] 2009-04-29 Gary Dismukes * exp_ch3.adb (Stream_Operation_OK): Return True for limited interfaces (other conditions permitting), so that abstract stream subprograms will be declared for them. 2009-04-29 Bob Duff * g-expect.adb (Expect_Internal): Fix check for overfull buffer. * g-expect.ads: Minor comment fixes. 2009-04-29 Ed Schonberg * freeze.adb, lib-xref.adb (Check_Dispatching_Operation): if the dispatching operation is a body without previous spec, update the list of primitive operations to ensure that cross-reference information is up-to-date. 2009-04-29 Albert Lee * g-socthi-vms.adb, g-socthi-vms.ads, g-socthi-vxworks.adb, g-socthi-vxworks.ads, g-socthi-mingw.adb, g-socthi-mingw.ads, g-socthi.adb, g-socthi.ads, g-socket.adb, g-socket.ads (GNAT.Sockets.Thin.C_Readv, GNAT.Sockets.Thin.C_Writev): Remove unused subprograms. (GNAT.Sockets.Thin.C_Recvmsg, GNAT.Sockets.Thin.C_Sendmsg): New bindings to call recvmsg(2) and sendmsg(2). (GNAT.Sockets.Receive_Vector, GNAT.Sockets.Send_Vector): Use C_Recvmsg/C_Sendmsg rather than Readv/C_Writev. From-SVN: r146949 --- gcc/ada/g-socket.adb | 92 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 34 deletions(-) (limited to 'gcc/ada/g-socket.adb') diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb index cc31d142c57..70964053074 100644 --- a/gcc/ada/g-socket.adb +++ b/gcc/ada/g-socket.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2008, AdaCore -- +-- Copyright (C) 2001-2009, 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- -- @@ -1657,6 +1657,41 @@ package body GNAT.Sockets is From.Port := Port_Type (Network_To_Short (Sin.Sin_Port)); end Receive_Socket; + -------------------- + -- Receive_Vector -- + -------------------- + + procedure Receive_Vector + (Socket : Socket_Type; + Vector : Vector_Type; + Count : out Ada.Streams.Stream_Element_Count; + Flags : Request_Flag_Type := No_Request_Flag) + is + Res : ssize_t; + + Msg : Msghdr := + (Msg_Name => System.Null_Address, + Msg_Namelen => 0, + Msg_Iov => Vector'Address, + Msg_Iovlen => Vector'Length, + Msg_Control => System.Null_Address, + Msg_Controllen => 0, + Msg_Flags => 0); + + begin + Res := + C_Recvmsg + (C.int (Socket), + Msg'Address, + To_Int (Flags)); + + if Res = ssize_t (Failure) then + Raise_Socket_Error (Socket_Errno); + end if; + + Count := Ada.Streams.Stream_Element_Count (Res); + end Receive_Vector; + ------------------- -- Resolve_Error -- ------------------- @@ -1782,31 +1817,6 @@ package body GNAT.Sockets is end if; end Resolve_Exception; - -------------------- - -- Receive_Vector -- - -------------------- - - procedure Receive_Vector - (Socket : Socket_Type; - Vector : Vector_Type; - Count : out Ada.Streams.Stream_Element_Count) - is - Res : C.int; - - begin - Res := - C_Readv - (C.int (Socket), - Vector'Address, - Vector'Length); - - if Res = Failure then - Raise_Socket_Error (Socket_Errno); - end if; - - Count := Ada.Streams.Stream_Element_Count (Res); - end Receive_Vector; - ----------------- -- Send_Socket -- ----------------- @@ -1891,11 +1901,15 @@ package body GNAT.Sockets is procedure Send_Vector (Socket : Socket_Type; Vector : Vector_Type; - Count : out Ada.Streams.Stream_Element_Count) + Count : out Ada.Streams.Stream_Element_Count; + Flags : Request_Flag_Type := No_Request_Flag) is - Res : C.int; - Iov_Count : C.int; - This_Iov_Count : C.int; + use type C.size_t; + + Res : ssize_t; + Iov_Count : C.size_t; + This_Iov_Count : C.size_t; + Msg : Msghdr; begin Count := 0; @@ -1913,13 +1927,23 @@ package body GNAT.Sockets is pragma Warnings (On); + Msg := + (Msg_Name => System.Null_Address, + Msg_Namelen => 0, + Msg_Iov => Vector + (Vector'First + Integer (Iov_Count))'Address, + Msg_Iovlen => This_Iov_Count, + Msg_Control => System.Null_Address, + Msg_Controllen => 0, + Msg_Flags => 0); + Res := - C_Writev + C_Sendmsg (C.int (Socket), - Vector (Vector'First + Integer (Iov_Count))'Address, - This_Iov_Count); + Msg'Address, + Set_Forced_Flags (To_Int (Flags))); - if Res = Failure then + if Res = ssize_t (Failure) then Raise_Socket_Error (Socket_Errno); end if; -- cgit v1.2.1