+/*
+ * Maps state flavor to number of words in the state:
+ */
+extern unsigned int _MachineStateCount[];
+
+/*
+ * The machine-dependent thread state - registers and all platform-dependent
+ * state - is saved in the machine thread structure which is embedded in
+ * the thread data structure. For historical reasons this is also referred to
+ * as the PCB.
+ */
+struct machine_thread {
+ x86_saved_state_t *iss;
+ void *ifps;
+ void *ids;
+ decl_simple_lock_data(,lock); /* protects ifps and ids */
+ uint64_t iss_pte0;
+ uint64_t iss_pte1;
+
+#ifdef MACH_BSD
+ uint64_t cthread_self; /* for use of cthread package */
+ struct real_descriptor cthread_desc;
+ unsigned long uldt_selector; /* user ldt selector to set */
+ struct real_descriptor uldt_desc; /* actual user setable ldt */
+#endif
+
+ struct pal_pcb pal_pcb;
+ uint32_t specFlags;
+ /* N.B.: These "specFlags" are read-modify-written non-atomically within
+ * the copyio routine. So conceivably any exception that modifies the
+ * flags in a persistent manner could be clobbered if it occurs within
+ * a copyio context. For now, the only other flag here is OnProc which
+ * is not modified except at context switch.
+ */
+#define OnProc 0x1
+#define CopyIOActive 0x2 /* Checked to ensure DTrace actions do not re-enter copyio(). */
+ uint64_t thread_gpu_ns;
+#if NCOPY_WINDOWS > 0
+ struct {
+ user_addr_t user_base;
+ } copy_window[NCOPY_WINDOWS];
+ int nxt_window;
+ int copyio_state;
+#define WINDOWS_DIRTY 0
+#define WINDOWS_CLEAN 1
+#define WINDOWS_CLOSED 2
+#define WINDOWS_OPENED 3
+ uint64_t physwindow_pte;
+ int physwindow_busy;
+#endif
+};
+typedef struct machine_thread *pcb_t;
+
+#define THREAD_TO_PCB(Thr) (&(Thr)->machine)
+
+#define USER_STATE(Thr) ((Thr)->machine.iss)
+#define USER_REGS32(Thr) (saved_state32(USER_STATE(Thr)))
+#define USER_REGS64(Thr) (saved_state64(USER_STATE(Thr)))
+
+#define user_pc(Thr) (is_saved_state32(USER_STATE(Thr)) ? \
+ USER_REGS32(Thr)->eip : \
+ USER_REGS64(Thr)->isf.rip )
+
+extern void *get_user_regs(thread_t);
+
+extern void *act_thread_csave(void);
+extern void act_thread_catt(void *ctx);
+extern void act_thread_cfree(void *ctx);
+
+#define FIND_PERFCONTROL_STATE(th) (PERFCONTROL_STATE_NULL)