Index: system/x86-freebsd-system.lid
===================================================================
--- system/x86-freebsd-system.lid	(revision 10708)
+++ system/x86-freebsd-system.lid	(working copy)
@@ -30,6 +30,7 @@
        xml
        settings/settings
        settings/dummy-settings
+Linker-Options: freebsd.o
 Copyright:    Original Code is Copyright (c) 1995-2004 Functional Objects, Inc.
               All rights reserved.
 License:      Functional Objects Library Public License Version 1.0
Index: system/file-system/unix-interface.dylan
===================================================================
--- system/file-system/unix-interface.dylan	(revision 10708)
+++ system/file-system/unix-interface.dylan	(working copy)
@@ -89,7 +89,7 @@
     (fd :: <integer>, position :: <integer>, mode :: <integer>) => (position :: <integer>)
   with-interrupt-repeat
     raw-as-integer
-      (%call-c-function ("lseek")
+      (%call-c-function ("mylseek")
            (fd :: <raw-c-unsigned-int>, position :: <raw-c-unsigned-long>, 
             mode :: <raw-c-unsigned-int>) 
         => (result :: <raw-c-signed-int>)
@@ -113,7 +113,7 @@
 define function unix-errno-value () => (errno :: <integer>)
   raw-as-integer
     (primitive-c-signed-int-at
-      (%call-c-function ("__errno_location") () => (errnop :: <raw-pointer>) () end,
+      (%call-c-function ("__error") () => (errnop :: <raw-pointer>) () end,
        integer-as-raw(0), integer-as-raw(0)))
 end function unix-errno-value;
 
Index: system/file-system/unix-ffi.dylan
===================================================================
--- system/file-system/unix-ffi.dylan	(revision 10708)
+++ system/file-system/unix-ffi.dylan	(working copy)
@@ -188,13 +188,13 @@
 define function unix-last-error () => (errno :: <integer>)
   raw-as-integer
     (primitive-c-signed-int-at
-      (%call-c-function ("__errno_location") () => (errnop :: <raw-pointer>) () end,
+      (%call-c-function ("__error") () => (errnop :: <raw-pointer>) () end,
        integer-as-raw(0), integer-as-raw(0)))
 end function unix-last-error;
 
 define function unix-last-error-setter (errno :: <integer>) => (errno :: <integer>)
   primitive-c-signed-int-at
-    (%call-c-function ("__errno_location") () => (errnop :: <raw-pointer>) () end,
+    (%call-c-function ("__error") () => (errnop :: <raw-pointer>) () end,
      integer-as-raw(0), integer-as-raw(0))
     := integer-as-raw(errno);
   errno
Index: system/freebsd.c
===================================================================
--- system/freebsd.c	(revision 0)
+++ system/freebsd.c	(revision 0)
@@ -0,0 +1,5 @@
+#include <unistd.h>
+
+int mylseek (int fildes, int offset, int whence) {
+  return lseek(fildes, offset, whence);
+}
Index: network/unix-sockets/errno.dylan
===================================================================
--- network/unix-sockets/errno.dylan	(revision 10708)
+++ network/unix-sockets/errno.dylan	(working copy)
@@ -7,7 +7,7 @@
 
 define inline-only C-function errno-location
   result val :: <C-int*>;
-  c-name: "__errno_location";
+  c-name: "__error";
 end C-function;
 
 define function errno() => (error-number :: <integer>)
Index: common-dylan/unix-common-extensions.dylan
===================================================================
--- common-dylan/unix-common-extensions.dylan	(revision 10708)
+++ common-dylan/unix-common-extensions.dylan	(working copy)
@@ -108,7 +108,7 @@
     end;
     //
     let exe-path
-      = concatenate("/proc/", integer-to-string(pid), "/exe");
+      = concatenate("/proc/", integer-to-string(pid), "/file");
     let buffer = make(<byte-string>, size: 8192, fill: '\0');
     let count
       = raw-as-integer(%call-c-function ("readlink")
Index: lib/variable-search/unix-variable-search.lid
===================================================================
--- lib/variable-search/unix-variable-search.lid	(revision 10708)
+++ lib/variable-search/unix-variable-search.lid	(working copy)
@@ -2,7 +2,6 @@
 Files:   unix-variable-search-library
          protocol
          unix-variable-search
-C-Libraries: -ldl
 Copyright:    Original Code is Copyright (c) 1995-2004 Functional Objects, Inc.
               All rights reserved.
 License:      Functional Objects Library Public License Version 1.0
Index: harp/pentium-harp/moves.dylan
===================================================================
--- harp/pentium-harp/moves.dylan	(revision 10708)
+++ harp/pentium-harp/moves.dylan	(working copy)
@@ -437,9 +437,7 @@
 
 
 /// Linux TEB support:
-///  Some versions of LinuxThreads store the pthread descriptor in the gs segment register.
-///  Use an unused fixed offset in pthread descriptor to store the TEB
-///  while running Dylan code.
+/// We use Linux' TLV support here.
 
 define method op--tlb-base-register 
     (be :: <pentium-linux-back-end>, dest :: <real-register>) => ()
@@ -451,9 +449,14 @@
 
 define method op--store-thread-local
     (be :: <pentium-linux-back-end>, data, offset :: <integer>) => ()
+  harp-out(be)
+    push(be, reg--tmp2);
+  end harp-out;
   emit(be, gs.segment-prefix);
   harp-out(be)
-    st(be, data, $teb, 0 /*ignore offset for Linux */);
+    ld(be, reg--tmp2, 0, 0);
+    st(be, data, $teb, reg--tmp2);
+    pop(be, reg--tmp2);
   end harp-out;
 end method;
 
@@ -461,7 +464,8 @@
     (be :: <pentium-linux-back-end>, dest :: <real-register>, offset :: <integer>) => ()
   emit(be, gs.segment-prefix);
   harp-out(be)
-    ld(be, dest, $teb, 0 /*ignore offset for Linux */);
+    ld(be, dest, 0, 0);
+    ld(be, dest, $teb, dest);
   end harp-out;
 end method;
 
Index: harp/pentium-harp/back-end.dylan
===================================================================
--- harp/pentium-harp/back-end.dylan	(revision 10708)
+++ harp/pentium-harp/back-end.dylan	(working copy)
@@ -26,7 +26,9 @@
 
 register-back-end(<pentium-windows-back-end>, #"harp", #"x86", #"win32");
 
-Define class <pentium-linux-back-end> (<pentium-back-end>, <native-linux-back-end>)
+define class <pentium-linux-back-end> (<pentium-back-end>, <native-linux-back-end>)
 end;
 
 register-back-end(<pentium-linux-back-end>, #"harp", #"x86", #"linux");
+
+register-back-end(<pentium-linux-back-end>, #"harp", #"x86", #"freebsd");
Index: io/unix-standard-io.dylan
===================================================================
--- io/unix-standard-io.dylan	(revision 10708)
+++ io/unix-standard-io.dylan	(working copy)
@@ -77,7 +77,7 @@
 define function unix-errno-value () => (errno :: <integer>)
   raw-as-integer
     (primitive-c-signed-int-at
-      (%call-c-function ("__errno_location") () => (errnop :: <raw-pointer>) () end,
+      (%call-c-function ("__error") () => (errnop :: <raw-pointer>) () end,
        integer-as-raw(0), integer-as-raw(0)))
 end function unix-errno-value;
 
Index: dfmc/harp-cg/harp-back-end.dylan
===================================================================
--- dfmc/harp-cg/harp-back-end.dylan	(revision 10708)
+++ dfmc/harp-cg/harp-back-end.dylan	(working copy)
@@ -18,6 +18,7 @@
     assembler-output? := select ($os-name)
 			   #"win32"  => #f;
 			   #"linux" => #"linux-outputter";
+			   #"freebsd" => #"linux-outputter";
 			   otherwise => #f;
 			 end;
   end;

