summaryrefslogtreecommitdiff
path: root/gcc/ada/g-socket.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-29 10:49:15 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-29 10:49:15 +0000
commita3e6563b2930eda54247c93617c90def3659c129 (patch)
tree0b6546d43b2e46559dc89368694673e09f48f367 /gcc/ada/g-socket.adb
parent86cf57b9cdb2979f0f96645567a9dca8ccb34bf7 (diff)
downloadgcc-a3e6563b2930eda54247c93617c90def3659c129.tar.gz
2009-04-29 Gary Dismukes <dismukes@adacore.com>
* 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 <duff@adacore.com> * g-expect.adb (Expect_Internal): Fix check for overfull buffer. * g-expect.ads: Minor comment fixes. 2009-04-29 Ed Schonberg <schonberg@adacore.com> * 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 <lee@adacore.com> * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146949 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-socket.adb')
-rw-r--r--gcc/ada/g-socket.adb92
1 files changed, 58 insertions, 34 deletions
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;