From a771b78a92bf6e05438b9898a41178e6b71c16ad Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Thu, 19 Mar 2020 11:47:47 -0400 Subject: [PATCH] chore: de-dunder software_interrupt --- runtime/include/software_interrupt.h | 24 ++++++------- runtime/src/runtime.c | 36 ++++++++++---------- runtime/src/sandbox.c | 4 +-- runtime/src/software_interrupt.c | 50 ++++++++++++++-------------- 4 files changed, 57 insertions(+), 57 deletions(-) diff --git a/runtime/include/software_interrupt.h b/runtime/include/software_interrupt.h index d935639..ea8d60f 100644 --- a/runtime/include/software_interrupt.h +++ b/runtime/include/software_interrupt.h @@ -9,16 +9,16 @@ * Externs ***************************************/ -extern __thread volatile sig_atomic_t software_interrupt__is_disabled; +extern __thread volatile sig_atomic_t software_interrupt_is_disabled; /*************************************** * Public Static Inlines ***************************************/ static inline void -software_interrupt__disable(void) +software_interrupt_disable(void) { - while (__sync_bool_compare_and_swap(&software_interrupt__is_disabled, 0, 1) == false) + while (__sync_bool_compare_and_swap(&software_interrupt_is_disabled, 0, 1) == false) ; } @@ -27,18 +27,18 @@ software_interrupt__disable(void) * Enables signals */ static inline void -software_interrupt__enable(void) +software_interrupt_enable(void) { - if (__sync_bool_compare_and_swap(&software_interrupt__is_disabled, 1, 0) == false) assert(0); + if (__sync_bool_compare_and_swap(&software_interrupt_is_disabled, 1, 0) == false) assert(0); } /** * @returns boolean if signals are enabled */ static inline int -software_interrupt__is_enabled(void) +software_interrupt_is_enabled(void) { - return (software_interrupt__is_disabled == 0); + return (software_interrupt_is_disabled == 0); } /** @@ -47,7 +47,7 @@ software_interrupt__is_enabled(void) * @return 0 on success. Exits program otherwise **/ static inline int -software_interrupt__mask_signal(int signal) +software_interrupt_mask_signal(int signal) { sigset_t set; int return_code; @@ -72,7 +72,7 @@ software_interrupt__mask_signal(int signal) * @return 0 on success. Exits program otherwise **/ static inline int -software_interrupt__unmask_signal(int signal) +software_interrupt_unmask_signal(int signal) { sigset_t set; int return_code; @@ -95,8 +95,8 @@ software_interrupt__unmask_signal(int signal) * Exports from module.c ***************************************/ -void software_interrupt__initialize(void); -void software_interrupt__arm_timer(void); -void software_interrupt__disarm_timer(void); +void software_interrupt_initialize(void); +void software_interrupt_arm_timer(void); +void software_interrupt_disarm_timer(void); #endif /* SFRT_SOFTWARE_INTERRUPT_H */ diff --git a/runtime/src/runtime.c b/runtime/src/runtime.c index c52a134..8c740a5 100644 --- a/runtime/src/runtime.c +++ b/runtime/src/runtime.c @@ -53,8 +53,8 @@ runtime_initialize(void) deque_init_sandbox(runtime_global_deque, RUNTIME__MAX_SANDBOX_REQUEST_COUNT); // Mask Signals - software_interrupt__mask_signal(SIGUSR1); - software_interrupt__mask_signal(SIGALRM); + software_interrupt_mask_signal(SIGUSR1); + software_interrupt_mask_signal(SIGALRM); // Initialize http_parser_settings global http_parser_settings_initialize(&runtime_http_parser_settings); @@ -137,8 +137,8 @@ listener_thread_initialize(void) ret = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cs); assert(ret == 0); - software_interrupt__initialize(); - software_interrupt__arm_timer(); + software_interrupt_initialize(); + software_interrupt_arm_timer(); } /*************************** @@ -179,7 +179,7 @@ static inline void worker_thread__switch_to_sandbox(struct sandbox *next_sandbox) { arch_context_t *next_register_context = next_sandbox == NULL ? NULL : &next_sandbox->ctxt; - software_interrupt__disable(); + software_interrupt_disable(); struct sandbox *current_sandbox = current_sandbox_get(); arch_context_t *current_register_context = current_sandbox == NULL ? NULL : ¤t_sandbox->ctxt; current_sandbox_set(next_sandbox); @@ -188,7 +188,7 @@ worker_thread__switch_to_sandbox(struct sandbox *next_sandbox) worker_thread__push_sandbox_to_completion_queue(current_sandbox); worker_thread__next_context = next_register_context; arch_context_switch(current_register_context, next_register_context); - software_interrupt__enable(); + software_interrupt_enable(); } /** @@ -198,7 +198,7 @@ worker_thread__switch_to_sandbox(struct sandbox *next_sandbox) void worker_thread__wakeup_sandbox(sandbox_t *sandbox) { - software_interrupt__disable(); + software_interrupt_disable(); debuglog("[%p: %s]\n", sandbox, sandbox->module->name); if (sandbox->state != BLOCKED) goto done; assert(sandbox->state == BLOCKED); @@ -206,7 +206,7 @@ worker_thread__wakeup_sandbox(sandbox_t *sandbox) sandbox->state = RUNNABLE; ps_list_head_append_d(&worker_thread__run_queue, sandbox); done: - software_interrupt__enable(); + software_interrupt_enable(); } @@ -218,14 +218,14 @@ void worker_thread__block_current_sandbox(void) { assert(worker_thread__is_in_callback == 0); - software_interrupt__disable(); + software_interrupt_disable(); struct sandbox *current_sandbox = current_sandbox_get(); ps_list_rem_d(current_sandbox); current_sandbox->state = BLOCKED; struct sandbox *next_sandbox = worker_thread__get_next_sandbox(0); debuglog("[%p: %next_sandbox, %p: %next_sandbox]\n", current_sandbox, current_sandbox->module->name, next_sandbox, next_sandbox ? next_sandbox->module->name : ""); - software_interrupt__enable(); + software_interrupt_enable(); worker_thread__switch_to_sandbox(next_sandbox); } @@ -406,9 +406,9 @@ worker_thread__execute_runtime_maintenance_and_get_next_sandbox(void) if (!worker_thread__is_in_callback) worker_thread__execute_libuv_event_loop(); // Get and return the sandbox at the head of the thread local runqueue - software_interrupt__disable(); + software_interrupt_disable(); struct sandbox *sandbox = worker_thread__get_next_sandbox(0); - software_interrupt__enable(); + software_interrupt_enable(); assert(sandbox == NULL || sandbox->state == RUNNABLE); return sandbox; } @@ -425,11 +425,11 @@ worker_thread__main(void *return_code) ps_list_head_init(&worker_thread__run_queue); ps_list_head_init(&worker_thread__completion_queue); - software_interrupt__is_disabled = 0; - worker_thread__next_context = NULL; + software_interrupt_is_disabled = 0; + worker_thread__next_context = NULL; #ifndef PREEMPT_DISABLE - software_interrupt__unmask_signal(SIGALRM); - software_interrupt__unmask_signal(SIGUSR1); + software_interrupt_unmask_signal(SIGALRM); + software_interrupt_unmask_signal(SIGUSR1); #endif uv_loop_init(&worker_thread__uvio_handle); worker_thread__is_in_callback = 0; @@ -457,13 +457,13 @@ worker_thread__exit_current_sandbox(void) { struct sandbox *current_sandbox = current_sandbox_get(); assert(current_sandbox); - software_interrupt__disable(); + software_interrupt_disable(); worker_thread__pop_sandbox_from_run_queue(current_sandbox); current_sandbox->state = RETURNED; struct sandbox *next_sandbox = worker_thread__get_next_sandbox(0); assert(next_sandbox != current_sandbox); - software_interrupt__enable(); + software_interrupt_enable(); // free resources from "main function execution", as stack still in use. // unmap linear memory only! munmap(current_sandbox->linear_memory_start, SBOX_MAX_MEM + PAGE_SIZE); diff --git a/runtime/src/sandbox.c b/runtime/src/sandbox.c index 992af7c..29d8801 100644 --- a/runtime/src/sandbox.c +++ b/runtime/src/sandbox.c @@ -181,10 +181,10 @@ current_sandbox_main(void) // FIXME: is this right? this is the first time this sandbox is running.. so it wont // return to worker_thread__switch_to_sandbox() api.. // we'd potentially do what we'd in worker_thread__switch_to_sandbox() api here for cleanup.. - if (!software_interrupt__is_enabled()) { + if (!software_interrupt_is_enabled()) { arch_context_init(¤t_sandbox->ctxt, 0, 0); worker_thread__next_context = NULL; - software_interrupt__enable(); + software_interrupt_enable(); } struct module *current_module = sandbox_get_module(current_sandbox); int argument_count = module_get_argument_count(current_module); diff --git a/runtime/src/software_interrupt.c b/runtime/src/software_interrupt.c index 98f826a..657d388 100644 --- a/runtime/src/software_interrupt.c +++ b/runtime/src/software_interrupt.c @@ -18,15 +18,15 @@ * Process Globals ***************************************/ -static const int software_interrupt__supported_signals[] = { SIGALRM, SIGUSR1 }; +static const int software_interrupt_supported_signals[] = { SIGALRM, SIGUSR1 }; /*************************************** * Thread Globals ***************************************/ -__thread static volatile sig_atomic_t software_interrupt__SIGALRM_count = 0; -__thread static volatile sig_atomic_t software_interrupt__SIGUSR_count = 0; -__thread volatile sig_atomic_t software_interrupt__is_disabled = 0; +__thread static volatile sig_atomic_t software_interrupt_SIGALRM_count = 0; +__thread static volatile sig_atomic_t software_interrupt_SIGUSR_count = 0; +__thread volatile sig_atomic_t software_interrupt_is_disabled = 0; /*************************************** * Externs @@ -38,8 +38,8 @@ extern pthread_t runtime_worker_threads[]; * Private Static Inlines ***************************************/ -static inline void software_interrupt__handle_signals(int signal_type, siginfo_t *signal_info, void *user_context_raw); -static inline void software_interrupt__schedule_alarm(void *user_context_raw); +static inline void software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void *user_context_raw); +static inline void software_interrupt_schedule_alarm(void *user_context_raw); /** * The handler function for Software Interrupts (signals) @@ -50,7 +50,7 @@ static inline void software_interrupt__schedule_alarm(void *user_context_raw); * @param user_context_raw void* to a user_context struct **/ static inline void -software_interrupt__handle_signals(int signal_type, siginfo_t *signal_info, void *user_context_raw) +software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void *user_context_raw) { #ifdef PREEMPT_DISABLE assert(0); @@ -75,33 +75,33 @@ software_interrupt__handle_signals(int signal_type, siginfo_t *signal_info, void } else { assert(signal_info->si_code == SI_TKILL); } - // debuglog("alrm:%d\n", software_interrupt__SIGALRM_count); + // debuglog("alrm:%d\n", software_interrupt_SIGALRM_count); - software_interrupt__SIGALRM_count++; - // software_interrupt__supported_signals per-core.. + software_interrupt_SIGALRM_count++; + // software_interrupt_supported_signals per-core.. if (curr && curr->state == RETURNED) return; if (worker_thread__next_context) return; - if (!software_interrupt__is_enabled()) return; - software_interrupt__schedule_alarm(user_context_raw); + if (!software_interrupt_is_enabled()) return; + software_interrupt_schedule_alarm(user_context_raw); break; } case SIGUSR1: { // make sure sigalrm doesn't mess this up if nested.. - assert(!software_interrupt__is_enabled()); + assert(!software_interrupt_is_enabled()); /* we set current before calling pthread_kill! */ assert(worker_thread__next_context && (&curr->ctxt == worker_thread__next_context)); assert(signal_info->si_code == SI_TKILL); - // debuglog("usr1:%d\n", software_interrupt__SIGUSR_count); + // debuglog("usr1:%d\n", software_interrupt_SIGUSR_count); - software_interrupt__SIGUSR_count++; + software_interrupt_SIGUSR_count++; // do not save current sandbox.. it is in co-operative switch.. // pick the next from "worker_thread__next_context".. // assert its "sp" to be zero in regs.. // memcpy from next context.. arch_mcontext_restore(&user_context->uc_mcontext, &curr->ctxt); worker_thread__next_context = NULL; - software_interrupt__enable(); + software_interrupt_enable(); break; } default: @@ -115,9 +115,9 @@ software_interrupt__handle_signals(int signal_type, siginfo_t *signal_info, void * @param user_context_raw void* to a user_context struct **/ static inline void -software_interrupt__schedule_alarm(void *user_context_raw) +software_interrupt_schedule_alarm(void *user_context_raw) { - software_interrupt__disable(); // no nesting! + software_interrupt_disable(); // no nesting! struct sandbox *curr = current_sandbox_get(); ucontext_t * user_context = (ucontext_t *)user_context_raw; @@ -142,7 +142,7 @@ software_interrupt__schedule_alarm(void *user_context_raw) // worker_thread__next_context = NULL; done: - software_interrupt__enable(); + software_interrupt_enable(); skip: return; } @@ -155,7 +155,7 @@ skip: * Arms the Interval Timer to start in 10ms and then trigger a SIGALRM every 5ms **/ void -software_interrupt__arm_timer(void) +software_interrupt_arm_timer(void) { #ifndef PREEMPT_DISABLE struct itimerval interval_timer; @@ -176,7 +176,7 @@ software_interrupt__arm_timer(void) * Disarm the Interval Timer **/ void -software_interrupt__disarm_timer(void) +software_interrupt_disarm_timer(void) { struct itimerval interval_timer; @@ -197,17 +197,17 @@ software_interrupt__disarm_timer(void) * Register sonftint_handler to execute on SIGALRM and SIGUSR1 **/ void -software_interrupt__initialize(void) +software_interrupt_initialize(void) { struct sigaction signal_action; memset(&signal_action, 0, sizeof(struct sigaction)); - signal_action.sa_sigaction = software_interrupt__handle_signals; + signal_action.sa_sigaction = software_interrupt_handle_signals; signal_action.sa_flags = SA_SIGINFO | SA_RESTART; for (int i = 0; - i < (sizeof(software_interrupt__supported_signals) / sizeof(software_interrupt__supported_signals[0])); + i < (sizeof(software_interrupt_supported_signals) / sizeof(software_interrupt_supported_signals[0])); i++) { - int return_code = sigaction(software_interrupt__supported_signals[i], &signal_action, NULL); + int return_code = sigaction(software_interrupt_supported_signals[i], &signal_action, NULL); if (return_code) { perror("sigaction"); exit(1);