master: freebsd-ppc64: add missing FP functions
stassats via Sbcl-commits <[email protected]> Mon, 04 May 2026 14:18:27 +0000
| Newsgroups | gmane.lisp.steel-bank.cvs |
|---|---|
| Message-ID | <[email protected]> |
The branch "master" has been updated in SBCL:
via acd0f7e95afd60d0c3241cf8b7c7a02677b30514 (commit)
from 0f4366f0eee15198c5e2c5e2d4ec06bd709d67c0 (commit)
- Log -----------------------------------------------------------------
commit acd0f7e95afd60d0c3241cf8b7c7a02677b30514
Author: Piotr Kubaj <[email protected]>
Date: Mon May 4 15:19:57 2026 +0200
freebsd-ppc64: add missing FP functions
---
src/runtime/ppc-bsd-os.c | 28 ++++++++++++++++++++++++++++
src/runtime/ppc-bsd-os.h | 6 ++++++
2 files changed, 34 insertions(+)
diff --git a/src/runtime/ppc-bsd-os.c b/src/runtime/ppc-bsd-os.c
index 5e488d86f..54dabb3ab 100644
--- a/src/runtime/ppc-bsd-os.c
+++ b/src/runtime/ppc-bsd-os.c
@@ -67,6 +67,34 @@ os_context_cr_addr(os_context_t *context)
#endif
}
+#ifdef LISP_FEATURE_FREEBSD
+os_context_register_t *
+os_context_float_register_addr(os_context_t *context, int offset)
+{
+ return (os_context_register_t *)&context->uc_mcontext.mc_fpreg[offset];
+}
+
+unsigned long
+os_context_fp_control(os_context_t *context)
+{
+ return context->uc_mcontext.mc_fpreg[32];
+}
+
+void
+os_restore_fp_control(os_context_t *context)
+{
+ unsigned long long control;
+ double d;
+ control = os_context_fp_control(context) &
+ (FLOAT_TRAPS_BYTE_MASK | FLOAT_ROUNDING_MODE_MASK);
+ /* Clear exception bits from the saved context so sigreturn doesn't
+ * restore OX=1 + OE=1 which would re-trigger SIGFPE. */
+ context->uc_mcontext.mc_fpreg[32] = control;
+ d = *((double *) &control);
+ asm volatile ("mtfsf 0xff,%0" : : "f" (d));
+}
+#endif
+
/* FIXME: If this can be a no-op on BSD/x86, then it
* deserves a more precise name.
*
diff --git a/src/runtime/ppc-bsd-os.h b/src/runtime/ppc-bsd-os.h
index f45daa855..194fd6c03 100644
--- a/src/runtime/ppc-bsd-os.h
+++ b/src/runtime/ppc-bsd-os.h
@@ -18,4 +18,10 @@ typedef ucontext_t os_context_t;
# error "Need a definition of OS_CONTEXT_PC"
#endif
+#ifdef LISP_FEATURE_FREEBSD
+unsigned long os_context_fp_control(os_context_t *context);
+#define RESTORE_FP_CONTROL_FROM_CONTEXT
+void os_restore_fp_control(os_context_t *context);
+#endif
+
#endif /* _PPC_BSD_OS_H */
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL