master: Restore building sb-posix on musl

stassats via Sbcl-commits <[email protected]> Wed, 20 May 2026 15:37:35 +0000
Newsgroups gmane.lisp.steel-bank.cvs
Message-ID <[email protected]>
The branch "master" has been updated in SBCL:
       via  f825ab5db65fd7d68bbd8c39e37a8725409cafce (commit)
      from  5c1cd2227f09d9355c5ad5873148cf69ee6df3e1 (commit)

- Log -----------------------------------------------------------------
commit f825ab5db65fd7d68bbd8c39e37a8725409cafce
Author: Stas Boukarev <[email protected]>
Date:   Wed May 20 18:36:31 2026 +0300

    Restore building sb-posix on musl
    
    Which gives different names to termios slots
    
    Fixes lp#2153432
---
 contrib/sb-grovel/def-to-lisp.lisp | 52 ++++++++++++++++++++++++--------------
 contrib/sb-posix/constants.lisp    |  8 ++++--
 2 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/contrib/sb-grovel/def-to-lisp.lisp b/contrib/sb-grovel/def-to-lisp.lisp
index afd55ac66..82f8481df 100644
--- a/contrib/sb-grovel/def-to-lisp.lisp
+++ b/contrib/sb-grovel/def-to-lisp.lisp
@@ -80,25 +80,39 @@ code:
   (destructuring-bind (cname &rest elements) cstruct
     (printf "(sb-grovel::define-c-struct ~A %ld" lispname
             (word-cast (format nil "sizeof(~A)" cname)))
-    (dolist (e elements)
-      (destructuring-bind (lisp-type lisp-el-name c-type c-el-name &key distrust-length) e
-        (printf " (~A ~A \"~A\"" lisp-el-name lisp-type c-type)
-        ;; offset
-        (as-c "{" cname "t;")
-        (printf "  %lu"
-                (format nil "((unsigned long~A)&(t.~A)) - ((unsigned long~A)&(t))"
-                        #+(and win32 64-bit) " long" #-(and win32 64-bit) ""
-                        c-el-name
-                        #+(and win32 64-bit) " long" #-(and win32 64-bit) ""))
-        (as-c "}")
-        ;; length
-        (if distrust-length
-            (printf "  0)")
-            (progn
-              (as-c "{" cname "t;")
-              (printf "  %ld)"
-                      (word-cast (format nil "sizeof(t.~A)" c-el-name)))
-              (as-c "}")))))
+    (when elements
+      (as-c "{" cname "t;")
+      (dolist (e elements)
+        (destructuring-bind (lisp-type lisp-el-name c-type c-el-name &key distrust-length) e
+          (printf " (~A ~A \"~A\"" lisp-el-name lisp-type c-type)
+          ;; offset
+          (flet ((ifdef (fun c-el-name)
+                   (cond ((typep c-el-name '(cons (eql :if)))
+                          (destructuring-bind (cond then else) (cdr c-el-name)
+                            (as-c "#if" cond)
+                            (funcall fun then)
+                            (as-c "#else")
+                            (funcall fun else)
+                            (as-c "#endif")))
+                         (t
+                          (funcall fun c-el-name)))))
+            (ifdef (lambda (c-el-name)
+                     (printf "  %lu"
+                             (format nil "((unsigned long~A)&(t.~A)) - ((unsigned long~A)&(t))"
+                                     #+(and win32 64-bit) " long" #-(and win32 64-bit) ""
+                                     c-el-name
+                                     #+(and win32 64-bit) " long" #-(and win32 64-bit) "")))
+                   c-el-name)
+
+            ;; length
+            (if distrust-length
+                (printf "  0)")
+                (ifdef (lambda (c-el-name)
+                         (printf "  %ld)"
+
+                                 (word-cast (format nil "sizeof(t.~A)" c-el-name))))
+                       c-el-name)))))
+      (as-c "}"))
     (printf ")")))
 
 (defun print-c-source (stream headers definitions package-name)
diff --git a/contrib/sb-posix/constants.lisp b/contrib/sb-posix/constants.lisp
index e96bdfe9c..a78f265bf 100644
--- a/contrib/sb-posix/constants.lisp
+++ b/contrib/sb-posix/constants.lisp
@@ -435,9 +435,13 @@
               (tcflag-t lflag "tcflag_t" "c_lflag")
               ((array cc-t) cc "cc_t" "c_cc")
               #-sunos
-              (speed-t ispeed "speed_t" "c_ispeed")
+              (speed-t ispeed "speed_t" (:if "defined(__linux__) && !defined(__GLIBC__)"
+                                             "__c_ispeed" ;; musl
+                                             "c_ispeed"))
               #-sunos
-              (speed-t ospeed "speed_t" "c_ospeed")))
+              (speed-t ospeed "speed_t" (:if "defined(__linux__) && !defined(__GLIBC__)"
+                                             "__c_ospeed" ;; musl
+                                             "c_ospeed"))))
 
  ;; utime(), utimes()
  #-win32

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL