+#if defined(LISP_FEATURE_RESTORE_TLS_SEGMENT_REGISTER_FROM_CONTEXT)
+void
+os_restore_tls_segment_register(os_context_t *context)
+{
+ load_fs(context->uc_mcontext.mc_fs);
+}
+#endif
+
+void
+os_restore_fp_control(os_context_t *context)
+{
+ /* FPU state is saved per context on post-KSE systems.
+ * On earlier systems, it is shared in a whole process.
+ */
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 500040
+ struct envxmm *ex = (struct envxmm *)(context->uc_mcontext.mc_fpstate);
+ __asm__ __volatile__ ("fldcw %0" : : "m" (ex->en_cw));
+#endif
+#if defined(LISP_FEATURE_RESTORE_TLS_SEGMENT_REGISTER_FROM_CONTEXT)
+ /* Calling this function here may not be good idea. Or rename
+ * function name os_restore_fp_control to os_restore_context or
+ * so, to match the behavior? */
+ os_restore_tls_segment_register(context);
+#endif
+}
+#endif
+
+#if defined(LISP_FEATURE_OPENBSD)