[COMMITTED,31/31] ada: add BACKLOG_MAX OS constant

Message ID 20250911091904.1505690-31-poulhies@adacore.com
State Committed
Commit 165b029d4dfaa18de907d8dc8a4e56f82f06b697
Headers
Series [COMMITTED,01/31] ada: Disable new warning for composite equality ops that can raise Program_Error |

Commit Message

Marc Poulhiès Sept. 11, 2025, 9:19 a.m. UTC
  BACKLOG_MAX represents the number of outstanding connections in the
socket's listen queue.

gcc/ada/ChangeLog:

	* libgnat/g-socket.adb (Listen_Socket): Change default value.
	* libgnat/g-socket.ads (Listen_Socket): Likewise.
	* s-oscons-tmplt.c (BACKLOG_MAX): New.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/libgnat/g-socket.adb | 2 +-
 gcc/ada/libgnat/g-socket.ads | 2 +-
 gcc/ada/s-oscons-tmplt.c     | 3 +++
 3 files changed, 5 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gcc/ada/libgnat/g-socket.adb b/gcc/ada/libgnat/g-socket.adb
index 0fed79177544..303640f7fcca 100644
--- a/gcc/ada/libgnat/g-socket.adb
+++ b/gcc/ada/libgnat/g-socket.adb
@@ -1958,7 +1958,7 @@  package body GNAT.Sockets is
 
    procedure Listen_Socket
      (Socket : Socket_Type;
-      Length : Natural := 15)
+      Length : Natural := SOSC.BACKLOG_MAX)
    is
       Res : constant C.int := C_Listen (C.int (Socket), C.int (Length));
    begin
diff --git a/gcc/ada/libgnat/g-socket.ads b/gcc/ada/libgnat/g-socket.ads
index 1fe8a74ef11e..7c6534cd71c9 100644
--- a/gcc/ada/libgnat/g-socket.ads
+++ b/gcc/ada/libgnat/g-socket.ads
@@ -1219,7 +1219,7 @@  package GNAT.Sockets is
 
    procedure Listen_Socket
      (Socket : Socket_Type;
-      Length : Natural := 15);
+      Length : Natural := SOSC.BACKLOG_MAX);
    --  To accept connections, a socket is first created with Create_Socket,
    --  a willingness to accept incoming connections and a queue Length for
    --  incoming connections are specified. Raise Socket_Error on error.
diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c
index 7a5e987cefc4..4f9ff2aac867 100644
--- a/gcc/ada/s-oscons-tmplt.c
+++ b/gcc/ada/s-oscons-tmplt.c
@@ -1791,6 +1791,9 @@  struct sockaddr_un {
 #define SIZEOF_sockaddr_un (sizeof (struct sockaddr_un))
 CND(SIZEOF_sockaddr_un, "struct sockaddr_un")
 
+#define BACKLOG_MAX 15
+CND(BACKLOG_MAX, "number of outstanding connections in the socket's listen queue")
+
 #define SIZEOF_fd_set (sizeof (fd_set))
 CND(SIZEOF_fd_set, "fd_set")
 CND(FD_SETSIZE, "Max fd value")