X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fppc-linux-os.c;h=c2dc0199e872b2367dfb2adec90659c9df5b2405;hb=f0f3805c145f2699701997761e2c6f55c475c192;hp=fe22e41dc29f6ef5fe2fd20b7baf469901c5053c;hpb=52c61a5ea469c7766ff493f889625394c4038b9a;p=sbcl.git diff --git a/src/runtime/ppc-linux-os.c b/src/runtime/ppc-linux-os.c index fe22e41..c2dc019 100644 --- a/src/runtime/ppc-linux-os.c +++ b/src/runtime/ppc-linux-os.c @@ -42,6 +42,10 @@ size_t os_vm_page_size; int arch_os_thread_init(struct thread *thread) { +#if defined(LISP_FEATURE_SB_THREAD) + pthread_setspecific(specials,thread); +#endif + /* For some reason, PPC Linux appears to default to not generating * floating point exceptions. PR_SET_FPEXC is a PPC-specific * option new in kernel 2.4.21 and 2.5.32 that allows us to @@ -94,6 +98,34 @@ os_context_lr_addr(os_context_t *context) #endif } +os_context_register_t * +os_context_ctr_addr(os_context_t *context) +{ + /* Like os_context_fp_control() and os_context_lr_addr(), this + * uses an index beyond the declared end of the array in order to + * find the correct register value in the context. */ +#if defined(GLIBC231_STYLE_UCONTEXT) + /* FIXME: This probably should be ->ctr instead of ->gpr[PT_CTR]. */ + return &((context->uc_mcontext.regs)->gpr[PT_CTR]); +#elif defined(GLIBC232_STYLE_UCONTEXT) + return &((context->uc_mcontext.uc_regs)->gregs[PT_CTR]); +#endif +} + +os_context_register_t * +os_context_cr_addr(os_context_t *context) +{ + /* Like os_context_fp_control() and os_context_lr_addr(), this + * uses an index beyond the declared end of the array in order to + * find the correct register value in the context. */ +#if defined(GLIBC231_STYLE_UCONTEXT) + /* FIXME: This probably should be ->ccr instead of ->gpr[PT_CCR]. */ + return &((context->uc_mcontext.regs)->gpr[PT_CCR]); +#elif defined(GLIBC232_STYLE_UCONTEXT) + return &((context->uc_mcontext.uc_regs)->gregs[PT_CCR]); +#endif +} + sigset_t * os_context_sigmask_addr(os_context_t *context) { @@ -122,29 +154,21 @@ os_context_fp_control(os_context_t *context) void os_restore_fp_control(os_context_t *context) { - unsigned long control; + /* KLUDGE: mtfsf has to be run against a float register, so we + * construct the float we need to use as an integer, then cast + * a pointer to its storage to a double and load that. For + * this to work, control must be the same width as a double, + * 64 bits. And why aren't we using a union here, anyway? */ + unsigned long long control; double d; + /* FIXME: We are only preserving enabled traps and rounding + * mode here. Do we also want to preserve "fast mode"? */ control = os_context_fp_control(context) & - /* FIXME: Should we preserve the user's requested rounding mode? - - Note that doing - - ~(FLOAT_STICKY_BITS_MASK | FLOAT_EXCEPTIONS_BYTE_MASK) - - here leads to infinite SIGFPE for invalid operations, as - there are bits in the control register that need to be - cleared that are let through by that mask. -- CSR, 2002-07-16 */ - - FLOAT_TRAPS_BYTE_MASK; + (FLOAT_TRAPS_BYTE_MASK | FLOAT_ROUNDING_MODE_MASK); d = *((double *) &control); - /* Hmp. Apparently the following doesn't work either: - asm volatile ("mtfsf 0xff,%0" : : "f" (d)); - - causing segfaults at the first GC. - */ } void