+ void *badaddr=arch_get_bad_addr(signal,info,context);
+ return (badaddr >= (void *)current_auto_gc_trigger &&
+ badaddr <((void *)current_dynamic_space + DYNAMIC_SPACE_SIZE));
+ }
+}
+#endif
+
+/* manipulate the signal context and stack such that when the handler
+ * returns, it will call function instead of whatever it was doing
+ * previously
+ */
+
+extern lispobj call_into_lisp(lispobj fun, lispobj *args, int nargs);
+extern void post_signal_tramp(void);
+void arrange_return_to_lisp_function(os_context_t *context, lispobj function)
+{
+ void * fun=native_pointer(function);
+ char *code = &(((struct simple_fun *) fun)->code);
+
+ /* Build a stack frame showing `interrupted' so that the
+ * user's backtrace makes (as much) sense (as usual) */
+#ifdef LISP_FEATURE_X86
+ /* Suppose the existence of some function that saved all
+ * registers, called call_into_lisp, then restored GP registers and
+ * returned. We shortcut this: fake the stack that call_into_lisp
+ * would see, then arrange to have it called directly. post_signal_tramp
+ * is the second half of this function
+ */
+ u32 *sp=(u32 *)*os_context_register_addr(context,reg_ESP);
+
+ *(sp-14) = post_signal_tramp; /* return address for call_into_lisp */
+ *(sp-13) = function; /* args for call_into_lisp : function*/
+ *(sp-12) = 0; /* arg array */
+ *(sp-11) = 0; /* no. args */
+ /* this order matches that used in POPAD */
+ *(sp-10)=*os_context_register_addr(context,reg_EDI);
+ *(sp-9)=*os_context_register_addr(context,reg_ESI);
+ /* this gets overwritten again before it's used, anyway */
+ *(sp-8)=*os_context_register_addr(context,reg_EBP);
+ *(sp-7)=0 ; /* POPAD doesn't set ESP, but expects a gap for it anyway */
+ *(sp-6)=*os_context_register_addr(context,reg_EBX);
+
+ *(sp-5)=*os_context_register_addr(context,reg_EDX);
+ *(sp-4)=*os_context_register_addr(context,reg_ECX);
+ *(sp-3)=*os_context_register_addr(context,reg_EAX);
+ *(sp-2)=*os_context_register_addr(context,reg_EBP);
+ *(sp-1)=*os_context_pc_addr(context);
+
+#else
+ struct thread *th=arch_os_get_current_thread();
+ build_fake_control_stack_frames(th,context);
+#endif