+#include "interrupt.h"
+#include "validate.h" /* for BINDING_STACK_SIZE etc */
+
+#define STATE_RUNNING MAKE_FIXNUM(1)
+#define STATE_STOPPED MAKE_FIXNUM(2)
+#define STATE_DEAD MAKE_FIXNUM(3)
+#if defined(LISP_FEATURE_SB_SAFEPOINT)
+# define STATE_SUSPENDED_BRIEFLY MAKE_FIXNUM(4)
+# define STATE_GC_BLOCKER MAKE_FIXNUM(5)
+# define STATE_PHASE1_BLOCKER MAKE_FIXNUM(5)
+# define STATE_PHASE2_BLOCKER MAKE_FIXNUM(6)
+# define STATE_INTERRUPT_BLOCKER MAKE_FIXNUM(7)
+#endif
+
+#ifdef LISP_FEATURE_SB_THREAD
+lispobj thread_state(struct thread *thread);
+void set_thread_state(struct thread *thread, lispobj state);
+void wait_for_thread_state_change(struct thread *thread, lispobj state);
+
+#if defined(LISP_FEATURE_SB_SAFEPOINT)
+enum threads_suspend_reason {
+ SUSPEND_REASON_NONE,
+ SUSPEND_REASON_GC,
+ SUSPEND_REASON_INTERRUPT,
+ SUSPEND_REASON_GCING
+};
+
+struct threads_suspend_info {
+ int suspend;
+ pthread_mutex_t world_lock;
+ pthread_mutex_t lock;
+ enum threads_suspend_reason reason;
+ int phase;
+ struct thread * gc_thread;
+ struct thread * interrupted_thread;
+ int blockers;
+ int used_gc_page;
+};
+
+struct suspend_phase {
+ int suspend;
+ enum threads_suspend_reason reason;
+ int phase;
+ struct suspend_phase *next;
+};
+
+extern struct threads_suspend_info suspend_info;
+
+struct gcing_safety {
+ lispobj csp_around_foreign_call;
+#ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
+ lispobj* pc_around_foreign_call;
+#endif
+};
+
+int handle_safepoint_violation(os_context_t *context, os_vm_address_t addr);
+void** os_get_csp(struct thread* th);
+void alloc_gc_page();
+void assert_on_stack(struct thread *th, void *esp);
+#endif /* defined(LISP_FEATURE_SB_SAFEPOINT) */
+
+extern pthread_key_t lisp_thread;
+#endif