aboutsummaryrefslogtreecommitdiff
path: root/lang/sbcl
diff options
context:
space:
mode:
authorMartin Wilke <miwi@FreeBSD.org>2006-12-02 00:20:41 +0000
committerMartin Wilke <miwi@FreeBSD.org>2006-12-02 00:20:41 +0000
commitfce28c16a5f4422ccb4816c2719fc0f7f3d928f8 (patch)
tree152d613624902f36d00a3a0244cb906ffa4e57e9 /lang/sbcl
parent4debeb3ac0bdd07edbd9214ef78cbcc117fd3c92 (diff)
downloadports-fce28c16a5f4422ccb4816c2719fc0f7f3d928f8.tar.gz
ports-fce28c16a5f4422ccb4816c2719fc0f7f3d928f8.zip
Notes
Diffstat (limited to 'lang/sbcl')
-rw-r--r--lang/sbcl/Makefile72
-rw-r--r--lang/sbcl/distinfo12
-rw-r--r--lang/sbcl/files/customize-target-features.lisp7
-rw-r--r--lang/sbcl/files/patch-backtrace117
-rw-r--r--lang/sbcl/files/patch-floating-point96
-rw-r--r--lang/sbcl/files/patch-freebsd-amd64559
-rw-r--r--lang/sbcl/files/patch-src_runtime_thread.c13
-rw-r--r--lang/sbcl/pkg-plist7
8 files changed, 639 insertions, 244 deletions
diff --git a/lang/sbcl/Makefile b/lang/sbcl/Makefile
index de512871ae40..b03a250667b5 100644
--- a/lang/sbcl/Makefile
+++ b/lang/sbcl/Makefile
@@ -6,38 +6,25 @@
#
PORTNAME= sbcl
-PORTVERSION= 0.9.18
+PORTVERSION= 1.0
CATEGORIES= lang lisp
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= sbcl
DISTFILES= ${DISTNAME}-source${EXTRACT_SUFX}
.if !defined(NOPORTDOCS)
-DISTFILES+= ${DISTNAME}-html${EXTRACT_SUFX}
+DISTFILES+= ${DISTNAME}-documentation-html${EXTRACT_SUFX}
.endif
MAINTAINER= sa2c@sa2c.net
COMMENT= A Common Lisp development system derived from the CMU CL system
-.undef BOOT_VERSION
-# If you have a previous version of SBCL installed, you can use it
-# instead of CMUCL to build the port, then deinstall it before
-# installing the new version.
-.if defined(WITH_SBCL)
-LISP_CMD= ""
-.elif defined(WITH_CMUCL)
-BUILD_DEPENDS= lisp:${PORTSDIR}/lang/cmucl
-LISP_CMD= "lisp -noinit -batch"
-.else
-BOOT_VERSION= 0.9.16
-.endif
-
USE_BZIP2= yes
USE_GMAKE= yes
EXTRACT_AFTER_ARGS= | ${TAR} -xf - --exclude */CVS/*
# Can currently only bootstrap using cmucl, which is i386-only
-ONLY_FOR_ARCHS= i386
+ONLY_FOR_ARCHS= i386 amd64
MAN1= sbcl.1
INFO= asdf sbcl
@@ -45,27 +32,53 @@ INFODIR= ${PREFIX}/${INFO_PATH}
.include <bsd.port.pre.mk>
-.if defined(BOOT_VERSION)
-BOOT_ARCH= ${ARCH:S/i386/x86/}
+# If you have a previous version of SBCL installed, you can use it
+# instead of the binary distribution.
+.if defined(WITH_SBCL)
+LISP_CMD= ""
+.else
+BOOT_VERSION= 0.9.16
+BOOT_ARCH= x86
BOOT_OS= ${OPSYS:L}
BOOT_DISTNAME= ${PORTNAME}-${BOOT_VERSION}-${BOOT_ARCH}-${BOOT_OS}
DISTFILES+= ${BOOT_DISTNAME}-binary${EXTRACT_SUFX}
LISP_CMD= "${WRKDIR}/${BOOT_DISTNAME}/src/runtime/sbcl --core ${WRKDIR}/${BOOT_DISTNAME}/output/sbcl.core --disable-debugger --userinit /dev/null --sysinit /dev/null"
.if ${OSVERSION} >= 500000
+.if ${ARCH} == i386
BUILD_DEPENDS+= ${LOCALBASE}/lib/compat/libc.so.4:${PORTSDIR}/misc/compat4x
+.elif ${ARCH} == amd64
+BUILD_DEPENDS+= ${LOCALBASE}/lib32/compat/libc.so.4:${PORTSDIR}/misc/compat4x
+.endif
.endif
.endif
+.if defined(WITH_THREADS) && ${OSVERSION} < 500000
+BROKEN= Does not compile on 4.x with threading
+.endif
+
+.if defined(WITH_THREADS) && ${ARCH} == amd64
+BROKEN= Does not compile on AMD64 with threading
+.endif
+
+.if ${ARCH} == i386
+PLIST_SUB+= I386_ONLY=""
+.else
+PLIST_SUB+= I386_ONLY="@comment "
+.endif
+
post-patch:
@${REINPLACE_CMD} -E -e \
- 's|CFLAGS = .*|CFLAGS = ${CFLAGS} -DSBCL_HOME=\\"${PREFIX}/lib/sbcl/\\"|' \
+ 's|CFLAGS = .*|CFLAGS = ${CFLAGS} -g -DSBCL_HOME=\\"${PREFIX}/lib/sbcl/\\"|' \
${WRKSRC}/src/runtime/GNUmakefile
@${FIND} ${WRKSRC} -name '*.orig' -o -name '*.bak' | ${XARGS} ${RM}
+.if defined(WITH_THREADS)
+ @${CP} ${FILESDIR}/customize-target-features.lisp ${WRKSRC}
+.endif
do-build:
- (cd ${WRKSRC} && ${SETENV} INSTALL_ROOT=${PREFIX} \
+ @(cd ${WRKSRC} && ${SETENV} INSTALL_ROOT=${PREFIX} \
${SH} make.sh ${LISP_CMD})
- (cd ${WRKSRC}/doc/manual && \
+ @(cd ${WRKSRC}/doc/manual && \
${GMAKE} MAKEINFO='makeinfo --no-split' info)
do-install:
@@ -79,4 +92,21 @@ do-install:
test: build
(cd ${WRKSRC}/tests && ${SH} run-tests.sh)
+pre-everything::
+.if ${ARCH} == amd64
+ @${ECHO_MSG} "====>"
+ @${ECHO_MSG} "====> WARNING: AMD64 support is experimental."
+ @${ECHO_MSG} "====>"
+.else
+.if !defined(WITH_THREADS) && ${OSVERSION} >= 600000
+ @${ECHO_MSG} "====>"
+ @${ECHO_MSG} "====> To enable experimental threading support, define WITH_THREADS."
+ @${ECHO_MSG} "====>"
+.elif defined(WITH_THREADS) && ${OSVERSION} < 600000
+ @${ECHO_MSG} "====>"
+ @${ECHO_MSG} "====> WARNING: Current threading support is very unstable on FreeBSD 5.x."
+ @${ECHO_MSG} "====>"
+.endif
+.endif
+
.include <bsd.port.post.mk>
diff --git a/lang/sbcl/distinfo b/lang/sbcl/distinfo
index 97b60609c1e6..8aa20a3f6572 100644
--- a/lang/sbcl/distinfo
+++ b/lang/sbcl/distinfo
@@ -1,9 +1,9 @@
-MD5 (sbcl-0.9.18-source.tar.bz2) = a00122024746ecb81bfff1a328bb2336
-SHA256 (sbcl-0.9.18-source.tar.bz2) = 860ad56be395f1053d9f24c592a9e40c196d504ee9d59a7bdd4379eac03ee011
-SIZE (sbcl-0.9.18-source.tar.bz2) = 2783861
-MD5 (sbcl-0.9.18-html.tar.bz2) = a082aac7c96c2456505797dc4f4e99cd
-SHA256 (sbcl-0.9.18-html.tar.bz2) = ded0e68565f2f39450eb49c8d38c0915713aa87945ca74225408077c9a0da736
-SIZE (sbcl-0.9.18-html.tar.bz2) = 124987
+MD5 (sbcl-1.0-source.tar.bz2) = 52e07dcc8eef0dc45ecdc35e46d4999f
+SHA256 (sbcl-1.0-source.tar.bz2) = 5d33383963ef8ae3ff1be7871aeb0df196923ab5b78513aa666214b52c2f5cfb
+SIZE (sbcl-1.0-source.tar.bz2) = 2891666
+MD5 (sbcl-1.0-documentation-html.tar.bz2) = 38fcc1059516be98c76ee7b53241b386
+SHA256 (sbcl-1.0-documentation-html.tar.bz2) = 3cd3f61c129a442a78d70f50c32df94d3b29f385771ba52510c6a783f13fc167
+SIZE (sbcl-1.0-documentation-html.tar.bz2) = 126295
MD5 (sbcl-0.9.16-x86-freebsd-binary.tar.bz2) = 339df1c8d5aff512c1fa4362954443a5
SHA256 (sbcl-0.9.16-x86-freebsd-binary.tar.bz2) = 61cd97c58615370606c9f01ca2049d71b9a05a3c84f2b299fe16ddba38e7e19c
SIZE (sbcl-0.9.16-x86-freebsd-binary.tar.bz2) = 7454913
diff --git a/lang/sbcl/files/customize-target-features.lisp b/lang/sbcl/files/customize-target-features.lisp
new file mode 100644
index 000000000000..299995966fca
--- /dev/null
+++ b/lang/sbcl/files/customize-target-features.lisp
@@ -0,0 +1,7 @@
+(lambda (features)
+ (flet ((enable (x)
+ (pushnew x features))
+ (disable (x)
+ (setf features (remove x features))))
+ (enable :sb-thread)
+ features))
diff --git a/lang/sbcl/files/patch-backtrace b/lang/sbcl/files/patch-backtrace
deleted file mode 100644
index 9a3dfee4da85..000000000000
--- a/lang/sbcl/files/patch-backtrace
+++ /dev/null
@@ -1,117 +0,0 @@
-Index: src/code/debug-int.lisp
-===================================================================
-RCS file: /cvsroot/sbcl/sbcl/src/code/debug-int.lisp,v
-retrieving revision 1.101
-diff -u -r1.101 debug-int.lisp
---- src/code/debug-int.lisp 28 Sep 2005 13:42:24 -0000 1.101
-+++ src/code/debug-int.lisp 27 Feb 2006 10:52:45 -0000
-@@ -559,6 +559,9 @@
-
- (defconstant sb!vm::nargs-offset #.sb!vm::ecx-offset)
-
-+(sb!alien:define-alien-variable "user_space_start" sb!alien:unsigned-long)
-+(sb!alien:define-alien-variable "user_space_end" sb!alien:unsigned-long)
-+
- ;;; Check for a valid return address - it could be any valid C/Lisp
- ;;; address.
- ;;;
-@@ -567,11 +570,7 @@
- (defun ra-pointer-valid-p (ra)
- (declare (type system-area-pointer ra))
- (and
-- ;; not the first page (which is unmapped)
-- ;;
-- ;; FIXME: Where is this documented? Is it really true of every CPU
-- ;; architecture? Is it even necessarily true in current SBCL?
-- (>= (sap-int ra) 4096)
-+ (>= user-space-end (sap-int ra) user-space-start)
- ;; not a Lisp stack pointer
- (not (control-stack-pointer-valid-p ra))))
-
-Index: src/runtime/bsd-os.c
-===================================================================
-RCS file: /cvsroot/sbcl/sbcl/src/runtime/bsd-os.c,v
-retrieving revision 1.36
-diff -u -r1.36 bsd-os.c
---- src/runtime/bsd-os.c 21 Feb 2006 23:40:36 -0000 1.36
-+++ src/runtime/bsd-os.c 27 Feb 2006 10:52:45 -0000
-@@ -53,6 +53,8 @@
-
- #ifdef __FreeBSD__
- #include <sys/sysctl.h>
-+#include <link.h>
-+#include <dlfcn.h>
- #include <osreldate.h>
-
- static void freebsd_init();
-@@ -310,6 +312,25 @@
- fast_bzero_pointer = fast_bzero_detect;
- }
- #endif /* LISP_FEATURE_X86 */
-+ /* extract lowermost address from linkmap */
-+ {
-+ Link_map *map;
-+
-+ if (dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map) == 0
-+ && map != NULL && map->l_addr != NULL)
-+ user_space_start = (unsigned long)map->l_addr;
-+ }
-+
-+ /* extract uppermost address from "kern.usrstack" mib */
-+ {
-+ size_t len;
-+ unsigned long tmp;
-+
-+ len = sizeof(tmp);
-+ if (sysctlbyname("kern.usrstack", &tmp, &len, NULL, 0) == 0
-+ && tmp > user_space_start)
-+ user_space_end = tmp;
-+ }
- }
- #endif /* __FreeBSD__ */
-
-Index: src/runtime/globals.c
-===================================================================
-RCS file: /cvsroot/sbcl/sbcl/src/runtime/globals.c,v
-retrieving revision 1.19
-diff -u -r1.19 globals.c
---- src/runtime/globals.c 21 Feb 2006 22:59:33 -0000 1.19
-+++ src/runtime/globals.c 27 Feb 2006 10:52:45 -0000
-@@ -16,6 +16,7 @@
- #include <stdio.h>
- #include <sys/types.h>
- #include <unistd.h>
-+#include <limits.h>
-
- #include "sbcl.h"
- #include "runtime.h"
-@@ -54,6 +55,14 @@
- pthread_key_t specials=0;
- #endif
-
-+/* Valid user address space. */
-+
-+/* not the first page (which is unmapped)
-+ * good default for most architectures. */
-+unsigned long user_space_start = 4096;
-+
-+unsigned long user_space_end = ULONG_MAX;
-+
- void globals_init(void)
- {
- /* Space, stack, and free pointer vars are initialized by
-Index: src/runtime/globals.h
-===================================================================
-RCS file: /cvsroot/sbcl/sbcl/src/runtime/globals.h,v
-retrieving revision 1.26
-diff -u -r1.26 globals.h
---- src/runtime/globals.h 21 Feb 2006 22:59:33 -0000 1.26
-+++ src/runtime/globals.h 27 Feb 2006 10:52:46 -0000
-@@ -108,4 +108,7 @@
-
- #endif /* LANGUAGE_ASSEMBLY */
-
-+extern unsigned long user_space_start;
-+extern unsigned long user_space_end;
-+
- #endif /* _INCLUDED_GLOBALS_H_ */
diff --git a/lang/sbcl/files/patch-floating-point b/lang/sbcl/files/patch-floating-point
deleted file mode 100644
index 2202de372c41..000000000000
--- a/lang/sbcl/files/patch-floating-point
+++ /dev/null
@@ -1,96 +0,0 @@
-Index: src/code/float-trap.lisp
-===================================================================
-RCS file: /cvsroot/sbcl/sbcl/src/code/float-trap.lisp,v
-retrieving revision 1.19
-diff -u -r1.19 float-trap.lisp
---- src/code/float-trap.lisp 6 Oct 2005 19:43:00 -0000 1.19
-+++ src/code/float-trap.lisp 28 Jun 2006 10:34:15 -0000
-@@ -153,10 +153,28 @@
- `(not (zerop (logand ,(dpb (float-trap-mask traps) float-traps-byte 0)
- (floating-point-modes)))))
-
-+;;; SIGFPE code to floating-point error
-+#+freebsd
-+(defparameter *sigfpe-code-error-alist*
-+ (list (cons sb!unix::fpe-intovf 'floating-point-overflow)
-+ (cons sb!unix::fpe-intdiv 'division-by-zero)
-+ (cons sb!unix::fpe-fltdiv 'division-by-zero)
-+ (cons sb!unix::fpe-fltovf 'floating-point-overflow)
-+ (cons sb!unix::fpe-fltund 'floating-point-underflow)
-+ (cons sb!unix::fpe-fltres 'floating-point-inexact)
-+ (cons sb!unix::fpe-fltinv 'floating-point-invalid-operation)
-+ (cons sb!unix::fpe-fltsub 'floating-point-exception)))
-+
- ;;; Signal the appropriate condition when we get a floating-point error.
- (defun sigfpe-handler (signal info context)
-- (declare (ignore signal info))
-+ (declare (ignore signal #!-freebsd info))
-+ #!+freebsd
-+ (declare (type system-area-pointer info))
- (declare (type system-area-pointer context))
-+ #!+freebsd
-+ (let ((code (sb!unix::siginfo-code info)))
-+ (error (or (cdr (assoc code *sigfpe-code-error-alist*))
-+ 'floating-point-exception)))
- (let* ((modes (context-floating-point-modes
- (sb!alien:sap-alien context (* os-context-t))))
- (traps (logand (ldb float-exceptions-byte modes)
-Index: src/code/target-signal.lisp
-===================================================================
-RCS file: /cvsroot/sbcl/sbcl/src/code/target-signal.lisp,v
-retrieving revision 1.34
-diff -u -r1.34 target-signal.lisp
---- src/code/target-signal.lisp 10 Apr 2006 16:08:45 -0000 1.34
-+++ src/code/target-signal.lisp 28 Jun 2006 10:34:15 -0000
-@@ -163,6 +163,10 @@
-
- ;;;; etc.
-
-+;;; extract si_code from siginfo_t
-+(sb!alien:define-alien-routine ("siginfo_code" siginfo-code) sb!alien:int
-+ (info system-area-pointer))
-+
- ;;; CMU CL comment:
- ;;; Magically converted by the compiler into a break instruction.
- (defun receive-pending-interrupt ()
-Index: src/runtime/interrupt.c
-===================================================================
-RCS file: /cvsroot/sbcl/sbcl/src/runtime/interrupt.c,v
-retrieving revision 1.113
-diff -u -r1.113 interrupt.c
---- src/runtime/interrupt.c 7 Jun 2006 16:25:10 -0000 1.113
-+++ src/runtime/interrupt.c 28 Jun 2006 10:34:15 -0000
-@@ -1376,3 +1376,9 @@
- SHOW("returning from interrupt_init()");
- #endif
- }
-+
-+int
-+siginfo_code(siginfo_t *info)
-+{
-+ return info->si_code;
-+}
-Index: tools-for-build/grovel-headers.c
-===================================================================
-RCS file: /cvsroot/sbcl/sbcl/tools-for-build/grovel-headers.c,v
-retrieving revision 1.15
-diff -u -r1.15 grovel-headers.c
---- tools-for-build/grovel-headers.c 18 Jun 2006 23:47:58 -0000 1.15
-+++ tools-for-build/grovel-headers.c 28 Jun 2006 10:34:15 -0000
-@@ -338,6 +338,16 @@
- defsignal("sigxcpu", SIGXCPU);
- defsignal("sigxfsz", SIGXFSZ);
- #endif
-+#ifdef __FreeBSD__
-+ defconstant("fpe-intovf", FPE_INTOVF);
-+ defconstant("fpe-intdiv", FPE_INTDIV);
-+ defconstant("fpe-fltdiv", FPE_FLTDIV);
-+ defconstant("fpe-fltovf", FPE_FLTOVF);
-+ defconstant("fpe-fltund", FPE_FLTUND);
-+ defconstant("fpe-fltres", FPE_FLTRES);
-+ defconstant("fpe-fltinv", FPE_FLTINV);
-+ defconstant("fpe-fltsub", FPE_FLTSUB);
-+#endif
- #endif // _WIN32
- return 0;
- }
diff --git a/lang/sbcl/files/patch-freebsd-amd64 b/lang/sbcl/files/patch-freebsd-amd64
new file mode 100644
index 000000000000..29a626c18b07
--- /dev/null
+++ b/lang/sbcl/files/patch-freebsd-amd64
@@ -0,0 +1,559 @@
+--- make-config.sh Thu Nov 30 02:36:43 2006 +0000
++++ make-config.sh Thu Nov 30 11:42:35 2006 +0900
+@@ -102,6 +102,7 @@ case `uname -m` in
+ *86) guessed_sbcl_arch=x86 ;;
+ i86pc) guessed_sbcl_arch=x86 ;;
+ *x86_64) guessed_sbcl_arch=x86-64 ;;
++ amd64) guessed_sbcl_arch=x86-64 ;;
+ [Aa]lpha) guessed_sbcl_arch=alpha ;;
+ sparc*) guessed_sbcl_arch=sparc ;;
+ sun*) guessed_sbcl_arch=sparc ;;
+--- src/runtime/GNUmakefile Thu Nov 30 02:36:43 2006 +0000
++++ src/runtime/GNUmakefile Thu Nov 30 13:26:27 2006 +0900
+@@ -58,7 +58,7 @@ targets: $(TARGET) sbcl.nm
+ $(CC) ${LINKFLAGS} -o $@ $^ $(LIBS)
+
+ sbcl.nm: $(TARGET)
+- $(NM) $(TARGET) | $(GREP) -v " F \| U " > ,$@
++ $(NM) $(TARGET) | $(GREP) -v " [FUw] " > ,$@
+ mv -f ,$@ $@
+
+ sbcl.h: $(wildcard genesis/*.h)
+--- src/runtime/breakpoint.h Thu Nov 30 02:36:43 2006 +0000
++++ src/runtime/breakpoint.h Thu Nov 30 18:16:38 2006 +0900
+@@ -22,5 +22,7 @@ extern void handle_breakpoint(int signal
+ os_context_t *context);
+ extern void *handle_fun_end_breakpoint(int signal, siginfo_t *info,
+ os_context_t *context);
++extern void handle_single_step_trap (os_context_t *context, int kind,
++ int register_offset);
+
+ #endif
+--- src/runtime/bsd-os.c Thu Nov 30 02:36:43 2006 +0000
++++ src/runtime/bsd-os.c Thu Nov 30 18:38:30 2006 +0900
+@@ -41,6 +41,9 @@
+ #include <signal.h>
+ /* #include <sys/sysinfo.h> */
+ #include "validate.h"
++#if defined LISP_FEATURE_GENCGC
++#include "gencgc-internal.h"
++#endif
+
+ os_vm_size_t os_vm_page_size;
+
+@@ -55,7 +58,6 @@ static void netbsd_init();
+
+ #ifdef __FreeBSD__
+ #include <sys/sysctl.h>
+-#include <osreldate.h>
+
+ static void freebsd_init();
+ #endif /* __FreeBSD__ */
+@@ -71,23 +73,6 @@ os_init(char *argv[], char *envp[])
+ #ifdef __FreeBSD__
+ freebsd_init();
+ #endif /* __FreeBSD__ */
+-}
+-
+-int *os_context_pc_addr(os_context_t *context)
+-{
+-#if defined __FreeBSD__
+- return CONTEXT_ADDR_FROM_STEM(eip);
+-#elif defined __OpenBSD__
+- return CONTEXT_ADDR_FROM_STEM(pc);
+-#elif defined __NetBSD__
+- return CONTEXT_ADDR_FROM_STEM(EIP);
+-#elif defined(LISP_FEATURE_DARWIN) && defined(LISP_FEATURE_X86)
+- return CONTEXT_ADDR_FROM_STEM(eip);
+-#elif defined LISP_FEATURE_DARWIN
+- return &context->uc_mcontext->ss.srr0;
+-#else
+-#error unsupported BSD variant
+-#endif
+ }
+
+ sigset_t *
+@@ -172,9 +157,11 @@ is_valid_lisp_addr(os_vm_address_t addr)
+ in_range_p(addr, DYNAMIC_SPACE_START , dynamic_space_size))
+ return 1;
+ for_each_thread(th) {
+- if((th->control_stack_start <= addr) && (addr < th->control_stack_end))
++ if(((os_vm_address_t)th->control_stack_start <= addr) &&
++ (addr < (os_vm_address_t)th->control_stack_end))
+ return 1;
+- if(in_range_p(addr, th->binding_stack_start, BINDING_STACK_SIZE))
++ if(in_range_p(addr, (lispobj)th->binding_stack_start,
++ BINDING_STACK_SIZE))
+ return 1;
+ }
+ return 0;
+@@ -191,10 +178,20 @@ is_valid_lisp_addr(os_vm_address_t addr)
+ * page fault on this OS.
+ */
+ static void
+-memory_fault_handler(int signal, siginfo_t *siginfo, void *void_context)
++memory_fault_handler(int signal, siginfo_t *siginfo, void *void_context
++#if defined(LISP_FEATURE_FREEBSD) && defined(LISP_FEATURE_X86_64)
++/* FreeBSD/amd64 stores fault address only in undocumented 4th arg. */
++ ,void *fault_addr
++#endif
++ )
+ {
+ os_context_t *context = arch_os_get_context(&void_context);
++#if defined(LISP_FEATURE_FREEBSD) && defined(LISP_FEATURE_X86_64)
++ /* KLUDGE: Store fault address into si_addr for compatibilities. */
++ siginfo->si_addr = fault_addr;
++#else
+ void *fault_addr = arch_get_bad_addr(signal, siginfo, context);
++#endif
+
+ #if defined(LISP_FEATURE_RESTORE_TLS_SEGMENT_REGISTER_FROM_CONTEXT)
+ FSHOW_SIGNAL((stderr, "/ TLS: restoring fs: %p in memory_fault_handler\n",
+@@ -202,7 +199,7 @@ memory_fault_handler(int signal, siginfo
+ os_restore_tls_segment_register(context);
+ #endif
+
+- FSHOW((stderr, "Memory fault at: %p, PC: %x\n", fault_addr, *os_context_pc_addr(context)));
++ FSHOW((stderr, "Memory fault at: %p, PC: %p\n", fault_addr, *os_context_pc_addr(context)));
+
+ if (!gencgc_handle_wp_violation(fault_addr))
+ if(!handle_guard_page_triggered(context,fault_addr)) {
+@@ -225,9 +222,15 @@ os_install_interrupt_handlers(void)
+ {
+ SHOW("os_install_interrupt_handlers()/bsd-os/defined(GENCGC)");
+ undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT,
++#ifdef LISP_FEATURE_FREEBSD
++ (__siginfohandler_t *)
++#endif
+ memory_fault_handler);
+ #ifdef SIG_MEMORY_FAULT2
+ undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT2,
++#ifdef LISP_FEATURE_FREEBSD
++ (__siginfohandler_t *)
++#endif
+ memory_fault_handler);
+ #endif
+
+@@ -363,6 +366,8 @@ static void freebsd_init()
+ #define KERN_PROC_PATHNAME 12
+ #endif
+
++extern int getosreldate(void);
++
+ char *
+ os_get_runtime_executable_path()
+ {
+--- src/runtime/bsd-os.h Thu Nov 30 02:36:43 2006 +0000
++++ src/runtime/bsd-os.h Thu Nov 30 12:46:02 2006 +0900
+@@ -31,7 +31,6 @@ typedef vm_size_t os_vm_size_t;
+ #endif
+ typedef off_t os_vm_offset_t;
+ typedef int os_vm_prot_t;
+-typedef int os_context_register_t;
+
+ #if defined __OpenBSD__
+ /* name defined for compatibility between OpenBSD 3.1 sigaltstack(2) and
+--- src/runtime/coreparse.c Thu Nov 30 02:36:43 2006 +0000
++++ src/runtime/coreparse.c Thu Nov 30 18:19:58 2006 +0900
+@@ -107,7 +107,7 @@ lose:
+ }
+
+ static void
+-process_directory(int fd, u32 *ptr, int count, os_vm_offset_t file_offset)
++process_directory(int fd, lispobj *ptr, int count, os_vm_offset_t file_offset)
+ {
+ struct ndir_entry *entry;
+
+--- src/runtime/interrupt.c Thu Nov 30 02:36:43 2006 +0000
++++ src/runtime/interrupt.c Thu Nov 30 18:21:43 2006 +0900
+@@ -584,7 +584,6 @@ run_deferred_handler(struct interrupt_da
+ * pending handler before calling it. Trust the handler to finish
+ * with the siginfo before enabling interrupts. */
+ void (*pending_handler) (int, siginfo_t*, void*)=data->pending_handler;
+- os_context_t *context = arch_os_get_context(&v_context);
+
+ data->pending_handler=0;
+ (*pending_handler)(data->pending_signal,&(data->pending_info), v_context);
+--- src/runtime/parse.c Thu Nov 30 02:36:43 2006 +0000
++++ src/runtime/parse.c Thu Nov 30 18:22:24 2006 +0900
+@@ -12,6 +12,7 @@
+ */
+
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <ctype.h>
+ #include <signal.h>
+
+--- src/runtime/print.c Thu Nov 30 02:36:43 2006 +0000
++++ src/runtime/print.c Thu Nov 30 18:22:44 2006 +0900
+@@ -19,6 +19,7 @@
+ */
+
+ #include <stdio.h>
++#include <string.h>
+
+ #include "sbcl.h"
+ #include "print.h"
+--- src/runtime/x86-64-arch.c Thu Nov 30 02:36:43 2006 +0000
++++ src/runtime/x86-64-arch.c Thu Nov 30 19:03:02 2006 +0900
+@@ -50,7 +50,7 @@ arch_get_bad_addr(int sig, siginfo_t *co
+ * want to get to, and on OS, which determines how we get to it.)
+ */
+
+-int *
++os_context_register_t *
+ context_eflags_addr(os_context_t *context)
+ {
+ #if defined __linux__
+@@ -61,7 +61,7 @@ context_eflags_addr(os_context_t *contex
+ * instead. */
+ return &context->uc_mcontext.gregs[17];
+ #elif defined __FreeBSD__
+- return &context->uc_mcontext.mc_eflags;
++ return &context->uc_mcontext.mc_rflags;
+ #elif defined __OpenBSD__
+ return &context->sc_eflags;
+ #else
+@@ -106,7 +106,7 @@ void arch_skip_instruction(os_context_t
+ break;
+
+ default:
+- fprintf(stderr,"[arch_skip_inst invalid code %d\n]\n",code);
++ fprintf(stderr,"[arch_skip_inst invalid code %ld\n]\n",code);
+ break;
+ }
+
+@@ -166,6 +166,11 @@ arch_remove_breakpoint(void *pc, unsigne
+ /* When single stepping, single_stepping holds the original instruction
+ * PC location. */
+ unsigned int *single_stepping = NULL;
++#ifdef CANNOT_GET_TO_SINGLE_STEP_FLAG
++unsigned int single_step_save1;
++unsigned int single_step_save2;
++unsigned int single_step_save3;
++#endif
+
+ void
+ arch_do_displaced_inst(os_context_t *context, unsigned int orig_inst)
+@@ -176,9 +181,24 @@ arch_do_displaced_inst(os_context_t *con
+ *((char *)pc) = orig_inst & 0xff;
+ *((char *)pc + 1) = (orig_inst & 0xff00) >> 8;
+
++#ifdef CANNOT_GET_TO_SINGLE_STEP_FLAG
++ /* Install helper instructions for the single step:
++ * pushf; or [esp],0x100; popf. */
++ single_step_save1 = *(pc-3);
++ single_step_save2 = *(pc-2);
++ single_step_save3 = *(pc-1);
++ *(pc-3) = 0x9c909090;
++ *(pc-2) = 0x00240c81;
++ *(pc-1) = 0x9d000001;
++#else
+ *context_eflags_addr(context) |= 0x100;
++#endif
+
+ single_stepping = pc;
++
++#ifdef CANNOT_GET_TO_SINGLE_STEP_FLAG
++ *os_context_pc_addr(context) = (os_context_register_t)((char *)pc - 9);
++#endif
+ }
+
+
+@@ -191,10 +211,17 @@ sigtrap_handler(int signal, siginfo_t *i
+
+ if (single_stepping && (signal==SIGTRAP))
+ {
++#ifdef CANNOT_GET_TO_SINGLE_STEP_FLAG
++ /* Un-install single step helper instructions. */
++ *(single_stepping-3) = single_step_save1;
++ *(single_stepping-2) = single_step_save2;
++ *(single_stepping-1) = single_step_save3;
++#else
+ *context_eflags_addr(context) ^= 0x100;
+-
++#endif
+ /* Re-install the breakpoint if possible. */
+- if (*os_context_pc_addr(context) == (int)single_stepping + 1) {
++ if ((char *)*os_context_pc_addr(context) ==
++ (char *)single_stepping + 1) {
+ fprintf(stderr, "warning: couldn't reinstall breakpoint\n");
+ } else {
+ *((char *)single_stepping) = BREAKPOINT_INST; /* x86 INT3 */
+@@ -216,7 +243,7 @@ sigtrap_handler(int signal, siginfo_t *i
+ single-stepping (as far as I can tell) this is somewhat moot,
+ but it might be worth either moving this code up or deleting
+ the single-stepping code entirely. -- CSR, 2002-07-15 */
+-#ifdef LISP_FEATURE_LINUX
++#if defined(LISP_FEATURE_LINUX) || defined(RESTORE_FP_CONTROL_FROM_CONTEXT)
+ os_restore_fp_control(context);
+ #endif
+
+--- src/runtime/x86-bsd-os.c Thu Nov 30 02:36:43 2006 +0000
++++ src/runtime/x86-bsd-os.c Thu Nov 30 12:28:00 2006 +0900
+@@ -100,6 +100,22 @@ os_context_sp_addr(os_context_t *context
+
+ #endif /* __NetBSD__ */
+
++int *os_context_pc_addr(os_context_t *context)
++{
++#if defined __FreeBSD__
++ return CONTEXT_ADDR_FROM_STEM(eip);
++#elif defined __OpenBSD__
++ return CONTEXT_ADDR_FROM_STEM(pc);
++#elif defined __NetBSD__
++ return CONTEXT_ADDR_FROM_STEM(EIP);
++#elif defined(LISP_FEATURE_DARWIN) && defined(LISP_FEATURE_X86)
++ return CONTEXT_ADDR_FROM_STEM(eip);
++#elif defined LISP_FEATURE_DARWIN
++ return &context->uc_mcontext->ss.srr0;
++#else
++#error unsupported BSD variant
++#endif
++}
+
+ /* FIXME: If this can be a no-op on BSD/x86, then it
+ * deserves a more precise name.
+--- src/runtime/x86-bsd-os.h Thu Nov 30 02:36:43 2006 +0000
++++ src/runtime/x86-bsd-os.h Thu Nov 30 12:43:00 2006 +0900
+@@ -5,6 +5,8 @@
+ #include <machine/segments.h>
+ #include <machine/cpufunc.h>
+ #endif
++
++typedef int os_context_register_t;
+
+ static inline os_context_t *arch_os_get_context(void **void_context) {
+ return (os_context_t *) *void_context;
+--- tests/foreign-stack-alignment.impure.lisp Thu Nov 30 02:36:43 2006 +0000
++++ tests/foreign-stack-alignment.impure.lisp Thu Nov 30 16:41:00 2006 +0900
+@@ -43,7 +43,7 @@
+ ;;;; number.
+
+ (run "cc"
+- #+(and linux (or x86-64 ppc)) "-fPIC"
++ #+(and (or linux freebsd) (or x86-64 ppc)) "-fPIC"
+ "stack-alignment-offset.c" "-o" "stack-alignment-offset")
+
+ (defparameter *good-offset*
+@@ -53,7 +53,7 @@
+ ;;;; Build the tool again, this time as a shared object, and load it
+
+ (run "cc" "stack-alignment-offset.c"
+- #+(and linux (or x86-64 ppc)) "-fPIC"
++ #+(and (or linux freebsd) (or x86-64 ppc)) "-fPIC"
+ #+darwin "-bundle" #-darwin "-shared"
+ "-o" "stack-alignment-offset.so")
+
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ src/runtime/Config.x86-64-bsd Thu Nov 30 17:01:43 2006 +0900
+@@ -0,0 +1,25 @@
++# -*- makefile -*- for the C-level run-time support for SBCL
++# configuration stuff shared between various *BSD OSes
++
++# This software is part of the SBCL system. See the README file for
++# more information.
++#
++# This software is derived from the CMU CL system, which was
++# written at Carnegie Mellon University and released into the
++# public domain. The software is in the public domain and is
++# provided with absolutely no warranty. See the COPYING and CREDITS
++# files for more information.
++
++ASSEM_SRC = x86-64-assem.S
++ARCH_SRC = x86-64-arch.c
++
++OS_SRC = bsd-os.c x86-64-bsd-os.c
++OS_LIBS = # -ldl
++
++CFLAGS += -fno-omit-frame-pointer
++
++GC_SRC = gencgc.c
++
++# Nothing to do for after-grovel-headers.
++.PHONY: after-grovel-headers
++after-grovel-headers:
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ src/runtime/Config.x86-64-freebsd Thu Nov 30 11:47:03 2006 +0900
+@@ -0,0 +1,26 @@
++# -*- makefile -*- for the C-level run-time support for SBCL
++
++# This software is part of the SBCL system. See the README file for
++# more information.
++#
++# This software is derived from the CMU CL system, which was
++# written at Carnegie Mellon University and released into the
++# public domain. The software is in the public domain and is
++# provided with absolutely no warranty. See the COPYING and CREDITS
++# files for more information.
++
++include Config.x86-64-bsd
++
++ASSEM_SRC += ldso-stubs.S
++
++# Until sbcl-0.6.7.3, we used "LINKFLAGS+=-static" here, which
++# worked fine for most things, but LOAD-FOREIGN & friends require
++# dlopen() etc., which in turn depend on dynamic linking of the
++# runtime.
++LINKFLAGS += -dynamic -export-dynamic
++
++# use libthr (1:1 threading). libpthread (m:n threading) does not work.
++ifdef LISP_FEATURE_SB_THREAD
++ #OS_LIBS += -lpthread
++ OS_LIBS += -lthr
++endif
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ src/runtime/x86-64-bsd-os.c Thu Nov 30 16:02:37 2006 +0900
+@@ -0,0 +1,115 @@
++#include <signal.h>
++#include "sbcl.h"
++#include "runtime.h"
++#include "thread.h"
++#include "lispregs.h"
++
++#if defined(LISP_FEATURE_FREEBSD)
++#include <machine/fpu.h>
++#endif
++
++/* KLUDGE: There is strong family resemblance in the signal context
++ * stuff in FreeBSD and OpenBSD, but in detail they're different in
++ * almost every line of code. It would be nice to find some way to
++ * factor out the commonality better; failing that, it might be best
++ * just to split this generic-BSD code into one variant for each BSD.
++ *
++ * KLUDGE II: this split has begun with the addition of the Darwin BSD
++ * flavour, with the cross-architecture complications that this
++ * entails; unfortunately, currently the situation is worse, not
++ * better, than in the above paragraph. */
++
++#if defined(LISP_FEATURE_FREEBSD)
++os_context_register_t *
++os_context_register_addr(os_context_t *context, int offset)
++{
++ switch(offset) {
++ case reg_RAX:
++ return CONTEXT_ADDR_FROM_STEM(rax);
++ case reg_RCX:
++ return CONTEXT_ADDR_FROM_STEM(rcx);
++ case reg_RDX:
++ return CONTEXT_ADDR_FROM_STEM(rdx);
++ case reg_RBX:
++ return CONTEXT_ADDR_FROM_STEM(rbx);
++ case reg_RSP:
++ return CONTEXT_ADDR_FROM_STEM(rsp);
++ case reg_RBP:
++ return CONTEXT_ADDR_FROM_STEM(rbp);
++ case reg_RSI:
++ return CONTEXT_ADDR_FROM_STEM(rsi);
++ case reg_RDI:
++ return CONTEXT_ADDR_FROM_STEM(rdi);
++ case reg_R8:
++ return CONTEXT_ADDR_FROM_STEM(r8);
++ case reg_R9:
++ return CONTEXT_ADDR_FROM_STEM(r9);
++ case reg_R10:
++ return CONTEXT_ADDR_FROM_STEM(r10);
++ case reg_R11:
++ return CONTEXT_ADDR_FROM_STEM(r11);
++ case reg_R12:
++ return CONTEXT_ADDR_FROM_STEM(r12);
++ case reg_R13:
++ return CONTEXT_ADDR_FROM_STEM(r13);
++ case reg_R14:
++ return CONTEXT_ADDR_FROM_STEM(r14);
++ case reg_R15:
++ return CONTEXT_ADDR_FROM_STEM(r15);
++ default:
++ return 0;
++ }
++}
++
++os_context_register_t *
++os_context_sp_addr(os_context_t *context)
++{
++ return CONTEXT_ADDR_FROM_STEM(rsp);
++}
++
++os_context_register_t *
++os_context_pc_addr(os_context_t *context)
++{
++ return CONTEXT_ADDR_FROM_STEM(rip);
++}
++
++#endif
++
++void
++os_flush_icache(os_vm_address_t address, os_vm_size_t length)
++{
++}
++
++int arch_os_thread_init(struct thread *thread) {
++ stack_t sigstack;
++#ifdef LISP_FEATURE_SB_THREAD
++ pthread_setspecific(specials,thread);
++#endif
++#ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
++ /* Signal handlers are run on the control stack, so if it is exhausted
++ * we had better use an alternate stack for whatever signal tells us
++ * we've exhausted it */
++ sigstack.ss_sp=((void *) thread)+dynamic_values_bytes;
++ sigstack.ss_flags=0;
++ sigstack.ss_size = 32*SIGSTKSZ;
++ sigaltstack(&sigstack,0);
++#endif
++ return 1; /* success */
++}
++
++int arch_os_thread_cleanup(struct thread *thread) {
++ return 1; /* success */
++}
++
++#if defined(LISP_FEATURE_FREEBSD)
++void
++os_restore_fp_control(os_context_t *context)
++{
++ struct envxmm *ex = (struct envxmm*)(&context->uc_mcontext.mc_fpstate);
++ /* reset exception flags and restore control flags on SSE2 FPU */
++ unsigned int temp = (ex->en_mxcsr) & ~0x3F;
++ asm ("ldmxcsr %0" : : "m" (temp));
++ /* same for x87 FPU. */
++ asm ("fldcw %0" : : "m" (ex->en_cw));
++}
++#endif
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ src/runtime/x86-64-bsd-os.h Thu Nov 30 12:45:17 2006 +0900
+@@ -0,0 +1,34 @@
++#ifndef _X86_64_BSD_OS_H
++#define _X86_64_BSD_OS_H
++
++#ifdef LISP_FEATURE_FREEBSD
++#include <machine/segments.h>
++#include <machine/cpufunc.h>
++#endif
++
++typedef register_t os_context_register_t;
++
++static inline os_context_t *arch_os_get_context(void **void_context) {
++ return (os_context_t *) *void_context;
++}
++
++/* The different BSD variants have diverged in exactly where they
++ * store signal context information, but at least they tend to use the
++ * same stems to name the structure fields, so by using this macro we
++ * can share a fair amount of code between different variants. */
++#if defined __FreeBSD__
++#define CONTEXT_ADDR_FROM_STEM(stem) &context->uc_mcontext.mc_ ## stem
++#elif defined(__OpenBSD__)
++#define CONTEXT_ADDR_FROM_STEM(stem) &context->sc_ ## stem
++#elif defined __NetBSD__
++#define CONTEXT_ADDR_FROM_STEM(stem) &((context)->uc_mcontext.__gregs[_REG_ ## stem])
++#else
++#error unsupported BSD variant
++#endif
++
++#if defined LISP_FEATURE_FREEBSD
++#define RESTORE_FP_CONTROL_FROM_CONTEXT
++void os_restore_fp_control(os_context_t *context);
++#endif
++
++#endif /* _X86_64_BSD_OS_H */
diff --git a/lang/sbcl/files/patch-src_runtime_thread.c b/lang/sbcl/files/patch-src_runtime_thread.c
new file mode 100644
index 000000000000..75387fc2d7b3
--- /dev/null
+++ b/lang/sbcl/files/patch-src_runtime_thread.c
@@ -0,0 +1,13 @@
+--- src/runtime/thread.c Thu Nov 23 15:11:26 2006 +0000
++++ src/runtime/thread.c Fri Nov 24 01:54:54 2006 +0900
+@@ -350,6 +350,10 @@ create_thread_struct(lispobj initial_fun
+ int i;
+ #endif
+
++#ifdef CREATE_CLEANUP_THREAD
++ /* Give a chance for cleanup threads to run. */
++ sched_yield();
++#endif
+ /* may as well allocate all the spaces at once: it saves us from
+ * having to decide what to do if only some of the allocations
+ * succeed */
diff --git a/lang/sbcl/pkg-plist b/lang/sbcl/pkg-plist
index cafd528e2892..4c70e27a140b 100644
--- a/lang/sbcl/pkg-plist
+++ b/lang/sbcl/pkg-plist
@@ -28,7 +28,6 @@
%%PORTDOCS%%%%DOCSDIR%%/html/asdf/missing-bits-in-implementation.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/ANSI-Conformance.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Accessing-Foreign-Values.html
-%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Accurate-Profiler.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Additional-Distributed-Documentation.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Automatic-Recompilation-of-Stale-Fasls.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Beyond-the-ANSI-Standard.html
@@ -68,6 +67,7 @@
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Declarations.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Defining-Constants.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Defining-Foreign-Types.html
+%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Deterministic-Profiler.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Development-Tools.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Diagnostic-Messages.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Diagnostic-Severity.html
@@ -245,6 +245,7 @@
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Macro-sb_002dprofile_003aprofile.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Macro-sb_002dprofile_003aunprofile.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Macro-sb_002dsprof_003awith_002dprofiling.html
+%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Macro-sb_002dsprof_003awith_002dsampling.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Macro-sb_002dthread_003awith_002dmutex.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Macro-sb_002dthread_003awith_002drecursive_002dlock.html
%%PORTDOCS%%%%DOCSDIR%%/html/sbcl/Metaobject-Protocol.html
@@ -389,8 +390,6 @@ lib/sbcl/sb-bsd-sockets/inet.fasl
lib/sbcl/sb-bsd-sockets/inet.lisp
lib/sbcl/sb-bsd-sockets/local.fasl
lib/sbcl/sb-bsd-sockets/local.lisp
-lib/sbcl/sb-bsd-sockets/malloc.fasl
-lib/sbcl/sb-bsd-sockets/malloc.lisp
lib/sbcl/sb-bsd-sockets/misc.fasl
lib/sbcl/sb-bsd-sockets/misc.lisp
lib/sbcl/sb-bsd-sockets/name-service.fasl
@@ -489,7 +488,7 @@ lib/sbcl/sb-rotate-byte/sb-rotate-byte.asd
lib/sbcl/sb-rotate-byte/sb-rotate-byte.fasl
lib/sbcl/sb-rotate-byte/sb-rotate-byte.texinfo
lib/sbcl/sb-rotate-byte/test-passed
-lib/sbcl/sb-rotate-byte/x86-vm.fasl
+%%I386_ONLY%%lib/sbcl/sb-rotate-byte/x86-vm.fasl
lib/sbcl/sb-rotate-byte/x86-vm.lisp
lib/sbcl/sb-rt/.cvsignore
lib/sbcl/sb-rt/Makefile