From b896f6f1b1ee83a38447d05c0bf25a6a558d9248 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 16 Mar 2020 15:41:41 -0400 Subject: [PATCH] chore: move rdtsc to util --- runtime/include/runtime.h | 16 ---------------- runtime/include/util.h | 17 +++++++++++++++++ runtime/src/env.c | 1 + runtime/src/runtime.c | 1 + runtime/src/sandbox.c | 1 + 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/runtime/include/runtime.h b/runtime/include/runtime.h index a6b48ad..552eda7 100644 --- a/runtime/include/runtime.h +++ b/runtime/include/runtime.h @@ -65,20 +65,4 @@ get_thread_libuv_handle(void) return &uvio_handle; } -/** - * Get CPU time in cycles using the Intel instruction rdtsc - * @return CPU time in cycles - **/ -static unsigned long long int -rdtsc(void) -{ - unsigned long long int cpu_time_in_cycles = 0; - unsigned int cycles_lo; - unsigned int cycles_hi; - __asm__ volatile("RDTSC" : "=a"(cycles_lo), "=d"(cycles_hi)); - cpu_time_in_cycles = (unsigned long long int)cycles_hi << 32 | cycles_lo; - - return cpu_time_in_cycles; -} - #endif /* SFRT_RUNTIME_H */ diff --git a/runtime/include/util.h b/runtime/include/util.h index 41f69f8..5a7816b 100644 --- a/runtime/include/util.h +++ b/runtime/include/util.h @@ -4,6 +4,23 @@ #include #include + +/** + * Get CPU time in cycles using the Intel instruction rdtsc + * @return CPU time in cycles + **/ +static unsigned long long int +rdtsc(void) +{ + unsigned long long int cpu_time_in_cycles = 0; + unsigned int cycles_lo; + unsigned int cycles_hi; + __asm__ volatile("RDTSC" : "=a"(cycles_lo), "=d"(cycles_hi)); + cpu_time_in_cycles = (unsigned long long int)cycles_hi << 32 | cycles_lo; + + return cpu_time_in_cycles; +} + /* perhaps move it to module.h or sandbox.h? */ int util__parse_modules_file_json(char *filename); diff --git a/runtime/src/env.c b/runtime/src/env.c index ac6d9f2..8c8d7f2 100644 --- a/runtime/src/env.c +++ b/runtime/src/env.c @@ -1,5 +1,6 @@ /* https://github.com/gwsystems/silverfish/blob/master/runtime/libc/libc_backing.c */ #include +#include extern i32 inner_syscall_handler(i32 n, i32 a, i32 b, i32 c, i32 d, i32 e, i32 f); diff --git a/runtime/src/runtime.c b/runtime/src/runtime.c index 5d7d26c..3261943 100644 --- a/runtime/src/runtime.c +++ b/runtime/src/runtime.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "http_parser_settings.h" #include "sandbox_request.h" diff --git a/runtime/src/sandbox.c b/runtime/src/sandbox.c index d13862a..ae0b825 100644 --- a/runtime/src/sandbox.c +++ b/runtime/src/sandbox.c @@ -7,6 +7,7 @@ #include #include #include +#include /** * Takes the arguments from the sandbox struct and writes them into the WebAssembly linear memory