;;;; -*- coding: utf-8; -*-
changes in sbcl-0.9.11 relative to sbcl-0.9.10:
+ * new port: SBCL now works on x86/Darwin, including MacOS X 10.4.5
+ on Intel.
* new feature: Unicode character names are now known to the system
(through CHAR-NAME and NAME-CHAR).
* bug fix: as implied by AMOP, standardized classes no longer have
if [ "$sbcl_arch" = "x86" ]; then
printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
printf ' :stack-allocatable-closures :alien-callbacks' >> $ltf
- if [ "$sbcl_os" = "linux" ] || [ "$sbcl_os" = "freebsd" ] || [ "$sbcl_os" = "netbsd" ] || [ "$sbcl_os" = "sunos" ]; then
+ if [ "$sbcl_os" = "linux" ] || [ "$sbcl_os" = "freebsd" ] || [ "$sbcl_os" = "netbsd" ] || [ "$sbcl_os" = "sunos" ] || [ "$sbcl_os" = "darwin" ]; then
printf ' :linkage-table' >> $ltf
fi
if [ "$sbcl_os" = "win32" ]; then
(error "Something is broken.")))
(lvar (node-lvar call))
(args args)
- #!+win32 (stack-pointer (make-stack-pointer-tn)))
+ #!+(or (and x86 darwin) win32) (stack-pointer (make-stack-pointer-tn)))
(multiple-value-bind (nsp stack-frame-size arg-tns result-tns)
(make-call-out-tns type)
#!+x86 (vop set-fpu-word-for-c call block)
- #!+win32 (vop current-stack-pointer call block stack-pointer)
+ #!+(or (and x86 darwin) win32) (vop current-stack-pointer call block stack-pointer)
(vop alloc-number-stack-space call block stack-frame-size nsp)
(dolist (tn arg-tns)
;; On PPC, TN might be a list. This is used to indicate
((lvar-tn call block function)
(reference-tn-list arg-tns nil))
((reference-tn-list result-tns t))))
- #!-win32 (vop dealloc-number-stack-space call block stack-frame-size)
- #!+win32 (vop reset-stack-pointer call block stack-pointer)
+ #!-(or (and darwin x86) win32) (vop dealloc-number-stack-space call block stack-frame-size)
+ #!+(or (and darwin x86) win32) (vop reset-stack-pointer call block stack-pointer)
#!+x86 (vop set-fpu-word-for-lisp call block)
(move-lvar-result call block result-tns lvar))))
(unless (zerop amount)
(let ((delta (logandc2 (+ amount 3) 3)))
(inst sub esp-tn delta)))
+ ;; C stack should probably be 16 byte aligned on Darwin
+ #!+darwin (inst and esp-tn -16)
(move result esp-tn)))
(define-vop (dealloc-number-stack-space)
(def!constant linkage-table-space-start #xA0000000)
(def!constant linkage-table-space-end #xA1000000))
+
+#!+darwin
+(progn
+ (def!constant read-only-space-start #x01000000)
+ (def!constant read-only-space-end #x04ff8000)
+
+ (def!constant static-space-start #x08000000)
+ (def!constant static-space-end #x097fff00)
+
+ (def!constant dynamic-space-start #x10000000)
+ (def!constant dynamic-space-end #x6ffff000)
+
+ (def!constant linkage-table-space-start #x0a000000)
+ (def!constant linkage-table-space-end #x0b000000))
+
;;; Size of one linkage-table entry in bytes.
(def!constant linkage-table-entry-size 8)
:from :eval
:to (:result 0))
eax)
+ #!+darwin (:temporary (:sc unsigned-reg
+ :offset esi-offset)
+ prev-stack-pointer)
(:results (result :scs (descriptor-reg)))
(:save-p t)
(:generator 100
- (inst push object)
+ ;; the stack should be 16-byte aligned on Darwin
+ #!-darwin (inst push object)
+ #!+darwin (progn (inst mov prev-stack-pointer esp-tn)
+ (inst sub esp-tn n-word-bytes)
+ (inst and esp-tn -16)
+ (storew object esp-tn))
(inst lea eax (make-fixup "debug_print" :foreign))
(inst call (make-fixup "call_into_c" :foreign))
- (inst add esp-tn n-word-bytes)
+ #!-darwin (inst add esp-tn n-word-bytes)
+ #!+darwin (inst mov esp-tn prev-stack-pointer)
(move result eax)))
# files for more information.
CFLAGS = -g -Wall -O2 -fdollars-in-identifiers
-OS_SRC = bsd-os.c ppc-darwin-os.c ppc-darwin-dlshim.c ppc-darwin-langinfo.c
+OS_SRC = bsd-os.c darwin-os.c ppc-darwin-os.c ppc-darwin-dlshim.c ppc-darwin-langinfo.c
OS_LIBS = -lSystem -lc
OS_OBJS = ppc-darwin-rospace.o
--- /dev/null
+# -*- 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.
+
+CFLAGS = -g -Wall -O2 -fdollars-in-identifiers
+OS_SRC = bsd-os.c x86-bsd-os.c darwin-os.c ppc-darwin-dlshim.c x86-darwin-langinfo.c
+OS_LIBS = -lSystem -lc -ldl
+OS_OBJS = x86-darwin-rospace.o
+
+CC = gcc
+
+ASSEM_SRC = x86-assem.S ldso-stubs.S
+ARCH_SRC = x86-arch.c
+
+CPPFLAGS += -no-cpp-precomp
+
+# KLUDGE: in OS X 10.3, Apple started putting the heap right where we
+# expect our read-only space mapped. This hack causes the linker to
+# place a zero-fill-on-demand segment in the same place and size as
+# read-only-space, which is the only thing capable of keeping malloc
+# out of this range.
+LINKFLAGS += -dynamic `cat x86-darwin-link-flags` -twolevel_namespace -bind_at_load
+
+GC_SRC = gencgc.c
+
+OS_CLEAN_FILES += x86-darwin-mkrospace x86-darwin-fix-rospace x86-darwin-link-flags
+
+x86-darwin-mkrospace: x86-darwin-mkrospace.c
+ $(CC) -g -Wall -pedantic -o $@ $<
+
+x86-darwin-fix-rospace: x86-darwin-fix-rospace.c
+ $(CC) -g -Wall -pedantic -o $@ $<
+
+x86-darwin-rospace.o x86-darwin-link-flags: x86-darwin-mkrospace
+ ./x86-darwin-mkrospace > x86-darwin-link-flags
+
+.PHONY: after-grovel-headers
+
+# Fix the sbcl runtime to avoid Panther placing the heap where
+# it wants read only space (in the first 32 megabytes, where it
+# can be absolute-branched to with BA.) Must be done after
+# grovel-headers, because Apple's nm is broken.
+after-grovel-headers: x86-darwin-fix-rospace
+ ./x86-darwin-fix-rospace
+
+# Fortunatly make-target-1.sh does a make clean all the time.
+# Otherwise we would have to make sure that sbcl gets rebuilt without
+# the readonlyspace hack before groveling headers again.
static void freebsd_init();
#endif /* __FreeBSD__ */
+#if defined(LISP_FEATURE_DARWIN) && defined(LISP_FEATURE_X86)
+static void x86_darwin_init();
+#endif
+
void
os_init(char *argv[], char *envp[])
{
#ifdef __FreeBSD__
freebsd_init();
#endif /* __FreeBSD__ */
+#if defined(LISP_FEATURE_DARWIN) && defined(LISP_FEATURE_X86)
+ x86_darwin_init();
+#endif
}
int *os_context_pc_addr(os_context_t *context)
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
/* (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__) || defined(__NetBSD__) || defined(LISP_FEATURE_DARWIN)
return &context->uc_sigmask;
-#elif defined __OpenBSD__
+#elif defined (__OpenBSD__)
return &context->sc_mask;
#else
#error unsupported BSD variant
os_context_t *context = arch_os_get_context(&void_context);
void *fault_addr = arch_get_bad_addr(signal, siginfo, context);
+#if defined(MEMORY_FAULT_DEBUG)
+ fprintf(stderr, "Memory fault at: %p, PC: %x\n", fault_addr, *os_context_pc_addr(context));
+#if defined(ARCH_HAS_STACK_POINTER)
+ fprintf(stderr, "Stack pointer: %x\n", *os_context_sp_addr(context));
+#endif
+#endif
+
if (!gencgc_handle_wp_violation(fault_addr))
if(!handle_guard_page_triggered(context,fault_addr)) {
#ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
}
#endif
+#if defined(LISP_FEATURE_DARWIN) && defined(LISP_FEATURE_X86)
+static void x86_darwin_init()
+{
+ struct sigaltstack sigstack;
+ sigstack.ss_sp = os_allocate(32*SIGSTKSZ);
+ if (sigstack.ss_sp) {
+ sigstack.ss_flags=0;
+ sigstack.ss_size = 32*SIGSTKSZ;
+ sigaltstack(&sigstack,0);
+ }
+}
+#endif
+
#ifdef LISP_FEATURE_DARWIN
/* defined in ppc-darwin-os.c instead */
#elif defined(LISP_FEATURE_FREEBSD)
If Apple is going to break ucontext_t out of spite, I'm going
to be cross with them ;) -- PRM */
+#if defined(LISP_FEATURE_X86)
+#include <sys/ucontext.h>
+#include <sys/_types.h>
+typedef struct ucontext os_context_t;
+#else
#include <ucontext.h>
typedef ucontext_t os_context_t;
+#endif
+
#define SIG_MEMORY_FAULT SIGBUS
#else
--- /dev/null
+/*
+ * This is the Darwin incarnation of OS-dependent routines. See also
+ * "bsd-os.c".
+ */
+
+/*
+ * 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 "sbcl.h"
+#include "globals.h"
+#include "runtime.h"
+#include <signal.h>
+#include <ucontext.h>
+#include <limits.h>
+#include <mach-o/dyld.h>
+#include "bsd-os.h"
+
+char *
+os_get_runtime_executable_path()
+{
+ char path[PATH_MAX + 1];
+ uint32_t size = sizeof(path);
+
+ if (_NSGetExecutablePath(path, &size) == -1)
+ return NULL;
+ else
+ path[size] = '\0';
+
+ return copied_string(path);
+}
ppc_flush_icache(address,length);
}
-char *
-os_get_runtime_executable_path()
-{
- char path[PATH_MAX + 1];
- uint32_t size = sizeof(path);
-
- if (_NSGetExecutablePath(path, &size) == -1)
- return NULL;
- else
- path[size] = '\0';
-
- return copied_string(path);
-}
* problem.. */
#define QSHOW_SIGNALS 0
-#ifdef QSHOW_SIGNALS
+#if QSHOW_SIGNALS
#define FSHOW_SIGNAL FSHOW
#else
#define FSHOW_SIGNAL(args)
return &context->uc_mcontext.mc_eflags;
#elif defined __OpenBSD__
return &context->sc_eflags;
+#elif defined LISP_FEATURE_DARWIN
+ return &context->uc_mcontext->ss.eflags;
#elif defined __NetBSD__
return &(context->uc_mcontext.__gregs[_REG_EFL]);
#elif defined LISP_FEATURE_WIN32
* number of bytes will follow, the first is the length of the byte
* arguments to follow. */
trap = *(unsigned char *)(*os_context_pc_addr(context));
+ /* FSHOW((stderr, "/<sigtrap trap %d at pc_addr: %p>\n", trap, *os_context_pc_addr(context))); */
switch (trap) {
case trap_PendingInterrupt:
#define GNAME(var) _##var
#endif
+#if defined __linux__ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __sun
+#define GNAMEDOLLAR(var) $##var
+#else
+#define GNAMEDOLLAR(var) $_##var
+#endif
+
+#if defined __linux__ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __sun
+#define DOLLARLITERAL(var) $##var
+#else
+#define DOLLARLITERAL(var) $##(var)
+#endif
+
/* Get the right type of alignment. Linux, FreeBSD and NetBSD (but not OpenBSD)
* want alignment in bytes.
*
* that are defined to be no-ops on win32. Hopefully this still works on
* other platforms.
*/
-#ifndef LISP_FEATURE_WIN32
+#if !defined(LISP_FEATURE_WIN32) && !defined(LISP_FEATURE_DARWIN)
#define TYPE(name) .type name,@function
#define SIZE(name) .size name,.-name
#else
#define SIZE(name)
#endif
+#if defined(LISP_FEATURE_DARWIN)
+#define END()
+#else
+#define END() .end
+#endif
+
.text
- .global GNAME(foreign_function_call_active)
- .global GNAME(all_threads)
+ .globl GNAME(foreign_function_call_active)
+ .globl GNAME(all_threads)
\f
/*
* A call to call_into_c preserves esi, edi, and ebp.
*/
.text
.align align_16byte,0x90
- .global GNAME(call_into_c)
+ .globl GNAME(call_into_c)
TYPE(GNAME(call_into_c))
GNAME(call_into_c):
movl $1,GNAME(foreign_function_call_active)
cld
#endif
+#ifdef LISP_FEATURE_DARWIN
+ andl $0xfffffff0,%esp # align stack to 16-byte boundary before calling C
+#endif
call *%eax # normal callout using Lisp stack
movl %eax,%ecx # remember integer return value
\f
.text
- .global GNAME(call_into_lisp_first_time)
+ .globl GNAME(call_into_lisp_first_time)
TYPE(GNAME(call_into_lisp_first_time))
/* The *ALIEN-STACK* pointer is set up on the first call_into_lisp when
movl THREAD_CONTROL_STACK_START_OFFSET(%eax) ,%esp
/* don't think too hard about what happens if we get interrupted
* here */
- addl $THREAD_CONTROL_STACK_SIZE-4,%esp
+ addl DOLLARLITERAL(THREAD_CONTROL_STACK_SIZE),%esp
#else
/* Win32 -really- doesn't like you switching stacks out from under it. */
movl GNAME(all_threads),%eax
jmp Lstack
\f
.text
- .global GNAME(call_into_lisp)
+ .globl GNAME(call_into_lisp)
TYPE(GNAME(call_into_lisp))
/* The C conventions require that ebx, esi, edi, and ebp be preserved
\f
/* support for saving and restoring the NPX state from C */
.text
- .global GNAME(fpu_save)
+ .globl GNAME(fpu_save)
TYPE(GNAME(fpu_save))
.align 2,0x90
GNAME(fpu_save):
ret
SIZE(GNAME(fpu_save))
- .global GNAME(fpu_restore)
+ .globl GNAME(fpu_restore)
TYPE(GNAME(fpu_restore))
.align 2,0x90
GNAME(fpu_restore):
*/
.text
.align align_4byte,0x90
- .global GNAME(undefined_tramp)
+ .globl GNAME(undefined_tramp)
TYPE(GNAME(undefined_tramp))
.byte 0, 0, 0, SIMPLE_FUN_HEADER_WIDETAG
GNAME(undefined_tramp):
*/
.text
.align align_4byte,0x90
- .global GNAME(closure_tramp)
+ .globl GNAME(closure_tramp)
TYPE(GNAME(closure_tramp))
.byte 0, 0, 0, SIMPLE_FUN_HEADER_WIDETAG
GNAME(closure_tramp):
* fun-end breakpoint magic
*/
.text
- .global GNAME(fun_end_breakpoint_guts)
+ .globl GNAME(fun_end_breakpoint_guts)
.align align_4byte
GNAME(fun_end_breakpoint_guts):
/* Multiple Value return */
movl %esp,%ebx # Setup ebx - the ofp.
subl $4,%esp # Allocate one stack slot for the return value
movl $4,%ecx # Setup ecx for one return value.
- movl $NIL,%edi # default second value
- movl $NIL,%esi # default third value
+ movl DOLLARLITERAL(NIL),%edi # default second value
+ movl DOLLARLITERAL(NIL),%esi # default third value
multiple_value_return:
- .global GNAME(fun_end_breakpoint_trap)
+ .globl GNAME(fun_end_breakpoint_trap)
GNAME(fun_end_breakpoint_trap):
int3
.byte trap_FunEndBreakpoint
hlt # We should never return here.
- .global GNAME(fun_end_breakpoint_end)
+ .globl GNAME(fun_end_breakpoint_end)
GNAME(fun_end_breakpoint_end):
\f
- .global GNAME(do_pending_interrupt)
+ .globl GNAME(do_pending_interrupt)
TYPE(GNAME(do_pending_interrupt))
.align align_4byte,0x90
GNAME(do_pending_interrupt):
* This is part of the funky magic for exception handling on win32.
* see sigtrap_emulator() in win32-os.c for details.
*/
- .global GNAME(sigtrap_trampoline)
+ .globl GNAME(sigtrap_trampoline)
GNAME(sigtrap_trampoline):
pushl %eax
pushl %ebp
* This is part of the funky magic for exception handling on win32.
* see handle_exception() in win32-os.c for details.
*/
- .global GNAME(exception_trampoline)
+ .globl GNAME(exception_trampoline)
GNAME(exception_trampoline):
pushl %eax
pushl %ebp
* to use.
*/
\f
- .global GNAME(fast_bzero_pointer)
+ .globl GNAME(fast_bzero_pointer)
.data
- .align 4
+ .align align_4byte
GNAME(fast_bzero_pointer):
/* Variable containing a pointer to the bzero function to use.
* Initially points to a basic function. Change this variable
\f
.text
.align align_8byte,0x90
- .global GNAME(fast_bzero)
+ .globl GNAME(fast_bzero)
TYPE(GNAME(fast_bzero))
GNAME(fast_bzero):
/* Indirect function call */
\f
.text
.align align_8byte,0x90
- .global GNAME(fast_bzero_detect)
+ .globl GNAME(fast_bzero_detect)
TYPE(GNAME(fast_bzero_detect))
GNAME(fast_bzero_detect):
/* Decide whether to use SSE, MMX or REP version */
* for all non-SSE2 processors.
*/
Lbase:
- movl $GNAME(fast_bzero_base), GNAME(fast_bzero_pointer)
+ movl GNAMEDOLLAR(fast_bzero_base), GNAME(fast_bzero_pointer)
jmp Lrestore
Lsse2:
- movl $GNAME(fast_bzero_sse), GNAME(fast_bzero_pointer)
+ movl GNAMEDOLLAR(fast_bzero_sse), GNAME(fast_bzero_pointer)
jmp Lrestore
Lrestore:
\f
.text
.align align_8byte,0x90
- .global GNAME(fast_bzero_sse)
+ .globl GNAME(fast_bzero_sse)
TYPE(GNAME(fast_bzero_sse))
GNAME(fast_bzero_sse):
movups %xmm7, -16(%esp) /* Save XMM register */
xorps %xmm7, %xmm7 /* Zero the XMM register */
jmp Lloop_sse
- .align 16
+ .align align_16byte
Lloop_sse:
/* Copy the 16 zeroes from xmm7 to memory, 4 times. MOVNTDQ is the
\f
.text
.align align_8byte,0x90
- .global GNAME(fast_bzero_base)
+ .globl GNAME(fast_bzero_base)
TYPE(GNAME(fast_bzero_base))
GNAME(fast_bzero_base):
shr $2, %ecx /* Amount of 4-byte blocks to copy */
jz Lend_base
cld /* Set direction of STOSL to increment */
- rep stosl /* Store EAX to *EDI, ECX times, incrementing
+
+ rep
+ stosl /* Store EAX to *EDI, ECX times, incrementing
* EDI by 4 after each store */
+
Lend_base:
pop %edi /* Restore temp registers */
pop %ecx
SIZE(GNAME(fast_bzero_base))
\f
- .end
+ END()
+
\ No newline at end of file
* 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(LISP_FEATURE_DARWIN)
int *
os_context_register_addr(os_context_t *context, int offset)
{
* 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__
+#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])
--- /dev/null
+/* ppc-darwin-fix-rospace.c - fix the segment and section output by ppc-darwin-mkrospace.c to have the correct size */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <mach-o/loader.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "sbcl.h"
+#include "runtime.h"
+
+#include "ppc-darwin-spacelist.h"
+
+int main(int argc, char** argv)
+{
+ int fd;
+ int i, spacei;
+ struct stat filestat;
+ struct mach_header *header;
+ void* file_pointer;
+ size_t filesize;
+ size_t old_commands_size;
+ char* window;
+ size_t segments_size;
+
+ /* Open the SBCL binary */
+ fd = open("sbcl", O_RDWR, 0); /* wr unx prgrmmrs, we cn't spll */
+ if (fd == -1) {
+ perror(argv[0]);
+ return -1;
+ }
+ if (fstat(fd, &filestat) == -1) {
+ close(fd);
+ perror(argv[0]);
+ return -1;
+ }
+ filesize = filestat.st_size;
+ if ((int) (file_pointer = mmap(NULL, filesize, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0)) == -1) {
+ perror(argv[0]);
+ close(fd);
+ return -1;
+ }
+
+ segments_size = 0;
+ spacei = 0;
+ header = (struct mach_header*) file_pointer;
+ window = (char*) (header + 1);
+ for (i = 0; i < header->ncmds; i++) {
+ struct load_command* current_segment;
+ current_segment = (struct load_command*) window;
+ segments_size += current_segment->cmdsize;
+ window += current_segment->cmdsize;
+ if (current_segment->cmd == LC_SEGMENT) {
+ int is_sbcl;
+ struct segment_command* seg = (struct segment_command*) current_segment;
+ struct section* sectptr;
+ int j, max;
+ max = seg->nsects;
+ if (strncmp("SBCL", seg->segname, 4) == 0) {
+ is_sbcl = 1;
+ seg->vmsize = space_sizes[spacei];
+ } else {
+ is_sbcl = 0;
+ }
+ seg++;
+ sectptr = (struct section*) seg;
+ for (j = 0; j < max; j++) {
+ if (is_sbcl) {
+ sectptr->size = space_sizes[spacei];
+ spacei++;
+ }
+ sectptr++;
+ }
+ }
+ }
+
+ munmap(file_pointer, filesize);
+ close(fd);
+ return 0;
+}
--- /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
+/* x86-darwin-mkrospace.c - write a .o which makes sure we get our desired address range */
+
+#include <stdlib.h>
+#include <string.h>
+#include <mach-o/loader.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+#include "sbcl.h"
+#include "runtime.h"
+
+#include "x86-darwin-spacelist.h"
+
+struct simple_object_file
+{
+ struct segment_command thesegment;
+ struct section thesection;
+};
+
+int main(int argc, char** argv)
+{
+ struct mach_header *theheader;
+ struct simple_object_file *theobj;
+ int fd, i;
+
+ /* Produce the mach header */
+ theheader = (struct mach_header*) malloc(sizeof(struct mach_header));
+ theheader->magic = MH_MAGIC;
+ theheader->cputype = CPU_TYPE_X86;
+ theheader->cpusubtype = CPU_SUBTYPE_I386_ALL;
+ theheader->filetype = MH_OBJECT;
+ theheader->ncmds = N_SEGMENTS_TO_PRODUCE;
+ theheader->sizeofcmds = N_SEGMENTS_TO_PRODUCE * (sizeof(struct segment_command) + sizeof(struct section));
+ theheader->flags = MH_NOUNDEFS;
+ printf("-Wl");
+ fd = open("x86-darwin-rospace.o", O_WRONLY | O_CREAT, 0644);
+ write(fd, theheader, sizeof(struct mach_header));
+
+ for (i = 0; i < N_SEGMENTS_TO_PRODUCE; i++) {
+ theobj = (struct simple_object_file*) malloc(sizeof(struct simple_object_file));
+ theobj->thesegment.cmd = LC_SEGMENT;
+ theobj->thesegment.cmdsize = sizeof(struct segment_command) + sizeof(struct section);
+ snprintf(theobj->thesegment.segname, 7, "SBCL%d", i);
+ theobj->thesegment.fileoff = sizeof(struct mach_header) + i * (sizeof(struct segment_command) + sizeof(struct section));
+ theobj->thesegment.vmaddr = space_start_locations[i];
+ theobj->thesegment.vmsize = 0;
+ theobj->thesegment.maxprot = VM_PROT_ALL;
+ theobj->thesegment.initprot = VM_PROT_ALL;
+ theobj->thesegment.nsects = 1;
+ theobj->thesegment.flags = 0;
+ snprintf(theobj->thesection.sectname, 7, "sect%d", i);
+ snprintf(theobj->thesection.segname, 7, "SBCL%d", i);
+ theobj->thesection.addr = space_start_locations[i];
+ theobj->thesection.size = 0;
+ theobj->thesection.offset = 0;
+ theobj->thesection.align = 0;
+ theobj->thesection.reloff = 0;
+ theobj->thesection.nreloc = 0;
+ theobj->thesection.flags = S_ZEROFILL | S_REGULAR | S_ATTR_SOME_INSTRUCTIONS;
+ theobj->thesection.reserved1 = 0;
+ theobj->thesection.reserved2 = 0;
+ write(fd, theobj, sizeof(struct simple_object_file));
+ printf(",-segaddr,SBCL%d,0x%x", i, space_start_locations[i]);
+ free(theobj);
+ }
+ printf("\n");
+ close(fd);
+ return 0;
+}
--- /dev/null
+#ifndef _X86_DARWIN_OS_H
+#define _X86_DARWIN_OS_H
+
+static inline os_context_t *arch_os_get_context(void **void_context) {
+ return (os_context_t *) *void_context;
+}
+
+#define CONTEXT_ADDR_FROM_STEM(stem) &context->uc_mcontext->ss.stem
+#define DARWIN_FIX_CONTEXT(context)
+
+#endif /* _X86_DARWIN_OS_H */
--- /dev/null
+#ifndef PPC_DARWIN_SPACELIST_H
+#define PPC_DARWIN_SPACELIST_H
+
+#if defined(LISP_FEATURE_GENCGC)
+#define N_SEGMENTS_TO_PRODUCE 4
+#else
+#define N_SEGMENTS_TO_PRODUCE 5
+#endif
+
+unsigned int space_start_locations[N_SEGMENTS_TO_PRODUCE] =
+ { READ_ONLY_SPACE_START, STATIC_SPACE_START,
+#if defined(LISP_FEATURE_GENCGC)
+ DYNAMIC_SPACE_START,
+#else
+ DYNAMIC_0_SPACE_START, DYNAMIC_1_SPACE_START,
+#endif
+ LINKAGE_TABLE_SPACE_START};
+
+unsigned int space_sizes[N_SEGMENTS_TO_PRODUCE] =
+ { READ_ONLY_SPACE_END - READ_ONLY_SPACE_START,
+ STATIC_SPACE_END - STATIC_SPACE_START,
+#if defined(LISP_FEATURE_GENCGC)
+ DYNAMIC_SPACE_END - DYNAMIC_SPACE_START,
+#else
+ DYNAMIC_0_SPACE_END - DYNAMIC_0_SPACE_START,
+ DYNAMIC_1_SPACE_END - DYNAMIC_1_SPACE_START,
+#endif
+ LINKAGE_TABLE_SPACE_END - LINKAGE_TABLE_SPACE_START};
+
+#endif
;;; This is not a WITH-TEST :FAILS-ON PPC DARWIN since there are
;;; suspicions that the breakpoint trace might corrupt the whole image
;;; on that platform.
-#-(and ppc darwin)
+#-(and (or ppc x86) darwin)
(with-test (:name (trace :encapsulate nil)
:fails-on '(or ppc sparc))
(let ((out (with-output-to-string (*trace-output*)
(assert (= 0.0d0 (scale-float 1.0d0 (1- most-negative-fixnum))))
(with-test (:name (:scale-float-overflow :bug-372)
- :fails-on '(or :ppc :freebsd)) ;; bug 372
+ :fails-on '(or :ppc :darwin :freebsd)) ;; bug 372
(progn
(assert (raises-error? (scale-float 1.0 most-positive-fixnum)
floating-point-overflow))
'double-float))
(with-test (:name (:addition-overflow :bug-372)
- :fails-on '(or :ppc :mips :freebsd))
+ :fails-on '(or :ppc :darwin :mips :freebsd))
(assert (typep (nth-value
1
(ignore-errors
#endif
.text"
-#!+(or x86 x86-64) "
+#!+(or (and x86 (not darwin)) x86-64) "
#define LDSO_STUBIFY(fct) \\
.align 16 ; \\
.globl ldso_stub__ ## fct ; \\
.indirect_symbol _ ## fct @\\
.long dyld_stub_binding_helper"
+;;; darwin x86 assembler is weird and follows the ppc assembler syntax
+#!+(and darwin x86) "
+#define LDSO_STUBIFY(fct) \\
+.text ; \\
+ .align 4 ; \\
+.globl ldso_stub___ ## fct ; \\
+ldso_stub___ ## fct: ; \\
+ jmp L ## fct ## $stub ; \\
+ .section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5 ; \\
+L ## fct ## $stub: ; \\
+ .indirect_symbol _ ## fct ; \\
+ hlt ; \\
+ hlt ; \\
+ hlt ; \\
+ hlt ; \\
+ hlt ; \\
+ .subsections_via_symbols ; "
+
;;; KLUDGE: set up the vital fifth argument, passed on the
;;; stack. Do this unconditionally, even if the stub is for a
;;; function with few arguments: it can't hurt. We only do this for
;;; 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.9.10.15"
+"0.9.10.16"