+static inline void
+machine_thread_switch_cpu_data(thread_t old, thread_t new)
+{
+ /*
+ * We build with -fno-strict-aliasing, so the load through temporaries
+ * is required so that this generates a single load / store pair.
+ */
+ cpu_data_t *datap = old->machine.CpuDatap;
+ vm_offset_t base = old->machine.pcpu_data_base;
+
+ /* TODO: Should this be ordered? */
+
+ /*
+ * arm relies on CpuDatap being set for a thread that has run,
+ * so we only reset pcpu_data_base.
+ */
+ old->machine.pcpu_data_base = -1;
+
+ new->machine.CpuDatap = datap;
+ new->machine.pcpu_data_base = base;
+}
+