chore: refactor double underscores

main
Sean McBride 5 years ago
parent fe1048c622
commit a949cbebe3

@ -64,8 +64,8 @@ http_parser_settings_on_header_field(http_parser *parser, const char *at, size_t
struct http_request *http_request = &sandbox->http_request;
if (http_request->last_was_value) http_request->header_count++;
assert(http_request->header_count <= HTTP__MAX_HEADER_COUNT);
assert(length < HTTP__MAX_HEADER_LENGTH);
assert(http_request->header_count <= HTTP_MAX_HEADER_COUNT);
assert(length < HTTP_MAX_HEADER_LENGTH);
http_request->last_was_value = 0;
http_request->headers[http_request->header_count - 1].key = (char *)
@ -89,8 +89,8 @@ http_parser_settings_on_header_value(http_parser *parser, const char *at, size_t
struct http_request *http_request = &sandbox->http_request;
http_request->last_was_value = 1;
assert(http_request->header_count <= HTTP__MAX_HEADER_COUNT);
assert(length < HTTP__MAX_HEADER_VALUE_LENGTH);
assert(http_request->header_count <= HTTP_MAX_HEADER_COUNT);
assert(length < HTTP_MAX_HEADER_VALUE_LENGTH);
http_request->headers[http_request->header_count - 1].value = (char *)
at; // it is from the sandbox's request_response_data, should persist.

@ -10,7 +10,7 @@ struct http_header {
};
struct http_request {
struct http_header headers[HTTP__MAX_HEADER_COUNT];
struct http_header headers[HTTP_MAX_HEADER_COUNT];
int header_count;
char * body;
int body_length;

@ -16,16 +16,16 @@ struct http_response_header {
};
struct http_response {
struct http_response_header headers[HTTP__MAX_HEADER_COUNT];
struct http_response_header headers[HTTP_MAX_HEADER_COUNT];
int header_count;
char * body;
int body_length;
char * status;
int status_length;
#ifdef USE_HTTP_UVIO
uv_buf_t bufs[HTTP__MAX_HEADER_COUNT * 2 + 3]; // max headers, one line for status code, remaining for body!
uv_buf_t bufs[HTTP_MAX_HEADER_COUNT * 2 + 3]; // max headers, one line for status code, remaining for body!
#else
struct iovec bufs[HTTP__MAX_HEADER_COUNT * 2 + 3];
struct iovec bufs[HTTP_MAX_HEADER_COUNT * 2 + 3];
#endif
};

@ -6,8 +6,8 @@
#include <types.h>
struct module {
char name[MODULE__MAX_NAME_LENGTH];
char path[MODULE__MAX_PATH_LENGTH];
char name[MODULE_MAX_NAME_LENGTH];
char path[MODULE_MAX_PATH_LENGTH];
void * dynamic_library_handle; // Handle to the *.so of the serverless function
i32 argument_count;
u32 stack_size; // a specification?
@ -27,15 +27,15 @@ struct module {
// uv_handle_t srvuv;
unsigned long max_request_size;
char request_headers[HTTP__MAX_HEADER_COUNT][HTTP__MAX_HEADER_LENGTH];
char request_headers[HTTP_MAX_HEADER_COUNT][HTTP_MAX_HEADER_LENGTH];
int request_header_count;
char request_content_type[HTTP__MAX_HEADER_VALUE_LENGTH];
char request_content_type[HTTP_MAX_HEADER_VALUE_LENGTH];
// resp size including headers!
unsigned long max_response_size;
int response_header_count;
char response_content_type[HTTP__MAX_HEADER_VALUE_LENGTH];
char response_headers[HTTP__MAX_HEADER_COUNT][HTTP__MAX_HEADER_LENGTH];
char response_content_type[HTTP_MAX_HEADER_VALUE_LENGTH];
char response_headers[HTTP_MAX_HEADER_COUNT][HTTP_MAX_HEADER_LENGTH];
// Equals the largest of either max_request_size or max_response_size
unsigned long max_request_or_response_size;
@ -171,10 +171,10 @@ module_set_http_info(struct module *module, int request_count, char *request_hea
{
assert(module);
module->request_header_count = request_count;
memcpy(module->request_headers, request_headers, HTTP__MAX_HEADER_LENGTH * HTTP__MAX_HEADER_COUNT);
memcpy(module->request_headers, request_headers, HTTP_MAX_HEADER_LENGTH * HTTP_MAX_HEADER_COUNT);
strcpy(module->request_content_type, request_content_type);
module->response_header_count = response_count;
memcpy(module->response_headers, response_headers, HTTP__MAX_HEADER_LENGTH * HTTP__MAX_HEADER_COUNT);
memcpy(module->response_headers, response_headers, HTTP_MAX_HEADER_LENGTH * HTTP_MAX_HEADER_COUNT);
strcpy(module->response_content_type, response_content_type);
}

@ -22,7 +22,7 @@ module_database_add(struct module *module)
// __sync_fetch_and_add is provided by GCC
int f = __sync_fetch_and_add(&module_database_free_offset, 1);
assert(f < MODULE__MAX_MODULE_COUNT);
assert(f < MODULE_MAX_MODULE_COUNT);
module_database[f] = module;
return 0;

@ -53,7 +53,7 @@ struct sandbox {
void *arguments; // arguments from request, must be of module->argument_count size.
i32 return_value;
struct sandbox_io_handle io_handles[SANDBOX__MAX_IO_HANDLE_COUNT];
struct sandbox_io_handle io_handles[SANDBOX_MAX_IO_HANDLE_COUNT];
struct sockaddr client_address; // client requesting connection!
int client_socket_descriptor;
uv_tcp_t client_libuv_stream;
@ -136,11 +136,11 @@ sandbox_initialize_io_handle(struct sandbox *sandbox)
{
if (!sandbox) return -1;
int io_handle_index;
for (io_handle_index = 0; io_handle_index < SANDBOX__MAX_IO_HANDLE_COUNT; io_handle_index++) {
for (io_handle_index = 0; io_handle_index < SANDBOX_MAX_IO_HANDLE_COUNT; io_handle_index++) {
if (sandbox->io_handles[io_handle_index].file_descriptor < 0) break;
}
if (io_handle_index == SANDBOX__MAX_IO_HANDLE_COUNT) return -1;
sandbox->io_handles[io_handle_index].file_descriptor = SANDBOX__FILE_DESCRIPTOR_PREOPEN_MAGIC;
if (io_handle_index == SANDBOX_MAX_IO_HANDLE_COUNT) return -1;
sandbox->io_handles[io_handle_index].file_descriptor = SANDBOX_FILE_DESCRIPTOR_PREOPEN_MAGIC;
memset(&sandbox->io_handles[io_handle_index].libuv_handle, 0, sizeof(union uv_any_handle));
return io_handle_index;
}
@ -176,9 +176,9 @@ static inline int
sandbox_set_file_descriptor(struct sandbox *sandbox, int io_handle_index, int file_descriptor)
{
if (!sandbox) return -1;
if (io_handle_index >= SANDBOX__MAX_IO_HANDLE_COUNT || io_handle_index < 0) return -1;
if (io_handle_index >= SANDBOX_MAX_IO_HANDLE_COUNT || io_handle_index < 0) return -1;
if (file_descriptor < 0
|| sandbox->io_handles[io_handle_index].file_descriptor != SANDBOX__FILE_DESCRIPTOR_PREOPEN_MAGIC)
|| sandbox->io_handles[io_handle_index].file_descriptor != SANDBOX_FILE_DESCRIPTOR_PREOPEN_MAGIC)
return -1;
sandbox->io_handles[io_handle_index].file_descriptor = file_descriptor;
return io_handle_index;
@ -194,7 +194,7 @@ static inline int
sandbox_get_file_descriptor(struct sandbox *sandbox, int io_handle_index)
{
if (!sandbox) return -1;
if (io_handle_index >= SANDBOX__MAX_IO_HANDLE_COUNT || io_handle_index < 0) return -1;
if (io_handle_index >= SANDBOX_MAX_IO_HANDLE_COUNT || io_handle_index < 0) return -1;
return sandbox->io_handles[io_handle_index].file_descriptor;
}
@ -206,7 +206,7 @@ sandbox_get_file_descriptor(struct sandbox *sandbox, int io_handle_index)
static inline void
sandbox_close_file_descriptor(struct sandbox *sandbox, int io_handle_index)
{
if (io_handle_index >= SANDBOX__MAX_IO_HANDLE_COUNT || io_handle_index < 0) return;
if (io_handle_index >= SANDBOX_MAX_IO_HANDLE_COUNT || io_handle_index < 0) return;
// TODO: Do we actually need to call some sort of close function here?
sandbox->io_handles[io_handle_index].file_descriptor = -1;
}
@ -221,7 +221,7 @@ static inline union uv_any_handle *
sandbox_get_libuv_handle(struct sandbox *sandbox, int io_handle_index)
{
if (!sandbox) return NULL;
if (io_handle_index >= SANDBOX__MAX_IO_HANDLE_COUNT || io_handle_index < 0) return NULL;
if (io_handle_index >= SANDBOX_MAX_IO_HANDLE_COUNT || io_handle_index < 0) return NULL;
return &sandbox->io_handles[io_handle_index].libuv_handle;
}

@ -21,7 +21,7 @@ DEQUE_PROTOTYPE(sandbox, sandbox_request_t *);
* @param sandbox_request
**/
static inline int
sandbox_request__push_to_dequeue(sandbox_request_t *sandbox_request)
sandbox_request_push_to_dequeue(sandbox_request_t *sandbox_request)
{
int return_code;
@ -48,7 +48,7 @@ sandbox_request__push_to_dequeue(sandbox_request_t *sandbox_request)
* @return the new sandbox request
**/
static inline sandbox_request_t *
sandbox_request__allocate(struct module *module, char *arguments, int socket_descriptor,
sandbox_request_allocate(struct module *module, char *arguments, int socket_descriptor,
const struct sockaddr *socket_address, u64 start_time)
{
sandbox_request_t *sandbox_request = (sandbox_request_t *)malloc(sizeof(sandbox_request_t));
@ -60,7 +60,7 @@ sandbox_request__allocate(struct module *module, char *arguments, int socket_des
sandbox_request->start_time = start_time;
debuglog("[%p: %s]\n", sandbox_request, sandbox_request->module->name);
sandbox_request__push_to_dequeue(sandbox_request);
sandbox_request_push_to_dequeue(sandbox_request);
return sandbox_request;
}
@ -69,7 +69,7 @@ sandbox_request__allocate(struct module *module, char *arguments, int socket_des
* @param sandbox_request the pointer which we want to set to the sandbox request
**/
static inline int
sandbox_request__pop_from_dequeue(sandbox_request_t **sandbox_request)
sandbox_request_pop_from_dequeue(sandbox_request_t **sandbox_request)
{
int return_code;
@ -100,12 +100,12 @@ sandbox_request__pop_from_dequeue(sandbox_request_t **sandbox_request)
* @returns A Sandbox Request or NULL
**/
static inline sandbox_request_t *
sandbox_request__steal_from_dequeue(void)
sandbox_request_steal_from_dequeue(void)
{
sandbox_request_t *sandbox_request = NULL;
#if NCORES == 1
sandbox_request__pop_from_dequeue(&sandbox_request);
sandbox_request_pop_from_dequeue(&sandbox_request);
#else
int r = deque_steal_sandbox(runtime_global_deque, &sandbox_request);
if (r) sandbox_request = NULL;

@ -117,48 +117,48 @@ typedef enum
#define debuglog(fmt, ...)
#endif // DEBUG
#define HTTP__MAX_HEADER_COUNT 16
#define HTTP__MAX_HEADER_LENGTH 32
#define HTTP__MAX_HEADER_VALUE_LENGTH 64
#define HTTP__RESPONSE_200_OK "HTTP/1.1 200 OK\r\n"
#define HTTP__RESPONSE_CONTENT_LENGTH "Content-length: \r\n\r\n" // content body follows this
#define HTTP__RESPONSE_CONTENT_TYPE "Content-type: \r\n"
#define HTTP__RESPONSE_CONTENT_TYPE_PLAIN "text/plain"
#define JSON__MAX_ELEMENT_COUNT 16 // Max number of elements defined in JSON
#define JSON__MAX_ELEMENT_SIZE 1024 // Max size of a single module in JSON
#define LISTENER_THREAD__CORE_ID 0 // Dedicated Listener Core
#define LISTENER_THREAD__MAX_EPOLL_EVENTS 1024
#define MODULE__DEFAULT_REQUEST_RESPONSE_SIZE (PAGE_SIZE)
#define MODULE__INITIALIZE_GLOBALS "populate_globals" // From Silverfish
#define MODULE__INITIALIZE_MEMORY "populate_memory" // From Silverfish
#define MODULE__INITIALIZE_TABLE "populate_table" // From Silverfish
#define MODULE__INITIALIZE_LIBC "wasmf___init_libc" // From Silverfish
#define MODULE__MAIN "wasmf_main" // From Silverfish
#define MODULE__MAX_ARGUMENT_COUNT 16 // Max number of arguments
#define MODULE__MAX_ARGUMENT_SIZE 64 // Max size of a single argument
#define MODULE__MAX_MODULE_COUNT 128 // Max number of modules
#define MODULE__MAX_NAME_LENGTH 32 // Max module name length
#define MODULE__MAX_PATH_LENGTH 256 // Max length of path string
#define MODULE__MAX_PENDING_CLIENT_REQUESTS 1000
#define RUNTIME__LOG_FILE "awesome.log"
#define RUNTIME__READ_WRITE_VECTOR_LENGTH 16
#define RUNTIME__MAX_SANDBOX_REQUEST_COUNT (1 << 19) // random!
#define SANDBOX__FILE_DESCRIPTOR_PREOPEN_MAGIC (707707707) // reads lol lol lol upside down
#define SANDBOX__MAX_IO_HANDLE_COUNT 32
#define SANDBOX__PULL_BATCH_SIZE 1 // Max # standboxes pulled onto the local runqueue in a single batch
#define SOFTWARE_INTERRUPT__TIME_TO_START_IN_USEC (10 * 1000) // start timers 10 ms from now.
#define SOFTWARE_INTERRUPT__INTERVAL_DURATION_IN_USEC (1000 * 5) // and execute every 5ms
#define HTTP_MAX_HEADER_COUNT 16
#define HTTP_MAX_HEADER_LENGTH 32
#define HTTP_MAX_HEADER_VALUE_LENGTH 64
#define HTTP_RESPONSE_200_OK "HTTP/1.1 200 OK\r\n"
#define HTTP_RESPONSE_CONTENT_LENGTH "Content-length: \r\n\r\n" // content body follows this
#define HTTP_RESPONSE_CONTENT_TYPE "Content-type: \r\n"
#define HTTP_RESPONSE_CONTENT_TYPE_PLAIN "text/plain"
#define JSON_MAX_ELEMENT_COUNT 16 // Max number of elements defined in JSON
#define JSON_MAX_ELEMENT_SIZE 1024 // Max size of a single module in JSON
#define LISTENER_THREAD_CORE_ID 0 // Dedicated Listener Core
#define LISTENER_THREAD_MAX_EPOLL_EVENTS 1024
#define MODULE_DEFAULT_REQUEST_RESPONSE_SIZE (PAGE_SIZE)
#define MODULE_INITIALIZE_GLOBALS "populate_globals" // From Silverfish
#define MODULE_INITIALIZE_MEMORY "populate_memory" // From Silverfish
#define MODULE_INITIALIZE_TABLE "populate_table" // From Silverfish
#define MODULE_INITIALIZE_LIBC "wasmf___init_libc" // From Silverfish
#define MODULE_MAIN "wasmf_main" // From Silverfish
#define MODULE_MAX_ARGUMENT_COUNT 16 // Max number of arguments
#define MODULE_MAX_ARGUMENT_SIZE 64 // Max size of a single argument
#define MODULE_MAX_MODULE_COUNT 128 // Max number of modules
#define MODULE_MAX_NAME_LENGTH 32 // Max module name length
#define MODULE_MAX_PATH_LENGTH 256 // Max length of path string
#define MODULE_MAX_PENDING_CLIENT_REQUESTS 1000
#define RUNTIME_LOG_FILE "awesome.log"
#define RUNTIME_READ_WRITE_VECTOR_LENGTH 16
#define RUNTIME_MAX_SANDBOX_REQUEST_COUNT (1 << 19) // random!
#define SANDBOX_FILE_DESCRIPTOR_PREOPEN_MAGIC (707707707) // reads lol lol lol upside down
#define SANDBOX_MAX_IO_HANDLE_COUNT 32
#define SANDBOX_PULL_BATCH_SIZE 1 // Max # standboxes pulled onto the local runqueue in a single batch
#define SOFTWARE_INTERRUPT_TIME_TO_START_IN_USEC (10 * 1000) // start timers 10 ms from now.
#define SOFTWARE_INTERRUPT_INTERVAL_DURATION_IN_USEC (1000 * 5) // and execute every 5ms
// If multicore, use all but the dedicated listener core
// If there are fewer cores than this, main dynamically overrides this and uses all available
#define WORKER_THREAD__CORE_COUNT (NCORES > 1 ? NCORES - 1 : NCORES)
#define WORKER_THREAD_CORE_COUNT (NCORES > 1 ? NCORES - 1 : NCORES)
#endif /* SFRT_TYPES_H */

@ -0,0 +1,20 @@
#ifndef SFRT_UTIL_H
#define SFRT_UTIL_H
/**
* Get CPU time in cycles using the Intel instruction rdtsc
* @return CPU time in cycles
**/
static unsigned long long int
util_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_UTIL_H */

@ -1,6 +1,7 @@
/* https://github.com/gwsystems/silverfish/blob/master/runtime/libc/libc_backing.c */
#include <runtime.h>
#include <ck_pr.h>
#include <util.h>
extern i32 inner_syscall_handler(i32 n, i32 a, i32 b, i32 c, i32 d, i32 e, i32 f);
@ -150,6 +151,5 @@ env_cos(double d)
INLINE unsigned long long
env_getcycles(void)
{
return __getcycles();
return util_rdtsc();
}

@ -88,7 +88,7 @@ http_response_set_body(struct http_response *http_response, char *body, int leng
int
http_response_set_header(struct http_response *http_response, char *header, int length)
{
assert(http_response->header_count < HTTP__MAX_HEADER_COUNT);
assert(http_response->header_count < HTTP_MAX_HEADER_COUNT);
http_response->header_count++;
http_response->headers[http_response->header_count - 1].header = header;
http_response->headers[http_response->header_count - 1].length = length;

@ -183,7 +183,7 @@ i32
wasm_open(i32 path_off, i32 flags, i32 mode)
{
uv_fs_t req = UV_FS_REQ_INIT();
char * path = worker_thread_get_memory_string(path_off, MODULE__MAX_PATH_LENGTH);
char * path = worker_thread_get_memory_string(path_off, MODULE_MAX_PATH_LENGTH);
int iofd = current_sandbox_initialize_io_handle();
if (iofd < 0) return -1;
@ -296,7 +296,7 @@ struct wasm_stat {
i32
wasm_stat(u32 path_str_offset, i32 stat_offset)
{
char * path = worker_thread_get_memory_string(path_str_offset, MODULE__MAX_PATH_LENGTH);
char * path = worker_thread_get_memory_string(path_str_offset, MODULE_MAX_PATH_LENGTH);
struct wasm_stat *stat_ptr = worker_thread_get_memory_ptr_void(stat_offset, sizeof(struct wasm_stat));
struct stat stat;
@ -388,7 +388,7 @@ wasm_fstat(i32 filedes, i32 stat_offset)
i32
wasm_lstat(i32 path_str_offset, i32 stat_offset)
{
char * path = worker_thread_get_memory_string(path_str_offset, MODULE__MAX_PATH_LENGTH);
char * path = worker_thread_get_memory_string(path_str_offset, MODULE_MAX_PATH_LENGTH);
struct wasm_stat *stat_ptr = worker_thread_get_memory_ptr_void(stat_offset, sizeof(struct wasm_stat));
struct stat stat;
@ -521,12 +521,12 @@ wasm_readv(i32 file_descriptor, i32 iov_offset, i32 iovcnt)
int d = current_sandbox_get_file_descriptor(file_descriptor);
struct wasm_iovec *iov = worker_thread_get_memory_ptr_void(iov_offset, iovcnt * sizeof(struct wasm_iovec));
for (int i = 0; i < iovcnt; i += RUNTIME__READ_WRITE_VECTOR_LENGTH) {
for (int i = 0; i < iovcnt; i += RUNTIME_READ_WRITE_VECTOR_LENGTH) {
uv_fs_t req = UV_FS_REQ_INIT();
uv_buf_t bufs[RUNTIME__READ_WRITE_VECTOR_LENGTH] = { 0 }; // avoid mallocs here!
uv_buf_t bufs[RUNTIME_READ_WRITE_VECTOR_LENGTH] = { 0 }; // avoid mallocs here!
int j = 0;
for (j = 0; j < RUNTIME__READ_WRITE_VECTOR_LENGTH && i + j < iovcnt; j++) {
for (j = 0; j < RUNTIME_READ_WRITE_VECTOR_LENGTH && i + j < iovcnt; j++) {
bufs[j] = uv_buf_init(worker_thread_get_memory_ptr_void(iov[i + j].base_offset, iov[i + j].len),
iov[i + j].len);
}
@ -569,12 +569,12 @@ wasm_writev(i32 file_descriptor, i32 iov_offset, i32 iovcnt)
int gret = 0;
struct wasm_iovec *iov = worker_thread_get_memory_ptr_void(iov_offset, iovcnt * sizeof(struct wasm_iovec));
for (int i = 0; i < iovcnt; i += RUNTIME__READ_WRITE_VECTOR_LENGTH) {
for (int i = 0; i < iovcnt; i += RUNTIME_READ_WRITE_VECTOR_LENGTH) {
uv_fs_t req = UV_FS_REQ_INIT();
uv_buf_t bufs[RUNTIME__READ_WRITE_VECTOR_LENGTH] = { 0 }; // avoid mallocs here!
uv_buf_t bufs[RUNTIME_READ_WRITE_VECTOR_LENGTH] = { 0 }; // avoid mallocs here!
int j = 0;
for (j = 0; j < RUNTIME__READ_WRITE_VECTOR_LENGTH && i + j < iovcnt; j++) {
for (j = 0; j < RUNTIME_READ_WRITE_VECTOR_LENGTH && i + j < iovcnt; j++) {
bufs[j] = uv_buf_init(worker_thread_get_memory_ptr_void(iov[i + j].base_offset, iov[i + j].len),
iov[i + j].len);
}
@ -666,7 +666,7 @@ wasm_getcwd(u32 buf_offset, u32 buf_size)
u32
wasm_unlink(u32 path_str_offset)
{
char * path = worker_thread_get_memory_string(path_str_offset, MODULE__MAX_PATH_LENGTH);
char * path = worker_thread_get_memory_string(path_str_offset, MODULE_MAX_PATH_LENGTH);
uv_fs_t req = UV_FS_REQ_INIT();
debuglog("[%p] start[%s]\n", uv_fs_get_data(&req), path);
uv_fs_unlink(worker_thread_get_libuv_handle(), &req, path, wasm_fs_callback);
@ -878,7 +878,7 @@ wasm_bind(i32 sockfd, i32 sockaddr_offset, i32 addrlen)
debuglog("[%p] tcp\n", c);
int r1 = uv_tcp_bind((uv_tcp_t *)h, worker_thread_get_memory_ptr_void(sockaddr_offset, addrlen),
0 /* TODO: flags */);
if (file_descriptor == SANDBOX__FILE_DESCRIPTOR_PREOPEN_MAGIC) {
if (file_descriptor == SANDBOX_FILE_DESCRIPTOR_PREOPEN_MAGIC) {
int r2 = -1, f = -1;
r2 = uv_fileno((uv_handle_t *)h, &f);
debuglog("[%p] [%d,%d]\n", c, f, file_descriptor);
@ -889,7 +889,7 @@ wasm_bind(i32 sockfd, i32 sockaddr_offset, i32 addrlen)
debuglog("[%p] udp\n", c);
int r1 = uv_udp_bind((uv_udp_t *)h, worker_thread_get_memory_ptr_void(sockaddr_offset, addrlen),
0 /* TODO: flags */);
if (file_descriptor == SANDBOX__FILE_DESCRIPTOR_PREOPEN_MAGIC) {
if (file_descriptor == SANDBOX_FILE_DESCRIPTOR_PREOPEN_MAGIC) {
int r2 = -1, f = -1;
r2 = uv_fileno((uv_handle_t *)h, &f);
debuglog("[%p] [%d,%d]\n", c, f, file_descriptor);

@ -21,8 +21,8 @@ i32 runtime_log_file_descriptor = -1;
u32 runtime_total_online_processors = 0;
u32 runtime_total_worker_processors = 0;
u32 runtime_first_worker_processor = 0;
int runtime_worker_threads_argument[WORKER_THREAD__CORE_COUNT] = { 0 }; // The worker sets its argument to -1 on error
pthread_t runtime_worker_threads[WORKER_THREAD__CORE_COUNT];
int runtime_worker_threads_argument[WORKER_THREAD_CORE_COUNT] = { 0 }; // The worker sets its argument to -1 on error
pthread_t runtime_worker_threads[WORKER_THREAD_CORE_COUNT];
/**
@ -76,11 +76,11 @@ runtime_allocate_available_cores()
// If multicore, we'll pin one core as a listener and run sandbox threads on all others
if (runtime_total_online_processors > 1) {
runtime_first_worker_processor = 1;
// WORKER_THREAD__CORE_COUNT can be used as a cap on the number of cores to use
// But if there are few cores that WORKER_THREAD__CORE_COUNT, just use what is available
// WORKER_THREAD_CORE_COUNT can be used as a cap on the number of cores to use
// But if there are few cores that WORKER_THREAD_CORE_COUNT, just use what is available
u32 max_possible_workers = runtime_total_online_processors - 1;
runtime_total_worker_processors = (max_possible_workers >= WORKER_THREAD__CORE_COUNT)
? WORKER_THREAD__CORE_COUNT
runtime_total_worker_processors = (max_possible_workers >= WORKER_THREAD_CORE_COUNT)
? WORKER_THREAD_CORE_COUNT
: max_possible_workers;
} else {
// If single core, we'll do everything on CPUID 0
@ -89,7 +89,7 @@ runtime_allocate_available_cores()
}
printf("Number of cores %u, sandboxing cores %u (start: %u) and module reqs %u\n",
runtime_total_online_processors, runtime_total_worker_processors, runtime_first_worker_processor,
LISTENER_THREAD__CORE_ID);
LISTENER_THREAD_CORE_ID);
}
#ifdef DEBUG
@ -105,7 +105,7 @@ runtime_process_debug_log_behavior()
fclose(stdout);
fclose(stderr);
fclose(stdin);
runtime_log_file_descriptor = open(RUNTIME__LOG_FILE, O_CREAT | O_TRUNC | O_WRONLY, S_IRWXU | S_IRWXG);
runtime_log_file_descriptor = open(RUNTIME_LOG_FILE, O_CREAT | O_TRUNC | O_WRONLY, S_IRWXU | S_IRWXG);
if (runtime_log_file_descriptor < 0) {
perror("open");
exit(-1);
@ -166,7 +166,7 @@ main(int argc, char **argv)
exit(-1);
}
memset(runtime_worker_threads, 0, sizeof(pthread_t) * WORKER_THREAD__CORE_COUNT);
memset(runtime_worker_threads, 0, sizeof(pthread_t) * WORKER_THREAD_CORE_COUNT);
runtime_set_resource_limits_to_max();
runtime_allocate_available_cores();

@ -41,7 +41,7 @@ module_initialize_as_server(struct module *module)
}
// Listen to the interface? Check that it is live?
if (listen(socket_descriptor, MODULE__MAX_PENDING_CLIENT_REQUESTS) < 0) assert(0);
if (listen(socket_descriptor, MODULE_MAX_PENDING_CLIENT_REQUESTS) < 0) assert(0);
// Set the socket descriptor and register with our global epoll instance to monitor for incoming HTTP requests
@ -111,24 +111,24 @@ module_new(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_m
if (module->dynamic_library_handle == NULL) goto dl_open_error;
// Resolve the symbols in the dynamic library *.so file
module->main = (mod_main_fn_t)dlsym(module->dynamic_library_handle, MODULE__MAIN);
module->main = (mod_main_fn_t)dlsym(module->dynamic_library_handle, MODULE_MAIN);
if (module->main == NULL) goto dl_error;
module->initialize_globals = (mod_glb_fn_t)dlsym(module->dynamic_library_handle, MODULE__INITIALIZE_GLOBALS);
module->initialize_globals = (mod_glb_fn_t)dlsym(module->dynamic_library_handle, MODULE_INITIALIZE_GLOBALS);
if (module->initialize_globals == NULL) goto dl_error;
module->initialize_memory = (mod_mem_fn_t)dlsym(module->dynamic_library_handle, MODULE__INITIALIZE_MEMORY);
module->initialize_memory = (mod_mem_fn_t)dlsym(module->dynamic_library_handle, MODULE_INITIALIZE_MEMORY);
if (module->initialize_memory == NULL) goto dl_error;
module->initialize_tables = (mod_tbl_fn_t)dlsym(module->dynamic_library_handle, MODULE__INITIALIZE_TABLE);
module->initialize_tables = (mod_tbl_fn_t)dlsym(module->dynamic_library_handle, MODULE_INITIALIZE_TABLE);
if (module->initialize_tables == NULL) goto dl_error;
module->initialize_libc = (mod_libc_fn_t)dlsym(module->dynamic_library_handle, MODULE__INITIALIZE_LIBC);
module->initialize_libc = (mod_libc_fn_t)dlsym(module->dynamic_library_handle, MODULE_INITIALIZE_LIBC);
if (module->initialize_libc == NULL) goto dl_error;
// Set fields in the module struct
strncpy(module->name, name, MODULE__MAX_NAME_LENGTH);
strncpy(module->path, path, MODULE__MAX_PATH_LENGTH);
strncpy(module->name, name, MODULE_MAX_NAME_LENGTH);
strncpy(module->path, path, MODULE_MAX_PATH_LENGTH);
module->argument_count = argument_count;
module->stack_size = round_up_to_page(stack_size == 0 ? WASM_STACK_SIZE : stack_size);
@ -136,8 +136,8 @@ module_new(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_m
module->relative_deadline_us = relative_deadline_us;
module->socket_descriptor = -1;
module->port = port;
if (request_size == 0) request_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE;
if (response_size == 0) response_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE;
if (request_size == 0) request_size = MODULE_DEFAULT_REQUEST_RESPONSE_SIZE;
if (response_size == 0) response_size = MODULE_DEFAULT_REQUEST_RESPONSE_SIZE;
module->max_request_size = request_size;
module->max_response_size = response_size;
module->max_request_or_response_size = round_up_to_page(request_size > response_size ? request_size
@ -214,7 +214,7 @@ module_new_from_json(char *file_name)
// Initialize the Jasmine Parser and an array to hold the tokens
jsmn_parser module_parser;
jsmn_init(&module_parser);
jsmntok_t tokens[JSON__MAX_ELEMENT_SIZE * JSON__MAX_ELEMENT_COUNT];
jsmntok_t tokens[JSON_MAX_ELEMENT_SIZE * JSON_MAX_ELEMENT_COUNT];
// Use Jasmine to parse the JSON
int total_tokens = jsmn_parse(&module_parser, file_buffer, strlen(file_buffer), tokens,
@ -228,12 +228,12 @@ module_new_from_json(char *file_name)
for (int i = 0; i < total_tokens; i++) {
assert(tokens[i].type == JSMN_OBJECT);
char module_name[MODULE__MAX_NAME_LENGTH] = { 0 };
char module_path[MODULE__MAX_PATH_LENGTH] = { 0 };
char *request_headers = (char *)malloc(HTTP__MAX_HEADER_LENGTH * HTTP__MAX_HEADER_COUNT);
memset(request_headers, 0, HTTP__MAX_HEADER_LENGTH * HTTP__MAX_HEADER_COUNT);
char *reponse_headers = (char *)malloc(HTTP__MAX_HEADER_LENGTH * HTTP__MAX_HEADER_COUNT);
memset(reponse_headers, 0, HTTP__MAX_HEADER_LENGTH * HTTP__MAX_HEADER_COUNT);
char module_name[MODULE_MAX_NAME_LENGTH] = { 0 };
char module_path[MODULE_MAX_PATH_LENGTH] = { 0 };
char *request_headers = (char *)malloc(HTTP_MAX_HEADER_LENGTH * HTTP_MAX_HEADER_COUNT);
memset(request_headers, 0, HTTP_MAX_HEADER_LENGTH * HTTP_MAX_HEADER_COUNT);
char *reponse_headers = (char *)malloc(HTTP_MAX_HEADER_LENGTH * HTTP_MAX_HEADER_COUNT);
memset(reponse_headers, 0, HTTP_MAX_HEADER_LENGTH * HTTP_MAX_HEADER_COUNT);
i32 request_size = 0;
i32 response_size = 0;
i32 argument_count = 0;
@ -244,8 +244,8 @@ module_new_from_json(char *file_name)
i32 response_count = 0;
int j = 1;
int ntoks = 2 * tokens[i].size;
char request_content_type[HTTP__MAX_HEADER_VALUE_LENGTH] = { 0 };
char response_content_type[HTTP__MAX_HEADER_VALUE_LENGTH] = { 0 };
char request_content_type[HTTP_MAX_HEADER_VALUE_LENGTH] = { 0 };
char response_content_type[HTTP_MAX_HEADER_VALUE_LENGTH] = { 0 };
for (; j < ntoks;) {
int ntks = 1;
@ -270,28 +270,28 @@ module_new_from_json(char *file_name)
relative_deadline_us = atoi(val);
} else if (strcmp(key, "http-req-headers") == 0) {
assert(tokens[i + j + 1].type == JSMN_ARRAY);
assert(tokens[i + j + 1].size <= HTTP__MAX_HEADER_COUNT);
assert(tokens[i + j + 1].size <= HTTP_MAX_HEADER_COUNT);
request_count = tokens[i + j + 1].size;
ntks += request_count;
ntoks += request_count;
for (int k = 1; k <= tokens[i + j + 1].size; k++) {
jsmntok_t *g = &tokens[i + j + k + 1];
char * r = request_headers + ((k - 1) * HTTP__MAX_HEADER_LENGTH);
assert(g->end - g->start < HTTP__MAX_HEADER_LENGTH);
char * r = request_headers + ((k - 1) * HTTP_MAX_HEADER_LENGTH);
assert(g->end - g->start < HTTP_MAX_HEADER_LENGTH);
strncpy(r, file_buffer + g->start, g->end - g->start);
}
} else if (strcmp(key, "http-resp-headers") == 0) {
assert(tokens[i + j + 1].type == JSMN_ARRAY);
assert(tokens[i + j + 1].size <= HTTP__MAX_HEADER_COUNT);
assert(tokens[i + j + 1].size <= HTTP_MAX_HEADER_COUNT);
response_count = tokens[i + j + 1].size;
ntks += response_count;
ntoks += response_count;
for (int k = 1; k <= tokens[i + j + 1].size; k++) {
jsmntok_t *g = &tokens[i + j + k + 1];
char * r = reponse_headers + ((k - 1) * HTTP__MAX_HEADER_LENGTH);
assert(g->end - g->start < HTTP__MAX_HEADER_LENGTH);
char * r = reponse_headers + ((k - 1) * HTTP_MAX_HEADER_LENGTH);
assert(g->end - g->start < HTTP_MAX_HEADER_LENGTH);
strncpy(r, file_buffer + g->start, g->end - g->start);
}
} else if (strcmp(key, "http-req-size") == 0) {

@ -6,7 +6,7 @@
***************************************/
// In-memory representation of all active modules
struct module *module_database[MODULE__MAX_MODULE_COUNT] = { NULL };
struct module *module_database[MODULE_MAX_MODULE_COUNT] = { NULL };
// First free in module
int module_database_free_offset = 0;

@ -22,6 +22,7 @@
#include <sandbox_request.h>
#include <software_interrupt.h>
#include <types.h>
#include <util.h>
/***************************
* Shared Process State *
@ -49,7 +50,7 @@ runtime_initialize(void)
runtime_global_deque = (struct deque_sandbox *)malloc(sizeof(struct deque_sandbox));
assert(runtime_global_deque);
// Note: Below is a Macro
deque_init_sandbox(runtime_global_deque, RUNTIME__MAX_SANDBOX_REQUEST_COUNT);
deque_init_sandbox(runtime_global_deque, RUNTIME_MAX_SANDBOX_REQUEST_COUNT);
// Mask Signals
software_interrupt_mask_signal(SIGUSR1);
@ -76,14 +77,14 @@ runtime_initialize(void)
void *
listener_thread_main(void *dummy)
{
struct epoll_event *epoll_events = (struct epoll_event *)malloc(LISTENER_THREAD__MAX_EPOLL_EVENTS
struct epoll_event *epoll_events = (struct epoll_event *)malloc(LISTENER_THREAD_MAX_EPOLL_EVENTS
* sizeof(struct epoll_event));
int total_requests = 0;
while (true) {
int request_count = epoll_wait(runtime_epoll_file_descriptor, epoll_events,
LISTENER_THREAD__MAX_EPOLL_EVENTS, -1);
u64 start_time = __getcycles();
LISTENER_THREAD_MAX_EPOLL_EVENTS, -1);
u64 start_time = util_rdtsc();
for (int i = 0; i < request_count; i++) {
if (epoll_events[i].events & EPOLLERR) {
perror("epoll_wait");
@ -103,11 +104,11 @@ listener_thread_main(void *dummy)
total_requests++;
sandbox_request_t *sandbox_request =
sandbox_request__allocate(module, module->name, socket_descriptor,
(const struct sockaddr *)&client_address, start_time);
sandbox_request_allocate(module, module->name, socket_descriptor,
(const struct sockaddr *)&client_address, start_time);
assert(sandbox_request);
// TODO: Refactor sandbox_request__allocate to not add to global request queue and do this here
// TODO: Refactor sandbox_request_allocate to not add to global request queue and do this here
}
}
@ -125,7 +126,7 @@ listener_thread_initialize(void)
cpu_set_t cs;
CPU_ZERO(&cs);
CPU_SET(LISTENER_THREAD__CORE_ID, &cs);
CPU_SET(LISTENER_THREAD_CORE_ID, &cs);
pthread_t listener_thread;
int ret = pthread_create(&listener_thread, NULL, listener_thread_main, NULL);
@ -252,8 +253,7 @@ worker_thread_process_io(void)
/**
* TODO: What is this doing?
**/
void __attribute__((noinline)) __attribute__((noreturn))
worker_thread_sandbox_switch_preempt(void)
void __attribute__((noinline)) __attribute__((noreturn)) worker_thread_sandbox_switch_preempt(void)
{
pthread_kill(pthread_self(), SIGUSR1);
@ -264,7 +264,7 @@ worker_thread_sandbox_switch_preempt(void)
/**
* Pulls up to 1..n sandbox requests, allocates them as sandboxes, sets them as runnable and places them on the local
* runqueue, and then frees the sandbox requests The batch size pulled at once is set by SANDBOX__PULL_BATCH_SIZE
* runqueue, and then frees the sandbox requests The batch size pulled at once is set by SANDBOX_PULL_BATCH_SIZE
* @return the number of sandbox requests pulled
*/
static inline int
@ -272,9 +272,9 @@ worker_thread_pull_and_process_sandbox_requests(void)
{
int total_sandboxes_pulled = 0;
while (total_sandboxes_pulled < SANDBOX__PULL_BATCH_SIZE) {
while (total_sandboxes_pulled < SANDBOX_PULL_BATCH_SIZE) {
sandbox_request_t *sandbox_request;
if ((sandbox_request = sandbox_request__steal_from_dequeue()) == NULL) break;
if ((sandbox_request = sandbox_request_steal_from_dequeue()) == NULL) break;
// Actually allocate the sandbox for the requests that we've pulled
struct sandbox *sandbox = sandbox_allocate(sandbox_request->module, sandbox_request->arguments,
sandbox_request->socket_descriptor,

@ -7,6 +7,7 @@
#include <uv.h>
#include <libuv_callbacks.h>
#include <current_sandbox.h>
#include <util.h>
/**
* Takes the arguments from the sandbox struct and writes them into the WebAssembly linear memory
@ -28,7 +29,7 @@ current_sandbox_setup_arguments(i32 argument_count)
i32 string_off = curr->arguments_offset + (argument_count * sizeof(i32));
for (int i = 0; i < argument_count; i++) {
char * arg = arguments + (i * MODULE__MAX_ARGUMENT_SIZE);
char * arg = arguments + (i * MODULE_MAX_ARGUMENT_SIZE);
size_t str_sz = strlen(arg) + 1;
array_ptr[i] = string_off;
@ -108,38 +109,39 @@ current_sandbox_build_and_send_client_response(void)
{
int sndsz = 0;
struct sandbox *curr = current_sandbox_get();
int response_header_length = strlen(HTTP__RESPONSE_200_OK) + strlen(HTTP__RESPONSE_CONTENT_TYPE)
+ strlen(HTTP__RESPONSE_CONTENT_LENGTH);
int response_header_length = strlen(HTTP_RESPONSE_200_OK) + strlen(HTTP_RESPONSE_CONTENT_TYPE)
+ strlen(HTTP_RESPONSE_CONTENT_LENGTH);
int body_length = curr->request_response_data_length - response_header_length;
memset(curr->request_response_data, 0,
strlen(HTTP__RESPONSE_200_OK) + strlen(HTTP__RESPONSE_CONTENT_TYPE)
+ strlen(HTTP__RESPONSE_CONTENT_LENGTH));
strncpy(curr->request_response_data, HTTP__RESPONSE_200_OK, strlen(HTTP__RESPONSE_200_OK));
sndsz += strlen(HTTP__RESPONSE_200_OK);
strlen(HTTP_RESPONSE_200_OK) + strlen(HTTP_RESPONSE_CONTENT_TYPE)
+ strlen(HTTP_RESPONSE_CONTENT_LENGTH));
strncpy(curr->request_response_data, HTTP_RESPONSE_200_OK, strlen(HTTP_RESPONSE_200_OK));
sndsz += strlen(HTTP_RESPONSE_200_OK);
if (body_length == 0) goto done;
strncpy(curr->request_response_data + sndsz, HTTP__RESPONSE_CONTENT_TYPE, strlen(HTTP__RESPONSE_CONTENT_TYPE));
strncpy(curr->request_response_data + sndsz, HTTP_RESPONSE_CONTENT_TYPE, strlen(HTTP_RESPONSE_CONTENT_TYPE));
if (strlen(curr->module->response_content_type) <= 0) {
strncpy(curr->request_response_data + sndsz + strlen("Content-type: "),
HTTP__RESPONSE_CONTENT_TYPE_PLAIN, strlen(HTTP__RESPONSE_CONTENT_TYPE_PLAIN));
HTTP_RESPONSE_CONTENT_TYPE_PLAIN, strlen(HTTP_RESPONSE_CONTENT_TYPE_PLAIN));
} else {
strncpy(curr->request_response_data + sndsz + strlen("Content-type: "),
curr->module->response_content_type, strlen(curr->module->response_content_type));
}
sndsz += strlen(HTTP__RESPONSE_CONTENT_TYPE);
sndsz += strlen(HTTP_RESPONSE_CONTENT_TYPE);
char len[10] = { 0 };
sprintf(len, "%d", body_length);
strncpy(curr->request_response_data + sndsz, HTTP__RESPONSE_CONTENT_LENGTH,
strlen(HTTP__RESPONSE_CONTENT_LENGTH));
strncpy(curr->request_response_data + sndsz, HTTP_RESPONSE_CONTENT_LENGTH,
strlen(HTTP_RESPONSE_CONTENT_LENGTH));
strncpy(curr->request_response_data + sndsz + strlen("Content-length: "), len, strlen(len));
sndsz += strlen(HTTP__RESPONSE_CONTENT_LENGTH);
sndsz += strlen(HTTP_RESPONSE_CONTENT_LENGTH);
sndsz += body_length;
done:
assert(sndsz == curr->request_response_data_length);
// Get End Timestamp
curr->total_time = __getcycles() - curr->start_time;
curr->total_time = util_rdtsc() - curr->start_time;
printf("Function returned in %lu cycles\n", curr->total_time);
#ifndef USE_HTTP_UVIO
int r = send(curr->client_socket_descriptor, curr->request_response_data, sndsz, 0);
@ -205,8 +207,8 @@ current_sandbox_main(void)
current_sandbox->http_parser.data = current_sandbox;
// NOTE: if more headers, do offset by that!
int response_header_length = strlen(HTTP__RESPONSE_200_OK) + strlen(HTTP__RESPONSE_CONTENT_TYPE)
+ strlen(HTTP__RESPONSE_CONTENT_LENGTH);
int response_header_length = strlen(HTTP_RESPONSE_200_OK) + strlen(HTTP_RESPONSE_CONTENT_TYPE)
+ strlen(HTTP_RESPONSE_CONTENT_LENGTH);
#ifdef USE_HTTP_UVIO
@ -319,7 +321,7 @@ sandbox_allocate(struct module *module, char *arguments, int socket_descriptor,
}
sandbox->client_socket_descriptor = socket_descriptor;
if (socket_address) memcpy(&sandbox->client_address, socket_address, sizeof(struct sockaddr));
for (int i = 0; i < SANDBOX__MAX_IO_HANDLE_COUNT; i++) sandbox->io_handles[i].file_descriptor = -1;
for (int i = 0; i < SANDBOX_MAX_IO_HANDLE_COUNT; i++) sandbox->io_handles[i].file_descriptor = -1;
ps_list_init_d(sandbox);
// Setup the sandbox's context, stack, and instruction pointer

@ -64,7 +64,7 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
if (signal_info->si_code == SI_KERNEL) {
int rt = 0;
// deliver signal to all other runtime threads..
for (int i = 0; i < WORKER_THREAD__CORE_COUNT; i++) {
for (int i = 0; i < WORKER_THREAD_CORE_COUNT; i++) {
if (pthread_self() == runtime_worker_threads[i]) {
rt = 1;
continue;
@ -161,8 +161,8 @@ software_interrupt_arm_timer(void)
struct itimerval interval_timer;
memset(&interval_timer, 0, sizeof(struct itimerval));
interval_timer.it_value.tv_usec = SOFTWARE_INTERRUPT__TIME_TO_START_IN_USEC;
interval_timer.it_interval.tv_usec = SOFTWARE_INTERRUPT__INTERVAL_DURATION_IN_USEC;
interval_timer.it_value.tv_usec = SOFTWARE_INTERRUPT_TIME_TO_START_IN_USEC;
interval_timer.it_interval.tv_usec = SOFTWARE_INTERRUPT_INTERVAL_DURATION_IN_USEC;
int return_code = setitimer(ITIMER_REAL, &interval_timer, NULL);
if (return_code) {

@ -13,9 +13,9 @@ main(void)
char *d = malloc(MAX_BUF + 1);
int r = read(0, d, MAX_BUF);
// unsigned long long st = getcycles(), en = 0;
// unsigned long long st = util_rdtsc(), en = 0;
// wrk();
// en = getcycles();
// en = util_rdtsc();
// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1);
if (r < 0)

@ -11,9 +11,9 @@ main(void)
char *d = malloc(MAX_BUF + 1);
int r = read(0, d, MAX_BUF);
// unsigned long long st = getcycles(), en = 0;
// unsigned long long st = util_rdtsc(), en = 0;
// wrk();
// en = getcycles();
// en = util_rdtsc();
// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1);
if (r < 0)

@ -11,9 +11,9 @@ main(void)
char *d = malloc(MAX_BUF + 1);
int r = read(0, d, MAX_BUF);
// unsigned long long st = getcycles(), en = 0;
// unsigned long long st = util_rdtsc(), en = 0;
// wrk();
// en = getcycles();
// en = util_rdtsc();
// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1);
if (r < 0)

@ -11,9 +11,9 @@ main(void)
char *d = malloc(MAX_BUF + 1);
int r = read(0, d, MAX_BUF);
// unsigned long long st = getcycles(), en = 0;
// unsigned long long st = util_rdtsc(), en = 0;
// wrk();
// en = getcycles();
// en = util_rdtsc();
// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1);
if (r < 0)

@ -11,9 +11,9 @@ main(void)
char *d = malloc(MAX_BUF + 1);
int r = read(0, d, MAX_BUF);
// unsigned long long st = getcycles(), en = 0;
// unsigned long long st = util_rdtsc(), en = 0;
// wrk();
// en = getcycles();
// en = util_rdtsc();
// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1);
if (r < 0)

Loading…
Cancel
Save