From 13323ed7c4e340dc1bfdddce502449212da6ec5a Mon Sep 17 00:00:00 2001
From: gerd <gerd>
Date: Fri, 6 Jun 2003 18:41:37 +0000
Subject: [PATCH] 	* src/code/unix.lisp (unix-mmap) [#+freebsd]: Use 2
 unsigned-longs 	for the 64-bit offset.

---
 code/unix.lisp | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/code/unix.lisp b/code/unix.lisp
index d759d5755..e54fd22e1 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.86 2003/06/06 17:52:45 toy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/unix.lisp,v 1.87 2003/06/06 18:41:37 gerd Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -859,6 +859,7 @@
 ;; The return value from mmap that means mmap failed.
 (defconstant map_failed -1)
 
+#-freebsd
 (defun unix-mmap (addr length prot flags fd offset)
   (declare (type (or null system-area-pointer) addr)
 	   (type (unsigned-byte 32) length)
@@ -877,6 +878,28 @@
 	(values nil unix-errno)
 	(sys:int-sap result))))
 
+#+freebsd
+(defun unix-mmap (addr length prot flags fd offset)
+  (declare (type (or null system-area-pointer) addr)
+	   (type (unsigned-byte 32) length)
+           (type (integer 1 7) prot)
+	   (type (unsigned-byte 32) flags)
+	   (type unix-fd fd)
+	   (type (signed-byte 32) offset))
+  ;; Can't use syscall, because the address that is returned could be
+  ;; "negative".  Hence we explicitly check for mmap returning
+  ;; MAP_FAILED.
+  (let ((result
+	 (alien-funcall
+	  (extern-alien "mmap"
+			(function int system-area-pointer
+				  size-t int int int
+				  unsigned-long unsigned-long))
+	  (or addr +null+) length prot flags (or fd -1) offset 0)))
+    (if (= result map_failed)
+	(values nil unix-errno)
+	(sys:int-sap result))))
+
 (defun unix-munmap (addr length)
   (declare (type system-area-pointer addr)
 	   (type (unsigned-byte 32) length))
-- 
GitLab