diff -ruN clean/sbcl-0.8.19/make-config.sh patched/sbcl-0.8.19.patched/make-config.sh
--- clean/sbcl-0.8.19/make-config.sh	2005-01-08 09:41:47.000000000 +0000
+++ patched/sbcl-0.8.19.patched/make-config.sh	2005-02-21 13:02:26.000000000 +0000
@@ -120,6 +120,11 @@
 	ln -s $sbcl_arch-bsd-os.h target-arch-os.h
 	ln -s bsd-os.h target-os.h
 	case `uname` in
+	    DragonFly)
+		printf ' :dragonfly' >> $ltf
+		sbcl_os="dragonfly"
+		ln -s Config.$sbcl_arch-dragonfly Config
+		;;
 	    FreeBSD)
 		printf ' :freebsd' >> $ltf
 		sbcl_os="freebsd"
@@ -188,7 +193,7 @@
 if [ "$sbcl_arch" = "x86" ]; then
     printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
     printf ' :stack-allocatable-closures' >> $ltf
-    if [ "$sbcl_os" = "linux" ] || [ "$sbcl_os" = "freebsd" ] || [ "$sbcl_os" = "netbsd" ]; then
+    if [ "$sbcl_os" = "linux" ] || [ "$sbcl_os" = "freebsd" ] || [ "$sbcl_os" = "netbsd" ] || [ "$sbcl_os" = "dragonfly" ]; then
 	printf ' :linkage-table' >> $ltf
     fi
 elif [ "$sbcl_arch" = "x86-64" ]; then
diff -ruN clean/sbcl-0.8.19/src/code/bsd-os.lisp patched/sbcl-0.8.19.patched/src/code/bsd-os.lisp
--- clean/sbcl-0.8.19/src/code/bsd-os.lisp	2004-04-08 13:26:03.000000000 +0000
+++ patched/sbcl-0.8.19.patched/src/code/bsd-os.lisp	2005-02-21 13:03:30.000000000 +0000
@@ -16,6 +16,7 @@
   "Return a string describing the supporting software."
   (the string ; (to force error in case of unsupported BSD variant)
        #!+FreeBSD "FreeBSD"
+       #!+DragonFly "DragonFly"
        #!+OpenBSD "OpenBSD"
        #!+NetBSD "NetBSD"
        #!+Darwin "Darwin"))
diff -ruN clean/sbcl-0.8.19/src/code/unix.lisp patched/sbcl-0.8.19.patched/src/code/unix.lisp
--- clean/sbcl-0.8.19/src/code/unix.lisp	2005-01-19 21:11:04.000000000 +0000
+++ patched/sbcl-0.8.19.patched/src/code/unix.lisp	2005-02-21 13:06:18.000000000 +0000
@@ -298,14 +298,14 @@
   ;; a constant. Going the grovel_headers route doesn't seem to be
   ;; helpful, either, as Solaris doesn't export PATH_MAX from
   ;; unistd.h.
-  #!-(or linux openbsd freebsd netbsd sunos osf1 darwin) (,stub,)
-  #!+(or linux openbsd freebsd netbsd sunos osf1 darwin)
+  #!-(or linux openbsd freebsd dragonfly netbsd sunos osf1 darwin) (,stub,)
+  #!+(or linux openbsd freebsd dragonfly netbsd sunos osf1 darwin)
   (or (newcharstar-string (alien-funcall (extern-alien "getcwd"
 						       (function (* char)
 								 (* char)
 								 size-t))
 					 nil 
-					 #!+(or linux openbsd freebsd netbsd darwin) 0
+					 #!+(or linux openbsd freebsd dragonfly netbsd darwin) 0
 					 #!+(or sunos osf1) 1025))
       (simple-perror "getcwd")))
 
diff -ruN clean/sbcl-0.8.19/src/compiler/x86/parms.lisp patched/sbcl-0.8.19.patched/src/compiler/x86/parms.lisp
--- clean/sbcl-0.8.19/src/compiler/x86/parms.lisp	2004-12-03 17:50:12.000000000 +0000
+++ patched/sbcl-0.8.19.patched/src/compiler/x86/parms.lisp	2005-02-21 13:08:33.000000000 +0000
@@ -176,6 +176,21 @@
   (def!constant linkage-table-space-start #x90000000)
   (def!constant linkage-table-space-end   #x91000000))
 
+#!+dragonfly
+(progn
+  (def!constant read-only-space-start     #x10000000)
+  (def!constant read-only-space-end       #x1ffff000)
+
+  (def!constant static-space-start        #x30000000)
+  (def!constant static-space-end          #x37fff000)
+
+  (def!constant dynamic-space-start       #x48000000)
+  (def!constant dynamic-space-end         #x88000000)
+
+  ;; In CMUCL:  0xB0000000->0xB1000000
+  (def!constant linkage-table-space-start #x90000000)
+  (def!constant linkage-table-space-end   #x91000000))
+
 #!+openbsd
 (progn
   (def!constant read-only-space-start     #x40000000)
diff -ruN clean/sbcl-0.8.19/src/runtime/Config.x86-dragonfly patched/sbcl-0.8.19.patched/src/runtime/Config.x86-dragonfly
--- clean/sbcl-0.8.19/src/runtime/Config.x86-dragonfly	1970-01-01 00:00:00.000000000 +0000
+++ patched/sbcl-0.8.19.patched/src/runtime/Config.x86-dragonfly	2005-02-21 13:09:34.000000000 +0000
@@ -0,0 +1,10 @@
+# -*- makefile -*-
+include Config.x86-bsd
+
+ASSEM_SRC += ldso-stubs.S
+
+# Until sbcl-0.6.7.3, we used "OS_LINK_FLAGS=-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.
+OS_LINK_FLAGS = -dynamic -export-dynamic
diff -ruN clean/sbcl-0.8.19/src/runtime/bsd-os.c patched/sbcl-0.8.19.patched/src/runtime/bsd-os.c
--- clean/sbcl-0.8.19/src/runtime/bsd-os.c	2004-12-03 17:50:12.000000000 +0000
+++ patched/sbcl-0.8.19.patched/src/runtime/bsd-os.c	2005-02-21 13:12:01.000000000 +0000
@@ -59,7 +59,7 @@
 
 int *os_context_pc_addr(os_context_t *context)
 {
-#if defined __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
     return CONTEXT_ADDR_FROM_STEM(eip);
 #elif defined __OpenBSD__
     return CONTEXT_ADDR_FROM_STEM(pc);
@@ -78,7 +78,7 @@
     /* (Unlike most of the other context fields that we access, the
      * signal mask field is a field of the basic, outermost context
      * struct itself both in FreeBSD 4.0 and in OpenBSD 2.6.) */
-#if defined __FreeBSD__  || __NetBSD__ || defined LISP_FEATURE_DARWIN
+#if defined __FreeBSD__  || __NetBSD__ || defined LISP_FEATURE_DARWIN || defined(__DragonFly__)
     return &context->uc_sigmask;
 #elif defined __OpenBSD__
     return &context->sc_mask;
@@ -177,7 +177,7 @@
 {
     /* The way that we extract low level information like the fault
      * address is not specified by POSIX. */
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
     void *fault_addr = siginfo->si_addr;
 #elif defined LISP_FEATURE_DARWIN
     void *fault_addr = siginfo->si_addr;
diff -ruN clean/sbcl-0.8.19/src/runtime/bsd-os.h patched/sbcl-0.8.19.patched/src/runtime/bsd-os.h
--- clean/sbcl-0.8.19/src/runtime/bsd-os.h	2004-04-19 03:41:40.000000000 +0000
+++ patched/sbcl-0.8.19.patched/src/runtime/bsd-os.h	2005-02-21 13:15:04.000000000 +0000
@@ -37,7 +37,7 @@
 /* FreeBSD 4.6 and NetBSD 1.6 already have stack_t defined. */
 #endif
 
-#if defined __FreeBSD__
+#if defined __FreeBSD__ || defined(__DragonFly__)
 /* Note: The man page for sigaction(2) in FreeBSD 4.0 says that this
  * is an mcontext_t, but according to comments by Raymond Wiker in the
  * original FreeBSD port of SBCL, that's wrong, it's actually a
diff -ruN clean/sbcl-0.8.19/src/runtime/undefineds.h patched/sbcl-0.8.19.patched/src/runtime/undefineds.h
--- clean/sbcl-0.8.19/src/runtime/undefineds.h	2004-04-19 03:41:40.000000000 +0000
+++ patched/sbcl-0.8.19.patched/src/runtime/undefineds.h	2005-02-21 13:22:47.000000000 +0000
@@ -38,6 +38,7 @@
 #if defined(hpux) \
      || defined(SVR4) \
      || defined(__FreeBSD__) \
+     || defined(__DragonFly__) \
      || defined(__OpenBSD__) \
      || defined(__NetBSD__)
 F(cfgetospeed)
@@ -153,7 +154,7 @@
 #if !defined(SVR4)
 F(sigsetmask)
 #endif
-#if !defined(SVR4) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
+#if !defined(SVR4) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
 F(sigstack)
 F(sigvec)
 #endif
@@ -177,6 +178,7 @@
 #if defined(hpux) \
      || defined(SVR4) \
      || defined(__FreeBSD__) \
+     || defined(__DragonFly__) \
      || defined(__OpenBSD__) \
      || defined(__NetBSD__) \
      || defined(__linux__)
@@ -197,6 +199,7 @@
      && !defined(SOLARIS) \
      && !defined(__OpenBSD__) \
      && !defined(__FreeBSD__) \
+     && !defined(__DragonFly__) \
      && !defined(__NetBSD__)
 F(umount)
 #endif
@@ -207,7 +210,7 @@
 #ifndef irix
 F(vfork)
 #endif
-#if !defined(osf1) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
+#if !defined(osf1) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
 F(vhangup)
 #endif
 F(wait)
@@ -260,11 +263,11 @@
 /* FIXME: NetBSD plays some renaming games, and so cannot simply
    reference symbols here.  "NetBSD needs to get fixed here too PEM
    2004-03-27" */
-#if defined(SVR4) || defined(__FreeBSD__)
+#if defined(SVR4) || defined(__FreeBSD__) || defined(__DragonFly__)
 F(setpgid)
 F(getpgid)
 D(timezone)
-#if !defined(__FreeBSD__)
+#if !defined(__FreeBSD__) && !defined(__DragonFly__)
 D(altzone)
 D(daylight)
 #endif
diff -ruN clean/sbcl-0.8.19/src/runtime/x86-arch.c patched/sbcl-0.8.19.patched/src/runtime/x86-arch.c
--- clean/sbcl-0.8.19/src/runtime/x86-arch.c	2004-09-09 12:10:15.000000000 +0000
+++ patched/sbcl-0.8.19.patched/src/runtime/x86-arch.c	2005-02-21 13:23:35.000000000 +0000
@@ -53,7 +53,7 @@
      * we need to do this nasty absolute index magic number thing
      * instead. */
     return &context->uc_mcontext.gregs[16];
-#elif defined __FreeBSD__
+#elif defined __FreeBSD__ || defined(__DragonFly__)
     return &context->uc_mcontext.mc_eflags;
 #elif defined __OpenBSD__
     return &context->sc_eflags;
diff -ruN clean/sbcl-0.8.19/src/runtime/x86-assem.S patched/sbcl-0.8.19.patched/src/runtime/x86-assem.S
--- clean/sbcl-0.8.19/src/runtime/x86-assem.S	2004-12-01 14:14:25.000000000 +0000
+++ patched/sbcl-0.8.19.patched/src/runtime/x86-assem.S	2005-02-21 13:24:42.000000000 +0000
@@ -29,7 +29,7 @@
  * turns out not to matter, perhaps it's just clutter we could get
  * rid of? -- WHN 2004-04-18)
  */
-#if defined __linux__  || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
+#if defined __linux__  || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined(__DragonFly__)
 #define GNAME(var) var
 #else
 #define GNAME(var) _##var
@@ -44,7 +44,7 @@
  * matter any more, perhaps it's just clutter we could get
  * rid of? -- WHN 2004-04-18)
  */
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
 #define align_4byte	4
 #define align_8byte	8
 #define align_16byte	16
diff -ruN clean/sbcl-0.8.19/src/runtime/x86-bsd-os.c patched/sbcl-0.8.19.patched/src/runtime/x86-bsd-os.c
--- clean/sbcl-0.8.19/src/runtime/x86-bsd-os.c	2004-10-18 13:07:42.000000000 +0000
+++ patched/sbcl-0.8.19.patched/src/runtime/x86-bsd-os.c	2005-02-21 13:25:59.000000000 +0000
@@ -14,7 +14,7 @@
  * entails; unfortunately, currently the situation is worse, not
  * better, than in the above paragraph. */
 
-#if defined(__FreeBSD__) || defined(__OpenBSD__)   
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
 int *
 os_context_register_addr(os_context_t *context, int offset)
 {
@@ -46,7 +46,7 @@
     return CONTEXT_ADDR_FROM_STEM(esp);
 }
 
-#endif /* __FreeBSD__ || __OpenBSD__ */
+#endif /* __FreeBSD__ || __OpenBSD__ || __DragonFly__ */
 
 #ifdef __NetBSD__
 int *
diff -ruN clean/sbcl-0.8.19/src/runtime/x86-bsd-os.h patched/sbcl-0.8.19.patched/src/runtime/x86-bsd-os.h
--- clean/sbcl-0.8.19/src/runtime/x86-bsd-os.h	2004-04-08 13:26:04.000000000 +0000
+++ patched/sbcl-0.8.19.patched/src/runtime/x86-bsd-os.h	2005-02-21 13:26:24.000000000 +0000
@@ -9,7 +9,7 @@
  * 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__
+#if defined __FreeBSD__ || defined(__DragonFly__)
 #define CONTEXT_ADDR_FROM_STEM(stem) &context->uc_mcontext.mc_ ## stem
 #elif defined __OpenBSD__
 #define CONTEXT_ADDR_FROM_STEM(stem) &context->sc_ ## stem

