From 01f97fcfeff34fea413da776b8c318a365439d90 Mon Sep 17 00:00:00 2001
From: cshapiro <cshapiro>
Date: Fri, 21 Dec 2007 08:46:48 +0000
Subject: [PATCH] The uname exported by the FreeBSD libc expects an older and
 shorter struct than the utsname struct in sys/utsname.h and the alien struct
 definition in Lisp.  Instead of calling the exported uname, call the
 underlying __xuname that knows about with the post FreeBSD 4 struct.

---
 code/unix.lisp | 47 +++++++++++++++++------------------------------
 1 file changed, 17 insertions(+), 30 deletions(-)

diff --git a/code/unix.lisp b/code/unix.lisp
index 42a8225a5..d3c1aa4e2 100644
--- a/code/unix.lisp
+++ b/code/unix.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/unix.lisp,v 1.116 2007/11/09 19:24:36 rtoy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/unix.lisp,v 1.117 2007/12/21 08:46:48 cshapiro Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -3258,39 +3258,26 @@
 	 :dir (string (cast (slot result 'pw-dir) c-call:c-string))
 	 :shell (string (cast (slot result 'pw-shell) c-call:c-string)))))))
 
-;; From sys/utsname.h
-#+(or solaris bsd)
-(eval-when (:compile-toplevel :load-toplevel :execute)
-  (defconstant +sys-namelen+
-    #+solaris 257
-    #+bsd 256))
-
-#+(or solaris bsd)
-(progn
 (def-alien-type nil
-    (struct utsname
-	    (sysname (array char #.+sys-namelen+))
-	    (nodename (array char #.+sys-namelen+))
-	    (release (array char #.+sys-namelen+))
-	    (version (array char #.+sys-namelen+))
-	    (machine (array char #.+sys-namelen+))))
-
+  (struct utsname
+    (sysname (array char #+svr4 257 #+bsd 256))
+    (nodename (array char #+svr4 257 #+bsd 256))
+    (release (array char #+svr4 257 #+bsd 256))
+    (version (array char #+svr4 257 #+bsd 256))
+    (machine (array char #+svr4 257 #+bsd 256))))
 
 (defun unix-uname ()
   (with-alien ((names (struct utsname)))
-    (let ((result
-	   (alien-funcall
-	    (extern-alien "uname"
-			  (function int
-				    (* (struct utsname))))
-	    (addr names))))
-      (when (>= result 0)
-	(values (cast (slot names 'sysname) c-string)
-		(cast (slot names 'nodename) c-string)
-		(cast (slot names 'release) c-string)
-		(cast (slot names 'version) c-string)
-		(cast (slot names 'machine) c-string))))))
-)
+    (syscall* (#-freebsd "uname"
+	       #+freebsd "__xuname" #+freebsd int
+	       (* (struct utsname)))
+	      (values (cast (slot names 'sysname) c-string)
+		      (cast (slot names 'nodename) c-string)
+		      (cast (slot names 'release) c-string)
+		      (cast (slot names 'version) c-string)
+		      (cast (slot names 'machine) c-string))
+	      #+freebsd 256
+	      (addr names))))
 
 #+(and solaris svr4)
 (progn
-- 
GitLab