0.7.12.51
[sbcl.git] / src / runtime / x86-linux-os.c
index 7c14c44..30a44da 100644 (file)
@@ -1,10 +1,18 @@
 /*
  * The x86 Linux incarnation of arch-dependent OS-dependent routines.
- * See also linux-os.c
+ * See also "linux-os.c".
  */
 
-
-/* header files lifted wholesale from linux-os.c, some may be redundant */
+/*
+ * 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 <stdio.h>
 #include <sys/param.h>
 #include "validate.h"
 size_t os_vm_page_size;
 
-#if defined GENCGC
-#include "gencgc.h"
-#endif
 
 /* KLUDGE: As of kernel 2.2.14 on Red Hat 6.2, there's code in the
  * <sys/ucontext.h> file to define symbolic names for offsets into
  * gregs[], but it's conditional on __USE_GNU and not defined, so
  * we need to do this nasty absolute index magic number thing
  * instead. */
-register_t *
+os_context_register_t *
 os_context_register_addr(os_context_t *context, int offset)
 {
     switch(offset) {
@@ -55,15 +60,30 @@ os_context_register_addr(os_context_t *context, int offset)
     }
     return &context->uc_mcontext.gregs[offset];
 }
-register_t *
+
+os_context_register_t *
 os_context_pc_addr(os_context_t *context)
 {
-    return &context->uc_mcontext.gregs[14];
+    return &context->uc_mcontext.gregs[14]; /*  REG_EIP */
 }
-register_t *
+
+os_context_register_t *
 os_context_sp_addr(os_context_t *context)
+{                              
+    return &context->uc_mcontext.gregs[17]; /* REG_UESP */
+}
+
+os_context_register_t *
+os_context_fp_addr(os_context_t *context)
 {
-    return &context->uc_mcontext.gregs[17];
+    return &context->uc_mcontext.gregs[6]; /* REG_EBP */
+}
+
+unsigned long
+os_context_fp_control(os_context_t *context)
+{
+    return ((((context->uc_mcontext.fpregs->cw) & 0xffff) ^ 0x3f) |
+           (((context->uc_mcontext.fpregs->sw) & 0xffff) << 16));
 }
 
 sigset_t *
@@ -73,6 +93,12 @@ os_context_sigmask_addr(os_context_t *context)
 }
 
 void
+os_restore_fp_control(os_context_t *context)
+{
+    asm ("fldcw %0" : : "m" (context->uc_mcontext.fpregs->cw));
+}
+
+void
 os_flush_icache(os_vm_address_t address, os_vm_size_t length)
 {
 }