From 0a90412010e4bd535df8c35d4bce95f321ebb6be Mon Sep 17 00:00:00 2001 From: Dmitriy Anisimkov Date: Mon, 8 Jul 2019 08:12:51 +0000 Subject: [PATCH] [Ada] GNAT.Sockets: remove default level in Get/Set_Socket_Option 2019-07-08 Dmitriy Anisimkov gcc/ada/ * libgnat/g-socket.ads, libgnat/g-socket.adb: Improve documentation. (Get_Socket_Option, Set_Socket_Option): Remove default value for the Level formal. From-SVN: r273198 --- gcc/ada/ChangeLog | 7 ++ gcc/ada/libgnat/g-socket.adb | 4 +- gcc/ada/libgnat/g-socket.ads | 133 ++++++++++++++++++++++++++++------- 3 files changed, 115 insertions(+), 29 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 687c4abefae..b1b2e48ab54 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2019-07-08 Dmitriy Anisimkov + + * libgnat/g-socket.ads, libgnat/g-socket.adb: Improve + documentation. + (Get_Socket_Option, Set_Socket_Option): Remove default value for + the Level formal. + 2019-07-08 Ed Schonberg * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): For an diff --git a/gcc/ada/libgnat/g-socket.adb b/gcc/ada/libgnat/g-socket.adb index ef6071bf882..2c9b8c76afd 100644 --- a/gcc/ada/libgnat/g-socket.adb +++ b/gcc/ada/libgnat/g-socket.adb @@ -1369,7 +1369,7 @@ package body GNAT.Sockets is function Get_Socket_Option (Socket : Socket_Type; - Level : Level_Type := Socket_Level; + Level : Level_Type; Name : Option_Name; Optname : Interfaces.C.int := -1) return Option_Type is @@ -2539,7 +2539,7 @@ package body GNAT.Sockets is procedure Set_Socket_Option (Socket : Socket_Type; - Level : Level_Type := Socket_Level; + Level : Level_Type; Option : Option_Type) is use type C.unsigned; diff --git a/gcc/ada/libgnat/g-socket.ads b/gcc/ada/libgnat/g-socket.ads index 30244338e61..6db3c5422a9 100644 --- a/gcc/ada/libgnat/g-socket.ads +++ b/gcc/ada/libgnat/g-socket.ads @@ -775,34 +775,113 @@ package GNAT.Sockets is IP_Protocol_For_TCP_Level); -- There are several options available to manipulate sockets. Each option - -- has a name and several values available. Most of the time, the value is - -- a boolean to enable or disable this option. + -- has a name and several values available. Most of the time, the value + -- is a boolean to enable or disable this option. Each socket option is + -- provided with an appropriate C name taken from the sockets API comments. + -- The C name can be used to find a detailed description in the OS-specific + -- documentation. The options are grouped by main Level_Type value, which + -- can be used together with this option in calls to the Set_Socket_Option + -- and Get_Socket_Option routines. Note that some options can be used with + -- more than one level. type Option_Name is (Generic_Option, - Keep_Alive, -- Enable sending of keep-alive messages - Reuse_Address, -- Allow bind to reuse local address - Broadcast, -- Enable datagram sockets to recv/send broadcasts - Send_Buffer, -- Set/get the maximum socket send buffer in bytes - Receive_Buffer, -- Set/get the maximum socket recv buffer in bytes - Linger, -- Shutdown wait for msg to be sent or timeout occur - Error, -- Get and clear the pending socket error - No_Delay, -- Do not delay send to coalesce data (TCP_NODELAY) - Add_Membership_V4, -- Join a multicast group - Add_Membership_V6, -- Idem for IPv6 socket - Drop_Membership_V4, -- Leave a multicast group - Drop_Membership_V6, -- Idem for IPv6 socket - Multicast_If_V4, -- Set default out interface for multicast packets - Multicast_If_V6, -- Idem for IPv6 socket - Multicast_Loop_V4, -- Sent multicast packets are looped to local socket - Multicast_Loop_V6, -- Idem for IPv6 socket - Multicast_TTL, -- Set the time-to-live of sent multicast packets - Multicast_Hops, -- Set the multicast hop limit for the IPv6 socket - Receive_Packet_Info, -- Receive low level packet info as ancillary data - Send_Timeout, -- Set timeout value for output - Receive_Timeout, -- Set timeout value for input - IPv6_Only, -- Restricted to IPv6 communications only - Busy_Polling); -- Set busy polling mode + -- Can be used to set/get any socket option via an OS-specific option + -- code with an integer value. + + ------------------ + -- Socket_Level -- + ------------------ + + Keep_Alive, -- SO_KEEPALIVE + -- Enable sending of keep-alive messages on connection-oriented sockets + + Reuse_Address, -- SO_REUSEADDR + -- Enable binding to an address and port already in use + + Broadcast, -- SO_BROADCAST + -- Enable sending broadcast datagrams on the socket + + Send_Buffer, -- SO_SNDBUF + -- Set/get the maximum socket send buffer in bytes + + Receive_Buffer, -- SO_RCVBUF + -- Set/get the maximum socket receive buffer in bytes + + Linger, -- SO_LINGER + -- When enabled, a Close_Socket or Shutdown_Socket will wait until all + -- queued messages for the socket have been successfully sent or the + -- linger timeout has been reached. + + Error, -- SO_ERROR + -- Get and clear the pending socket error integer code + + Send_Timeout, -- SO_SNDTIMEO + -- Specify sending timeout until reporting an error + + Receive_Timeout, -- SO_RCVTIMEO + -- Specify receiving timeout until reporting an error + + Busy_Polling, -- SO_BUSY_POLL + -- Sets the approximate time in microseconds to busy poll on a blocking + -- receive when there is no data. + + ------------------------------- + -- IP_Protocol_For_TCP_Level -- + ------------------------------- + + No_Delay, -- TCP_NODELAY + -- Disable the Nagle algorithm. This means that output buffer content + -- is always sent as soon as possible, even if there is only a small + -- amount of data. + + ------------------------------ + -- IP_Protocol_For_IP_Level -- + ------------------------------ + + Add_Membership_V4, -- IP_ADD_MEMBERSHIP + -- Join a multicast group + + Drop_Membership_V4, -- IP_DROP_MEMBERSHIP + -- Leave a multicast group + + Multicast_If_V4, -- IP_MULTICAST_IF + -- Set/Get outgoing interface for sending multicast packets + + Multicast_Loop_V4, -- IP_MULTICAST_LOOP + -- This boolean option determines whether sent multicast packets should + -- be looped back to the local sockets. + + Multicast_TTL, -- IP_MULTICAST_TTL + -- Set/Get the time-to-live of sent multicast packets + + Receive_Packet_Info, -- IP_PKTINFO + -- Receive low-level packet info as ancillary data + + -------------------------------- + -- IP_Protocol_For_IPv6_Level -- + -------------------------------- + + Add_Membership_V6, -- IPV6_ADD_MEMBERSHIP + -- Join IPv6 multicast group + + Drop_Membership_V6, -- IPV6_DROP_MEMBERSHIP + -- Leave IPv6 multicast group + + Multicast_If_V6, -- IPV6_MULTICAST_IF + -- Set/Get outgoing interface index for sending multicast packets + + Multicast_Loop_V6, -- IPV6_MULTICAST_LOOP + -- This boolean option determines whether sent multicast IPv6 packets + -- should be looped back to the local sockets. + + IPv6_Only, -- IPV6_V6ONLY + -- Restricted to IPv6 communications only + + Multicast_Hops -- IPV6_MULTICAST_HOPS + -- Set the multicast hop limit for the IPv6 socket + ); + subtype Specific_Option_Name is Option_Name range Keep_Alive .. Option_Name'Last; @@ -1084,7 +1163,7 @@ package GNAT.Sockets is function Get_Socket_Option (Socket : Socket_Type; - Level : Level_Type := Socket_Level; + Level : Level_Type; Name : Option_Name; Optname : Interfaces.C.int := -1) return Option_Type; -- Get the options associated with a socket. Raises Socket_Error on error. @@ -1199,7 +1278,7 @@ package GNAT.Sockets is procedure Set_Socket_Option (Socket : Socket_Type; - Level : Level_Type := Socket_Level; + Level : Level_Type; Option : Option_Type); -- Manipulate socket options. Raises Socket_Error on error -- 2.30.2