chore: move rdtsc to util

main
Sean McBride 5 years ago
parent dc9677e41f
commit b896f6f1b1

@ -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 */

@ -4,6 +4,23 @@
#include <sandbox.h>
#include <module.h>
/**
* 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);

@ -1,5 +1,6 @@
/* https://github.com/gwsystems/silverfish/blob/master/runtime/libc/libc_backing.c */
#include <runtime.h>
#include <util.h>
extern i32 inner_syscall_handler(i32 n, i32 a, i32 b, i32 c, i32 d, i32 e, i32 f);

@ -10,6 +10,7 @@
#include <softint.h>
#include <uv.h>
#include <http_api.h>
#include <util.h>
#include "http_parser_settings.h"
#include "sandbox_request.h"

@ -7,6 +7,7 @@
#include <uv.h>
#include <http_api.h>
#include <libuv_callbacks.h>
#include <util.h>
/**
* Takes the arguments from the sandbox struct and writes them into the WebAssembly linear memory

Loading…
Cancel
Save