From d6f10cac7a5226120a31775a6ade1e2472b3d78a Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Tue, 28 Jul 2020 20:39:09 -0400 Subject: [PATCH] refactor: decompose types.h --- runtime/include/current_sandbox.h | 1 - runtime/include/debuglog.h | 25 +++++ runtime/include/http.h | 5 + runtime/include/http_request.h | 2 +- runtime/include/http_response.h | 12 ++- runtime/include/module.h | 18 ++++ runtime/include/runtime.h | 7 ++ runtime/include/sandbox.h | 25 +++-- runtime/include/sandbox_request.h | 2 +- runtime/include/software_interrupt.h | 3 + runtime/include/types.h | 106 ++----------------- runtime/include/worker_thread.h | 4 +- runtime/src/arch_context.c | 6 +- runtime/src/current_sandbox.c | 1 - runtime/src/env.c | 2 + runtime/src/global_request_scheduler_deque.c | 1 + runtime/src/http_parser_settings.c | 1 + runtime/src/http_response.c | 5 +- runtime/src/libc/uvio.c | 2 +- runtime/src/local_runqueue_list.c | 1 + runtime/src/local_runqueue_minheap.c | 1 + runtime/src/main.c | 9 +- runtime/src/memory/common.c | 3 + runtime/src/module.c | 7 +- runtime/src/runtime.c | 1 - runtime/src/sandbox.c | 6 +- runtime/src/software_interrupt.c | 2 +- runtime/src/worker_thread.c | 2 +- 28 files changed, 125 insertions(+), 135 deletions(-) create mode 100644 runtime/include/debuglog.h create mode 100644 runtime/include/http.h diff --git a/runtime/include/current_sandbox.h b/runtime/include/current_sandbox.h index a0d47b4..655dc1d 100644 --- a/runtime/include/current_sandbox.h +++ b/runtime/include/current_sandbox.h @@ -1,7 +1,6 @@ #pragma once #include "sandbox.h" -#include "types.h" void current_sandbox_close_file_descriptor(int io_handle_index); struct sandbox * current_sandbox_get(void); diff --git a/runtime/include/debuglog.h b/runtime/include/debuglog.h new file mode 100644 index 0000000..572816e --- /dev/null +++ b/runtime/include/debuglog.h @@ -0,0 +1,25 @@ +#pragma once + +#include + +extern int32_t debuglog_file_descriptor; + +/** + * debuglog is a macro that behaves based on the macros DEBUG and LOG_TO_FILE + * If DEBUG is not set, debuglog does nothing + * If DEBUG is set and LOG_TO_FILE is set, debuglog prints to the logfile defined in debuglog_file_descriptor + * If DEBUG is set and LOG_TO_FILE is not set, debuglog prints to STDOUT + */ +#ifdef DEBUG +#ifdef LOG_TO_FILE +#define debuglog(fmt, ...) \ + dprintf(debuglog_file_descriptor, "C: %02d, T: 0x%lx, F: %s> \n\t" fmt "\n", sched_getcpu(), pthread_self(), \ + __func__, ##__VA_ARGS__); +#else /* !LOG_TO_FILE */ +#define debuglog(fmt, ...) \ + fprintf(stderr, "C: %02d, T: 0x%lx, F: %s> \n\t" fmt "\n", sched_getcpu(), pthread_self(), __func__, \ + ##__VA_ARGS__); +#endif /* LOG_TO_FILE */ +#else /* !DEBUG */ +#define debuglog(fmt, ...) +#endif /* DEBUG */ diff --git a/runtime/include/http.h b/runtime/include/http.h new file mode 100644 index 0000000..bb42eae --- /dev/null +++ b/runtime/include/http.h @@ -0,0 +1,5 @@ +#pragma once + +#define HTTP_MAX_HEADER_COUNT 16 +#define HTTP_MAX_HEADER_LENGTH 32 +#define HTTP_MAX_HEADER_VALUE_LENGTH 64 diff --git a/runtime/include/http_request.h b/runtime/include/http_request.h index f82b5ab..ad38c15 100644 --- a/runtime/include/http_request.h +++ b/runtime/include/http_request.h @@ -1,6 +1,6 @@ #pragma once -#include "types.h" +#include "http.h" /* all in-memory ptrs.. don't mess around with that! */ struct http_header { diff --git a/runtime/include/http_response.h b/runtime/include/http_response.h index b738e5b..f8b705e 100644 --- a/runtime/include/http_response.h +++ b/runtime/include/http_response.h @@ -2,14 +2,20 @@ #include #include - -#include "types.h" - /* Conditionally load libuv */ #ifdef USE_HTTP_UVIO #include #endif +#include "http.h" + +#define HTTP_RESPONSE_200_OK "HTTP/1.1 200 OK\r\n" +#define HTTP_RESPONSE_CONTENT_LENGTH "Content-Length: " +#define HTTP_RESPONSE_CONTENT_LENGTH_TERMINATOR "\r\n\r\n" /* content body follows this */ +#define HTTP_RESPONSE_CONTENT_TYPE "Content-Type: " +#define HTTP_RESPONSE_CONTENT_TYPE_PLAIN "text/plain" +#define HTTP_RESPONSE_CONTENT_TYPE_TERMINATOR " \r\n" + struct http_response_header { char *header; int length; diff --git a/runtime/include/module.h b/runtime/include/module.h index 56879f2..6fed543 100644 --- a/runtime/include/module.h +++ b/runtime/include/module.h @@ -1,11 +1,29 @@ #pragma once +#include #include +#include "http.h" #include "panic.h" #include "software_interrupt.h" #include "types.h" +/* Wasm initialization functions generated by the compiler */ +#define MODULE_INITIALIZE_GLOBALS "populate_globals" +#define MODULE_INITIALIZE_MEMORY "populate_memory" +#define MODULE_INITIALIZE_TABLE "populate_table" +#define MODULE_INITIALIZE_LIBC "wasmf___init_libc" +#define MODULE_MAIN "wasmf_main" + +#define MODULE_DEFAULT_REQUEST_RESPONSE_SIZE (PAGE_SIZE) + +#define MODULE_MAX_ARGUMENT_COUNT 16 +#define MODULE_MAX_ARGUMENT_SIZE 64 +#define MODULE_MAX_MODULE_COUNT 128 +#define MODULE_MAX_NAME_LENGTH 32 +#define MODULE_MAX_PATH_LENGTH 256 +#define MODULE_MAX_PENDING_CLIENT_REQUESTS 1000 + struct module { char name[MODULE_MAX_NAME_LENGTH]; char path[MODULE_MAX_PATH_LENGTH]; diff --git a/runtime/include/runtime.h b/runtime/include/runtime.h index 2547377..96fddfa 100644 --- a/runtime/include/runtime.h +++ b/runtime/include/runtime.h @@ -3,6 +3,13 @@ #include /* for epoll_create1(), epoll_ctl(), struct epoll_event */ #include "types.h" +#define LISTENER_THREAD_CORE_ID 0 /* Dedicated Listener Core */ +#define LISTENER_THREAD_MAX_EPOLL_EVENTS 1024 + +#define RUNTIME_LOG_FILE "awesome.log" +#define RUNTIME_MAX_SANDBOX_REQUEST_COUNT (1 << 19) /* random! */ +#define RUNTIME_READ_WRITE_VECTOR_LENGTH 16 + extern int runtime_epoll_file_descriptor; extern uint32_t runtime_total_worker_processors; diff --git a/runtime/include/sandbox.h b/runtime/include/sandbox.h index 17759b6..125d2c8 100644 --- a/runtime/include/sandbox.h +++ b/runtime/include/sandbox.h @@ -3,16 +3,21 @@ #include #include #include -#include "sandbox_request.h" #include "arch/context.h" +#include "debuglog.h" #include "deque.h" #include "http_request.h" #include "http_response.h" #include "module.h" #include "ps_list.h" +#include "sandbox_request.h" #include "software_interrupt.h" +#define SANDBOX_FILE_DESCRIPTOR_PREOPEN_MAGIC (707707707) /* upside down LOLLOLLOL 🤣😂🤣*/ +#define SANDBOX_MAX_IO_HANDLE_COUNT 32 +#define SANDBOX_MAX_MEMORY (1L << 32) /* 4GB */ + /********************* * Structs and Types * ********************/ @@ -323,12 +328,12 @@ sandbox_print_perf(struct sandbox *sandbox) queued_us, initializing_us, runnable_us, running_us, blocked_us, returned_us); } -void sandbox_set_as_initialized(struct sandbox *sandbox, struct sandbox_request *sandbox_request, - uint64_t allocation_timestamp) __attribute__((always_inline)); -void sandbox_set_as_runnable(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); -void sandbox_set_as_running(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); -void sandbox_set_as_blocked(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); -void sandbox_set_as_preempted(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); -void sandbox_set_as_returned(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); -void sandbox_set_as_complete(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); -void sandbox_set_as_error(struct sandbox *sandbox, sandbox_state_t last_state) __attribute__((always_inline)); +INLINE void sandbox_set_as_initialized(struct sandbox *sandbox, struct sandbox_request *sandbox_request, + uint64_t allocation_timestamp); +INLINE void sandbox_set_as_runnable(struct sandbox *sandbox, sandbox_state_t last_state); +INLINE void sandbox_set_as_running(struct sandbox *sandbox, sandbox_state_t last_state); +INLINE void sandbox_set_as_blocked(struct sandbox *sandbox, sandbox_state_t last_state); +INLINE void sandbox_set_as_preempted(struct sandbox *sandbox, sandbox_state_t last_state); +INLINE void sandbox_set_as_returned(struct sandbox *sandbox, sandbox_state_t last_state); +INLINE void sandbox_set_as_complete(struct sandbox *sandbox, sandbox_state_t last_state); +INLINE void sandbox_set_as_error(struct sandbox *sandbox, sandbox_state_t last_state); diff --git a/runtime/include/sandbox_request.h b/runtime/include/sandbox_request.h index de6e557..4fdd5c0 100644 --- a/runtime/include/sandbox_request.h +++ b/runtime/include/sandbox_request.h @@ -2,10 +2,10 @@ #include +#include "debuglog.h" #include "deque.h" #include "module.h" #include "runtime.h" -#include "types.h" extern float runtime_processor_speed_MHz; diff --git a/runtime/include/software_interrupt.h b/runtime/include/software_interrupt.h index ff02547..9412dbc 100644 --- a/runtime/include/software_interrupt.h +++ b/runtime/include/software_interrupt.h @@ -8,6 +8,9 @@ #include #include +#define SOFTWARE_INTERRUPT_TIME_TO_START_IN_USEC (10 * 1000) /* 10 ms */ +#define SOFTWARE_INTERRUPT_INTERVAL_DURATION_IN_USEC (5 * 1000) /* 5 ms */ + /************ * Externs * ***********/ diff --git a/runtime/include/types.h b/runtime/include/types.h index 780205e..5b30b24 100644 --- a/runtime/include/types.h +++ b/runtime/include/types.h @@ -1,34 +1,13 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -#include -#include -#include -#include -#include -#define EXPORT __attribute__((visibility("default"))) -#define IMPORT __attribute__((visibility("default"))) - -#define INLINE __attribute__((always_inline)) -#define WEAK __attribute__((weak)) #ifndef PAGE_SIZE #define PAGE_SIZE (1 << 12) #endif -#define PAGE_ALIGNED __attribute__((aligned(PAGE_SIZE))) - /* For this family of macros, do NOT pass zero as the pow2 */ #define round_to_pow2(x, pow2) (((unsigned long)(x)) & (~((pow2)-1))) #define round_up_to_pow2(x, pow2) (round_to_pow2(((unsigned long)x) + (pow2)-1, (pow2))) @@ -36,21 +15,22 @@ #define round_to_page(x) round_to_pow2(x, PAGE_SIZE) #define round_up_to_page(x) round_up_to_pow2(x, PAGE_SIZE) +#define EXPORT __attribute__((visibility("default"))) +#define IMPORT __attribute__((visibility("default"))) +#define INLINE __attribute__((always_inline)) +#define PAGE_ALIGNED __attribute__((aligned(PAGE_SIZE))) +#define WEAK __attribute__((weak)) + /* FIXME: per-module configuration? */ #define WASM_PAGE_SIZE (1024 * 64) /* 64KB */ #define WASM_START_PAGES (1 << 8) /* 16MB */ #define WASM_MAX_PAGES (1 << 15) /* 4GB */ #define WASM_STACK_SIZE (1 << 19) /* 512KB */ -#define SBOX_MAX_MEM (1L << 32) /* 4GB */ /* These are per module symbols and I'd need to dlsym for each module. instead just use global constants, see above macros. The code generator compiles in the starting number of wasm pages, and the maximum number of pages If we try and allocate more than max_pages, we should fault */ -// TODO: Should this be deleted? -// extern uint32_t starting_pages; -// extern uint32_t max_pages; - /* The code generator also compiles in stubs that populate the linear memory and function table */ void populate_memory(void); void populate_table(void); @@ -72,83 +52,9 @@ struct sandbox_context_cache { extern __thread struct sandbox_context_cache local_sandbox_context_cache; -/* TODO: LOG_TO_FILE logic is untested */ -extern int32_t runtime_log_file_descriptor; - /* functions in the module to lookup and call per sandbox. */ typedef int32_t (*mod_main_fn_t)(int32_t a, int32_t b); typedef void (*mod_glb_fn_t)(void); typedef void (*mod_mem_fn_t)(void); typedef void (*mod_tbl_fn_t)(void); typedef void (*mod_libc_fn_t)(int32_t, int32_t); - -/** - * debuglog is a macro that behaves based on the macros DEBUG and LOG_TO_FILE - * If DEBUG is not set, debuglog does nothing - * If DEBUG is set and LOG_TO_FILE is set, debuglog prints to the logfile defined in runtime_log_file_descriptor - * If DEBUG is set adn LOG_TO_FILE is not set, debuglog prints to STDOUT - */ -#ifdef DEBUG -#ifdef LOG_TO_FILE -#define debuglog(fmt, ...) \ - dprintf(runtime_log_file_descriptor, "C: %02d, T: 0x%lx, F: %s> \n\t" fmt "\n", sched_getcpu(), \ - pthread_self(), __func__, ##__VA_ARGS__); -#else /* !LOG_TO_FILE */ -#define debuglog(fmt, ...) \ - fprintf(stderr, "C: %02d, T: 0x%lx, F: %s> \n\t" fmt "\n", sched_getcpu(), pthread_self(), __func__, \ - ##__VA_ARGS__); -#endif /* LOG_TO_FILE */ -#else /* !DEBUG */ -#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: " -#define HTTP_RESPONSE_CONTENT_LENGTH_TERMINATOR "\r\n\r\n" /* content body follows this */ - - -#define HTTP_RESPONSE_CONTENT_TYPE "Content-Type: " -#define HTTP_RESPONSE_CONTENT_TYPE_PLAIN "text/plain" -#define HTTP_RESPONSE_CONTENT_TYPE_TERMINATOR " \r\n" - -#define JSON_MAX_ELEMENT_COUNT 16 -#define JSON_MAX_ELEMENT_SIZE 1024 - -#define LISTENER_THREAD_CORE_ID 0 /* Dedicated Listener Core */ -#define LISTENER_THREAD_MAX_EPOLL_EVENTS 1024 - -#define MODULE_DEFAULT_REQUEST_RESPONSE_SIZE (PAGE_SIZE) - -/* Wasm initialization functions generated by the compiler */ -#define MODULE_INITIALIZE_GLOBALS "populate_globals" -#define MODULE_INITIALIZE_MEMORY "populate_memory" -#define MODULE_INITIALIZE_TABLE "populate_table" -#define MODULE_INITIALIZE_LIBC "wasmf___init_libc" -#define MODULE_MAIN "wasmf_main" - -#define MODULE_MAX_ARGUMENT_COUNT 16 -#define MODULE_MAX_ARGUMENT_SIZE 64 -#define MODULE_MAX_MODULE_COUNT 128 -#define MODULE_MAX_NAME_LENGTH 32 -#define MODULE_MAX_PATH_LENGTH 256 -#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) /* upside down LOLLOLLOL 🤣😂🤣*/ -#define SANDBOX_MAX_IO_HANDLE_COUNT 32 - -#define SOFTWARE_INTERRUPT_TIME_TO_START_IN_USEC (10 * 1000) /* 10 ms */ -#define SOFTWARE_INTERRUPT_INTERVAL_DURATION_IN_USEC (5 * 1000) /* 5 ms */ - -/* - * The runtime explicitly requires at least two cores, allocating all as worker threads - * minus the dedicated listener core - */ -#define WORKER_THREAD_CORE_COUNT (NCORES - 1) diff --git a/runtime/include/worker_thread.h b/runtime/include/worker_thread.h index c4747b1..227de57 100644 --- a/runtime/include/worker_thread.h +++ b/runtime/include/worker_thread.h @@ -2,7 +2,9 @@ #include -#include "types.h" +/* 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) extern __thread uv_loop_t worker_thread_uvio_handle; diff --git a/runtime/src/arch_context.c b/runtime/src/arch_context.c index e2874e8..1e8befc 100644 --- a/runtime/src/arch_context.c +++ b/runtime/src/arch_context.c @@ -1,7 +1,7 @@ -#include +#include #include - -#include "types.h" +#include +#include /** * Called by the inline assembly in arch_context_switch to send a SIGUSR1 in order to restore a previously preempted diff --git a/runtime/src/current_sandbox.c b/runtime/src/current_sandbox.c index 873b900..5eb0497 100644 --- a/runtime/src/current_sandbox.c +++ b/runtime/src/current_sandbox.c @@ -1,5 +1,4 @@ #include "current_sandbox.h" -#include "types.h" /* current sandbox that is active.. */ static __thread struct sandbox *worker_thread_current_sandbox = NULL; diff --git a/runtime/src/env.c b/runtime/src/env.c index c15acfd..6dc722f 100644 --- a/runtime/src/env.c +++ b/runtime/src/env.c @@ -1,5 +1,7 @@ /* https://github.com/gwsystems/silverfish/blob/master/runtime/libc/libc_backing.c */ +#include #include +#include #include "runtime.h" #include "worker_thread.h" diff --git a/runtime/src/global_request_scheduler_deque.c b/runtime/src/global_request_scheduler_deque.c index b31c86b..b202bc2 100644 --- a/runtime/src/global_request_scheduler_deque.c +++ b/runtime/src/global_request_scheduler_deque.c @@ -1,4 +1,5 @@ #include "global_request_scheduler.h" +#include "runtime.h" static struct deque_sandbox *global_request_scheduler_deque; static pthread_mutex_t global_request_scheduler_deque_mutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/runtime/src/http_parser_settings.c b/runtime/src/http_parser_settings.c index ee0f296..5aa63f8 100644 --- a/runtime/src/http_parser_settings.c +++ b/runtime/src/http_parser_settings.c @@ -1,5 +1,6 @@ #include +#include "http.h" #include "http_request.h" #include "http_response.h" #include "http_parser_settings.h" diff --git a/runtime/src/http_response.c b/runtime/src/http_response.c index d2dbb7f..df78a09 100644 --- a/runtime/src/http_response.c +++ b/runtime/src/http_response.c @@ -1,9 +1,10 @@ -#include "http_response.h" - +#include #ifdef USE_HTTP_UVIO #include #endif +#include "http_response.h" + /*************************************************** * General HTTP Response Functions * **************************************************/ diff --git a/runtime/src/libc/uvio.c b/runtime/src/libc/uvio.c index 185ff7d..f96e934 100644 --- a/runtime/src/libc/uvio.c +++ b/runtime/src/libc/uvio.c @@ -1,11 +1,11 @@ #include #include "current_sandbox.h" +#include "debuglog.h" #include "http_request.h" #include "panic.h" #include "runtime.h" #include "sandbox.h" -#include "types.h" #include "worker_thread.h" // What should we tell the child program its UID and GID are? diff --git a/runtime/src/local_runqueue_list.c b/runtime/src/local_runqueue_list.c index 2f362ad..8e84cfa 100644 --- a/runtime/src/local_runqueue_list.c +++ b/runtime/src/local_runqueue_list.c @@ -1,3 +1,4 @@ +#include "debuglog.h" #include "local_runqueue_list.h" #include "local_runqueue.h" #include "global_request_scheduler.h" diff --git a/runtime/src/local_runqueue_minheap.c b/runtime/src/local_runqueue_minheap.c index 93cdb8c..76b12fb 100644 --- a/runtime/src/local_runqueue_minheap.c +++ b/runtime/src/local_runqueue_minheap.c @@ -1,6 +1,7 @@ #include #include "current_sandbox.h" +#include "debuglog.h" #include "global_request_scheduler.h" #include "local_runqueue.h" #include "local_runqueue_minheap.h" diff --git a/runtime/src/main.c b/runtime/src/main.c index 7743ffd..27589d4 100644 --- a/runtime/src/main.c +++ b/runtime/src/main.c @@ -8,6 +8,7 @@ #include #include +#include "debuglog.h" #include "module.h" #include "panic.h" #include "runtime.h" @@ -17,7 +18,7 @@ /* Conditionally used by debuglog when DEBUG is set */ #ifdef DEBUG -int32_t runtime_log_file_descriptor = -1; +int32_t debuglog_file_descriptor = -1; #endif float runtime_processor_speed_MHz = 0; @@ -138,13 +139,13 @@ 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); - if (runtime_log_file_descriptor < 0) { + debuglog_file_descriptor = open(RUNTIME_LOG_FILE, O_CREAT | O_TRUNC | O_WRONLY, S_IRWXU | S_IRWXG); + if (debuglog_file_descriptor < 0) { perror("open"); exit(-1); } #else - runtime_log_file_descriptor = 1; + debuglog_file_descriptor = 1; #endif /* LOG_TO_FILE */ } #endif /* DEBUG */ diff --git a/runtime/src/memory/common.c b/runtime/src/memory/common.c index fa120fe..c27dc92 100644 --- a/runtime/src/memory/common.c +++ b/runtime/src/memory/common.c @@ -1,3 +1,6 @@ +#include +#include + #include "runtime.h" #include "types.h" diff --git a/runtime/src/module.c b/runtime/src/module.c index c5b1839..a6ad84c 100644 --- a/runtime/src/module.c +++ b/runtime/src/module.c @@ -3,13 +3,18 @@ #include #include #include +#include #include +#include "debuglog.h" +#include "http.h" #include "module.h" #include "module_database.h" #include "panic.h" #include "runtime.h" -#include "types.h" + +const int JSON_MAX_ELEMENT_COUNT = 16; +const int JSON_MAX_ELEMENT_SIZE = 1024; /************************* * Private Static Inline * diff --git a/runtime/src/runtime.c b/runtime/src/runtime.c index 30105ec..1f64f10 100644 --- a/runtime/src/runtime.c +++ b/runtime/src/runtime.c @@ -12,7 +12,6 @@ #include "runtime.h" #include "sandbox_request.h" #include "software_interrupt.h" -#include "types.h" /*************************** * Shared Process State * diff --git a/runtime/src/sandbox.c b/runtime/src/sandbox.c index 5f6d0d6..c834e0a 100644 --- a/runtime/src/sandbox.c +++ b/runtime/src/sandbox.c @@ -5,6 +5,7 @@ #include #include "current_sandbox.h" +#include "debuglog.h" #include "http_parser_settings.h" #include "libuv_callbacks.h" #include "local_completion_queue.h" @@ -12,7 +13,6 @@ #include "panic.h" #include "runtime.h" #include "sandbox.h" -#include "types.h" #include "worker_thread.h" /** @@ -360,7 +360,7 @@ sandbox_allocate_memory(struct module *module) char * error_message = NULL; unsigned long linear_memory_size = WASM_PAGE_SIZE * WASM_START_PAGES; /* The initial pages */ - uint64_t linear_memory_max_size = (uint64_t)SBOX_MAX_MEM; + uint64_t linear_memory_max_size = (uint64_t)SANDBOX_MAX_MEMORY; struct sandbox *sandbox = NULL; unsigned long sandbox_size = sizeof(struct sandbox) + module->max_request_or_response_size; @@ -835,7 +835,7 @@ err: void sandbox_free_linear_memory(struct sandbox *sandbox) { - int rc = munmap(sandbox->linear_memory_start, SBOX_MAX_MEM + PAGE_SIZE); + int rc = munmap(sandbox->linear_memory_start, SANDBOX_MAX_MEMORY + PAGE_SIZE); if (rc == -1) panic("sandbox_free_linear_memory - munmap failed\n"); } diff --git a/runtime/src/software_interrupt.c b/runtime/src/software_interrupt.c index dc42935..63361cd 100644 --- a/runtime/src/software_interrupt.c +++ b/runtime/src/software_interrupt.c @@ -9,13 +9,13 @@ #include "arch/context.h" #include "current_sandbox.h" +#include "debuglog.h" #include "local_runqueue.h" #include "module.h" #include "panic.h" #include "runtime.h" #include "sandbox.h" #include "software_interrupt.h" -#include "types.h" /******************* * Process Globals * diff --git a/runtime/src/worker_thread.c b/runtime/src/worker_thread.c index 50bd5c2..325a7a7 100644 --- a/runtime/src/worker_thread.c +++ b/runtime/src/worker_thread.c @@ -6,6 +6,7 @@ #include #include "current_sandbox.h" +#include "debuglog.h" #include "global_request_scheduler.h" #include "local_completion_queue.h" #include "local_runqueue.h" @@ -13,7 +14,6 @@ #include "local_runqueue_minheap.h" #include "panic.h" #include "runtime.h" -#include "types.h" #include "worker_thread.h" /***************************