[PATCH] Use socklen_t for ai_addrlen on all platforms

Andreas Franke via Sbcl-devel <[email protected]> Fri, 27 Feb 2026 01:24:23 +0000
Newsgroups gmane.lisp.steel-bank.devel
Message-ID <trinity-e7f2885a-08ed-43df-9102-ec43b2c574cb-1772155463652@trinity-msg-rest-gmx-gmx-live-8d9bc96fb-8kcmf>
Tested on linux x86-64:
While the types are actually different, sb-grovel's mk-val does 
  (declare (ignore h-type))
so the C type string is purely documentary -- no functional change.
The groveler measures the real C struct and always gets 4 bytes for ai_addrlen.
(explanation based on Claude)

Other platforms haven't been tested.

_______________________________________________
Sbcl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-devel
0001-Use-socklen_t-for-ai_addrlen-on-all-platforms.patch (text/x-patch, 1.7 KB)
From a67e31e8ea7f272c3390e46fe8eb79dd6fad229a Mon Sep 17 00:00:00 2001
From: Andreas Franke <[email protected]>
Date: Thu, 26 Feb 2026 21:05:36 +0000
Subject: [PATCH] Use socklen_t for ai_addrlen on all platforms

POSIX defines ai_addrlen as socklen_t. The Darwin branch already had
this right; use it everywhere and drop the stale FIXME.
---
 contrib/sb-bsd-sockets/constants-addrinfo.lisp | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/contrib/sb-bsd-sockets/constants-addrinfo.lisp b/contrib/sb-bsd-sockets/constants-addrinfo.lisp
index a78175387..5debc3dbd 100644
--- a/contrib/sb-bsd-sockets/constants-addrinfo.lisp
+++ b/contrib/sb-bsd-sockets/constants-addrinfo.lisp
@@ -8,14 +8,7 @@
                        (integer family "int" "ai_family")
                        (integer socktype "int" "ai_socktype")
                        (integer protocol "int" "ai_protocol")
-                       ;; CLH 20070306 FIXME: ai_addrlen should really
-                       ;; be a socklen_t, but I'm not sure if this the
-                       ;; case on other platforms. I'm setting this to
-                       ;; socklen_t on darwin and hoping that other
-                       ;; platform maintainers will do the right thing
-                       ;; here.
-                       #+darwin (integer addrlen "socklen_t" "ai_addrlen")
-                       #-darwin (integer addrlen "size_t" "ai_addrlen")
+                       (integer addrlen "socklen_t" "ai_addrlen")
                        ;; This can be a void pointer since it has to
                        ;; be cast to the respectively appropriate
                        ;; address structure anyway.
-- 
2.43.0