+
+/* 32-bit right-rotate n bits */
+static inline uint32_t ror32(uint32_t val, const unsigned int n)
+{
+ __asm__ volatile("rorl %%cl,%0" : "=r" (val) : "0" (val), "c" (n));
+ return val;
+}
+
+void
+ml_entropy_collect(void)
+{
+ uint32_t tsc_lo, tsc_hi;
+ uint32_t *ep;
+
+ assert(cpu_number() == master_cpu);
+
+ /* update buffer pointer cyclically */
+ if (EntropyData.index_ptr - EntropyData.buffer == ENTROPY_BUFFER_SIZE)
+ ep = EntropyData.index_ptr = EntropyData.buffer;
+ else
+ ep = EntropyData.index_ptr++;
+
+ rdtsc_nofence(tsc_lo, tsc_hi);
+ *ep = ror32(*ep, 9) ^ tsc_lo;
+}
+
+uint64_t
+ml_energy_stat(__unused thread_t t) {
+ return 0;
+}
+
+void
+ml_gpu_stat_update(uint64_t gpu_ns_delta) {
+ current_thread()->machine.thread_gpu_ns += gpu_ns_delta;
+}
+
+uint64_t
+ml_gpu_stat(thread_t t) {
+ return t->machine.thread_gpu_ns;
+}
+
+int plctrace_enabled = 0;
+
+void _disable_preemption(void) {
+ disable_preemption_internal();
+}
+
+void _enable_preemption(void) {
+ enable_preemption_internal();
+}
+
+void plctrace_disable(void) {
+ plctrace_enabled = 0;
+}