(setf dlerror (dlerror)
(shared-object-sap obj) nil)))
(when dlerror
- (cerror dlerror))))
+ (cerror "Ignore the error and continue anyway" "dlerror returned an error: ~S" dlerror))))
(defun load-shared-object (file)
"Load a shared library/dynamic shared object file/general dlopenable
# -*- makefile -*-
CFLAGS = -Dppc -g -Wall -O2 -no-cpp-precomp
-OS_SRC = bsd-os.c os-common.c ppc-darwin-os.c ppc-darwin-dlshim.c
+OS_SRC = bsd-os.c os-common.c ppc-darwin-os.c ppc-darwin-dlshim.c ppc-darwin-langinfo.c
OS_LIBS = -lSystem -lc -lm
# Avoid the gcc 3.3 prerelease tarpit of death!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "ppc-darwin-dlshim.h"
/* Darwin does not define the standard ELF
* dlopen/dlclose/dlsym/dlerror interface to shared libraries, so this
static char dl_self; /* I'm going to abuse this */
-#define RTLD_LAZY 1
-#define RTLD_NOW 2
-#define RTLD_GLOBAL 0x100
-
static int callback_count;
static struct mach_header* last_header;
+static int last_was_error = 0;
void dlshim_image_callback(struct mach_header* ptr, unsigned long phooey)
{
if (!errbuf) {
errbuf = (char*) malloc(256*sizeof(char));
}
- snprintf(errbuf, 255, "%s in %s: %d %d", c, d, a, b);
- return errbuf;
+ if (!(c || d)) {
+ last_was_error = 0;
+ snprintf(errbuf, 255, "%s in %s: %d %d", c, d, a, b);
+ return errbuf;
+ } else if (last_was_error) {
+ last_was_error = 0;
+ snprintf(errbuf, 255, "Can't find symbol");
+ return errbuf;
+ }
+ last_was_error = 0;
+ return NULL;
}
void* dlsym(void* handle, char* symbol)
retsym = NSLookupAndBindSymbol(symbol);
return NSAddressOfSymbol(retsym);
} else {
+ last_was_error = 1;
return NULL;
}
} else {
retsym = NSLookupSymbolInImage(handle, symbol, 0);
return NSAddressOfSymbol(retsym);
} else {
+ last_was_error = 1;
return NULL;
}
}
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * This is a minimal nl_langinfo replacement that only handles CODESET.
+ * By default, it returns UTF-8. It checks if LC_CTYPE or LANG are set, and
+ * uses LATIN-1 if it finds one set to C, or UTF-8 if it finds one set to
+ * anything else.
+ */
+
+/*
+ * 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 <stdlib.h>
+#include "ppc-darwin-langinfo.h"
+
+char *nl_langinfo(nl_item item)
+{
+ char *nada = "", *utf8 = "UTF-8", *latin1 = "LATIN-1";
+
+ if (item != CODESET) {
+ return nada;
+ } else {
+ char *ctype = getenv ("LC_CTYPE");
+
+ if ((ctype != NULL) && (!strcmp(ctype, "C"))) {
+ return latin1;
+ } else if (ctype != NULL) {
+ return utf8;
+ } else {
+ char *lang = getenv ("LANG");
+
+ if ((lang != NULL) && (!strcmp(lang, "C"))) {
+ return latin1;
+ } else {
+ return utf8;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * 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_LANGINFO_H
+#define PPC_DARWIN_LANGINFO_H
+
+#define CODESET 49
+
+typedef int nl_item;
+char *nl_langinfo (nl_item);
+
+#endif /* PPC_DARWIN_LANGINFO_H */
#include <unistd.h>
#include <signal.h>
#include <errno.h>
-#include <dlfcn.h>
-#include <langinfo.h>
+#ifdef __APPLE_CC__
+ #include "../src/runtime/ppc-darwin-dlshim.h"
+ #include "../src/runtime/ppc-darwin-langinfo.h"
+#else
+ #include <dlfcn.h>
+ #include <langinfo.h>
+#endif
#include "genesis/config.h"
;;; 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".)
-"0.8.17.30"
+"0.8.17.31"