static void unixCheckClockType() { #if (_POSIX_MONOTONIC_CLOCK-0 == 0) if (is_likely(load_acquire(monotonicClockChecked))) return; # if defined(_SC_MONOTONIC_CLOCK) // detect if the system support monotonic timers long x = sysconf(_SC_MONOTONIC_CLOCK); store_release(monotonicClockAvailable, x >= 200112L); # endif store_release(monotonicClockChecked, true); #endif }
static void btree_ui_out(struct btree_info *ui, const char *filename) { FILE *out = stdout; if (filename) { printf("output %s\n", filename); out = fopen(filename, "w+"); if (out == NULL) out = stdout; } #if 1 btree_print(ui->tree, (void (*)(void*, void*))userinfo_print, out); #else { int i; for (i=0; i < ui->tree->entries_num; i++) { struct user_info *info = store_read(ui->userinfo_store, i); userinfo_print(out, info); store_release(ui->userinfo_store, i, info); } } #endif if (out != stdout) fclose(out); }
static void action_queue_complete(struct cpu_action_queue *q, struct cpu_action *action) { /* Mark completion and send events to waiters. */ store_release(&q->completed, action); sev(); }
int exception_handler_register(uint64_t vid, struct exception_handler *h) { if (vid >= NUM_EXC_VIDS) return -1; /* Just place at head of queue. */ h->next = handlers[vid]; store_release(&handlers[vid], h); return 0; }
static void control_leave(struct sml_control *control) { assert(load_relaxed(&control->state) == ACTIVE(ASYNC)); /* unlock; all updates so far must be released */ store_release(&control->state, INACTIVE(ASYNC)); if (load_relaxed(&stop_the_world_flag)) { mutex_lock(&control->inactive_wait_lock); cond_signal(&control->inactive_wait_cond); mutex_unlock(&control->inactive_wait_lock); } }
void sml_check_internal(void *frame_pointer) { struct sml_control *control = tlv_get(current_control); void *old_frame_top; assert(load_relaxed(&control->state) == ACTIVE(ASYNC)); if (load_relaxed(&stop_the_world_flag)) { old_frame_top = control->frame_stack->top; if (!old_frame_top) control->frame_stack->top = frame_pointer; store_release(&control->state, INACTIVE(SYNC1)); mutex_lock(&control->inactive_wait_lock); cond_signal(&control->inactive_wait_cond); mutex_unlock(&control->inactive_wait_lock); control_enter(control); control->frame_stack->top = old_frame_top; } }
int exception_handler_unregister(uint64_t vid, struct exception_handler *h) { struct exception_handler *cur; struct exception_handler **prev; if (vid >= NUM_EXC_VIDS) return -1; prev = &handlers[vid]; for (cur = handlers[vid]; cur != NULL; cur = cur->next) { if (cur != h) continue; /* Update previous pointer. */ store_release(prev, cur->next); return 0; } /* Not found */ return -1; }