1.0.39.15: delete all traces of the darwin dlshim
authorCyrus Harmon <ch-sbcl@bobobeach.com>
Sun, 13 Jun 2010 04:40:20 +0000 (04:40 +0000)
committerCyrus Harmon <ch-sbcl@bobobeach.com>
Sun, 13 Jun 2010 04:40:20 +0000 (04:40 +0000)
 * following up on previous commits which still used the shim with the
   :dlshim feature, now completely remover all traces of the dlshim.

src/code/foreign.lisp
src/compiler/generic/genesis.lisp
src/runtime/Config.ppc-darwin
src/runtime/Config.x86-64-darwin
src/runtime/Config.x86-darwin
src/runtime/darwin-dlshim.c [deleted file]
src/runtime/darwin-dlshim.h [deleted file]
src/runtime/darwin-os.c
tools-for-build/grovel-headers.c
tools-for-build/ldso-stubs.lisp
version.lisp-expr

index e81185d..cd83867 100644 (file)
@@ -16,8 +16,7 @@
 
 (defun extern-alien-name (name)
   (handler-case
-      #!+(or elf (and mach-o (not dlshim))) (coerce name 'base-string)
-      #!+(or (and mach-o dlshim) win32) (concatenate 'base-string "_" name)
+      (coerce name 'base-string)
     (error ()
       (error "invalid external alien name: ~S" name))))
 
   (let ((extern (extern-alien-name name)))
     (values
      (or (gethash extern table)
-         (gethash (concatenate 'base-string
-                               #!+(and mach-o dlshim) "_ldso_stub_"
-                               #!+(and mach-o (not dlshim)) "ldso_stub__"
-                               #!-mach-o "ldso_stub__"
-                               extern) table)))))
+         (gethash (concatenate 'base-string "ldso_stub__" extern) table)))))
 
 (defun find-foreign-symbol-address (name)
   "Returns the address of the foreign symbol NAME, or NIL. Does not enter the
index bfea5da..bbfca86 100644 (file)
@@ -1597,11 +1597,11 @@ core and return a descriptor to it."
                                 (subseq line (1+ p2)))
                         (values (parse-integer line :end p1 :radix 16)
                                 (subseq line (1+ p2))))
-                  ; KLUDGE CLH 2010-05-31: on darwin, nm gives us
+                  ;; KLUDGE CLH 2010-05-31: on darwin, nm gives us
                   ;; _function but dlsym expects us to look up
                   ;; function, without the leading _ . Therefore, we
                   ;; strip it off here.
-                  #!+(and darwin (not dlshim))
+                  #!+darwin
                   (when (equal (char name 0) #\_)
                     (setf name (subseq name 1)))
                   (multiple-value-bind (old-value found)
index 92089b5..0d3d79a 100644 (file)
@@ -13,9 +13,6 @@ CFLAGS = -g -Wall -O2 -fdollars-in-identifiers -mmacosx-version-min=10.4
 LINKFLAGS += -mmacosx-version-min=10.4
 
 OS_SRC = bsd-os.c darwin-os.c ppc-darwin-os.c
-ifdef LISP_FEATURE_DLSHIM
-  OS_SRC += darwin-dlshim.c
-endif
 
 OS_LIBS = -lSystem -lc
 
index d852f4b..24965f5 100644 (file)
@@ -22,9 +22,6 @@ CFLAGS += -D_DARWIN_USE_64_BIT_INODE
 endif
 
 OS_SRC = bsd-os.c x86-64-bsd-os.c darwin-os.c x86-64-darwin-os.c
-ifdef LISP_FEATURE_DLSHIM
-  OS_SRC += darwin-dlshim.c
-endif
 
 OS_LIBS = -lSystem -lc -ldl
 ifdef LISP_FEATURE_SB_THREAD
index 2ee81e1..c1a3eb7 100644 (file)
@@ -20,9 +20,6 @@ LINKFLAGS += -mmacosx-version-min=10.4
 endif
 
 OS_SRC = bsd-os.c x86-bsd-os.c darwin-os.c x86-darwin-os.c
-ifdef LISP_FEATURE_DLSHIM
-  OS_SRC += darwin-dlshim.c
-endif
 
 OS_LIBS = -lSystem -lc -ldl
 ifdef LISP_FEATURE_SB_THREAD
diff --git a/src/runtime/darwin-dlshim.c b/src/runtime/darwin-dlshim.c
deleted file mode 100644 (file)
index 05bd340..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * These functions emulate a small subset of the dlopen / dlsym
- * functionality under Darwin's Mach-O dyld system.
- */
-
-/*
- * 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 <mach-o/dyld.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "darwin-dlshim.h"
-
-/* Darwin does not define the standard ELF
- * dlopen/dlclose/dlsym/dlerror interface to shared libraries, so this
- * is an attempt at a minimal wrapper to allow SBCL to work without
- * external dependency on pogma's dlcompat library.
- */
-
-/* For now, there is no RTLD_GLOBAL emulation either. */
-
-static char dl_self; /* I'm going to abuse this */
-
-static int callback_count;
-static const struct mach_header* last_header;
-
-#define DLSYM_ERROR 1
-#define DLOPEN_ERROR 2
-
-static int last_error = 0;
-
-void
-dlshim_image_callback(const struct mach_header* ptr, intptr_t phooey)
-{
-    callback_count++;
-    last_header = ptr;
-}
-
-int
-lib_path_count(void)
-{
-    char* libpath;
-    int i;
-    int count;
-    libpath = getenv("DYLD_LIBRARY_PATH");
-    count = 1;
-    if (libpath) {
-        for (i = 0; libpath[i] != '\0'; i++) {
-            if (libpath[i] == ':') count++;
-        }
-    }
-    return count;
-}
-
-const char*
-lib_path_prefixify(int index, const char* filename)
-{
-    static char* retbuf = NULL;
-    int fi, li, i, count;
-    char* libpath;
-    if (!retbuf) {
-        retbuf = (char*) malloc(1024*sizeof(char));
-    }
-    count = 0;
-    fi = 0;
-    li = -1;
-    libpath = getenv("DYLD_LIBRARY_PATH");
-    if (libpath) {
-        i = 0;
-        while (count != index && libpath[i] != '\0') {
-            if (libpath[i] == ':') count++;
-            i++;
-        }
-        fi = i;
-        while (libpath[i] != '\0' && libpath[i] != ':') {
-            i++;
-        }
-        li = i - 1;
-    }
-    if (li - fi > 0) {
-        if (li - fi + 1 > 1022 - strlen(filename)) {
-            retbuf =
-                (char*) realloc(retbuf, (li - fi + 3 + strlen(filename))*sizeof(char));
-        }
-        memcpy(retbuf, libpath + fi, (li - fi + 1)*sizeof(char));
-        retbuf[li - fi + 1] = '/';
-        memcpy(retbuf + li - fi + 2, filename, strlen(filename) + 1);
-        return retbuf;
-    } else {
-        return filename;
-    }
-}
-
-const void*
-dlopen(const char* filename, int flags)
-{
-    static char has_callback = 0;
-    if (!has_callback) {
-        _dyld_register_func_for_add_image(dlshim_image_callback);
-    }
-    if (!filename) {
-        return &dl_self;
-    } else {
-        const struct mach_header* img = NULL;
-        if (!img)
-            img = NSAddImage(filename, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
-        if (!img)
-            img = NSAddImage(filename,
-                             NSADDIMAGE_OPTION_RETURN_ON_ERROR |
-                             NSADDIMAGE_OPTION_WITH_SEARCHING);
-        if (!img) {
-            NSObjectFileImage fileImage;
-            callback_count = 0;
-            last_header = NULL;
-            if (NSCreateObjectFileImageFromFile(filename, &fileImage)
-                == NSObjectFileImageSuccess) {
-                NSLinkModule(fileImage, filename,
-                             NSLINKMODULE_OPTION_BINDNOW |
-                             ((flags & RTLD_GLOBAL)?NSLINKMODULE_OPTION_PRIVATE:0) |
-                             NSLINKMODULE_OPTION_RETURN_ON_ERROR);
-                if (callback_count && last_header)
-                    img = last_header;
-            }
-        }
-        if (!img) {
-            NSObjectFileImage fileImage;
-            int i, maxi;
-            const char* prefixfilename;
-            maxi = lib_path_count();
-            for (i = 0; i < maxi && !img; i++) {
-                prefixfilename = lib_path_prefixify(i, filename);
-                callback_count = 0;
-                last_header = NULL;
-                if (NSCreateObjectFileImageFromFile(prefixfilename, &fileImage)
-                    == NSObjectFileImageSuccess) {
-                    NSLinkModule(fileImage, filename,
-                                 NSLINKMODULE_OPTION_BINDNOW |
-                                 ((flags & RTLD_GLOBAL)?NSLINKMODULE_OPTION_PRIVATE:0) |
-                                 NSLINKMODULE_OPTION_RETURN_ON_ERROR);
-                    if (callback_count && last_header)
-                        img = last_header;
-                }
-            }
-        }
-        if (img) {
-            if (flags & RTLD_NOW) {
-                NSLookupSymbolInImage(img, "",
-                                      NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_FULLY |
-                                      NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
-            }
-            if (NSIsSymbolNameDefinedInImage(img, "__init")) {
-                NSSymbol initsymbol;
-                void (*initfunc) (void);
-                initsymbol = NSLookupSymbolInImage(img, "__init", 0);
-                initfunc = NSAddressOfSymbol(initsymbol);
-                initfunc();
-            }
-        } else
-            last_error = DLOPEN_ERROR;
-        return img;
-    }
-}
-
-const char*
-dlerror()
-{
-    NSLinkEditErrors c;
-    int errorNumber;
-    const char *fileName, *errorString;
-    char *result = NULL;
-
-    if (last_error) {
-        NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
-        /* The errorString obtained by the above is too verbose for
-         * our needs, so we just translate the errno.
-         *
-         * We also have simple fallbacks in case we've somehow lost
-         * the context before this point. */
-        if (errorNumber) {
-            result = strerror(errorNumber);
-        } else if (DLSYM_ERROR == last_error) {
-            result = "dlsym(3) failed";
-        } else if (DLOPEN_ERROR == last_error) {
-            result = "dlopen(3) failed";
-        }
-        last_error = 0;
-    }
-
-    return result;
-}
-
-void*
-dlsym(void* handle, char* symbol)
-{
-    if (handle == &dl_self) {
-        if (NSIsSymbolNameDefined(symbol)) {
-            NSSymbol retsym;
-            retsym = NSLookupAndBindSymbol(symbol);
-            return NSAddressOfSymbol(retsym);
-        } else {
-            last_error = DLSYM_ERROR;
-            return NULL;
-        }
-    } else {
-        if (NSIsSymbolNameDefinedInImage(handle, symbol)) {
-            NSSymbol retsym;
-            retsym = NSLookupSymbolInImage(handle, symbol, 0);
-            return NSAddressOfSymbol(retsym);
-        } else {
-            last_error = DLSYM_ERROR;
-            return NULL;
-        }
-    }
-}
-
-int
-dlclose(void *handle)
-{
-    /* dlclose is not implemented, and never will be for dylibs.
-     * return -1 to signal an error; it's not used by SBCL anyhow */
-    return -1;
-}
diff --git a/src/runtime/darwin-dlshim.h b/src/runtime/darwin-dlshim.h
deleted file mode 100644 (file)
index 1c9128e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * These functions emulate a small subset of the dlopen / dlsym
- * functionality under Darwin's Mach-O dyld system.
- */
-
-/*
- * 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.
- */
-
-#ifndef PPC_DARWIN_DLSHIM_H
-#define PPC_DARWIN_DLSHIM_H
-
-#define RTLD_LAZY 1
-#define RTLD_NOW 2
-#define RTLD_GLOBAL 0x100
-
-#endif /* PPC_DARWIN_DLSHIM_H */
index 7bfc735..4a2bef6 100644 (file)
 #include <mach-o/dyld.h>
 #include "bsd-os.h"
 #include <errno.h>
-
-#ifndef LISP_FEATURE_DLSHIM
 #include <dlfcn.h>
-#endif
 
 char *
 os_get_runtime_executable_path(int external)
index 421f03c..e93b2e1 100644 (file)
   #include <sys/ioctl.h>
   #include <sys/termios.h>
   #include <langinfo.h>
-  #ifdef LISP_FEATURE_DLSHIM
-    #include "../src/runtime/darwin-dlshim.h"
-  #else
-    #include <dlfcn.h>
-  #endif
+  #include <dlfcn.h>
 #endif
 
 #include <sys/stat.h>
index 62eb528..5d9e0d7 100644 (file)
@@ -324,7 +324,6 @@ ldso_stub__ ## fct: ;                  \\
                    "unlockpt")
                  #!+openbsd
                  '("openpty")
-                 #!-dlshim
                  '("dlclose"
                    "dlerror"
                    "dlopen"
index b34242d..4a13d0d 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.39.14"
+"1.0.39.15"