void cScreenGirlDetails::process() { if (!ids_set) set_ids(); // we need to make sure the ID variables are set if (check_keys()) return; // handle arrow keys init(); // set up the window if needed check_events(); // check to see if there's a button event needing handling }
/*************************************************************************** ************************ ENTRYPOINT AND MAIN LOOP ************************* **************************************************************************/ int main(void) { // Init MCU init_application(); #ifdef CONFIG_TEST // Branch to welcome screen test_mode(); #else /* clear whole scren */ display_clear(0, 0); #endif /* Init modules */ mod_init(); /* main loop */ while (1) { /* Go to LPM3, wait for interrupts */ _BIS_SR(LPM3_bits + GIE); __no_operation(); /* service watchdog on wakeup */ #ifdef USE_WATCHDOG // Service watchdog (reset counter) WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL; #endif /* check if any driver has events pending */ check_events(); /* check for button presses, drive the menu */ check_buttons(); } }
int main(int ac, char **av) { int lc; int pid; tst_parse_opts(ac, av, NULL, NULL); setup(); for (lc = 0; TEST_LOOPING(lc); ++lc) { pid = tst_fork(); switch (pid) { case 0: send_events(); exit(0); case -1: tst_brkm(TBROK | TERRNO, cleanup, "fork() failed"); default: if (!check_events()) tst_resm(TFAIL, "Wrong data received in eventX"); else tst_resm(TPASS, "Data received in eventX"); break; } SAFE_WAITPID(NULL, pid, NULL, 0); } cleanup(); tst_exit(); }
static int control(struct vo *vo, uint32_t request, void *data) { switch (request) { case VOCTRL_CHECK_EVENTS: check_events(vo); return VO_TRUE; } return VO_NOTIMPL; }
int zmq_poller_modify_fd (void *poller_, zmq::fd_t fd_, short events_) { if (-1 == check_poller_fd_registration_args (poller_, fd_) || -1 == check_events (events_)) return -1; return (static_cast<zmq::socket_poller_t *> (poller_)) ->modify_fd (fd_, events_); }
static void run_dmm(struct dsp_node *node, unsigned long times) { dmm_buffer_t *input_buffer; dmm_buffer_t *output_buffer; unsigned long total_times; input_buffer = dmm_buffer_new(dsp_handle, proc, DMA_TO_DEVICE); output_buffer = dmm_buffer_new(dsp_handle, proc, DMA_FROM_DEVICE); dmm_buffer_allocate(input_buffer, input_buffer_size); dmm_buffer_allocate(output_buffer, output_buffer_size); dmm_buffer_map(output_buffer); dmm_buffer_map(input_buffer); configure_dsp_node(node, input_buffer, output_buffer); total_times = times; pr_info("running %lu times", times); while (!done) { struct dsp_msg msg; if (do_write) { static unsigned char foo = 1; unsigned int i; for (i = 0; i < input_buffer->size; i++) ((char *) input_buffer->data)[i] = foo; foo++; } dmm_buffer_begin(input_buffer, input_buffer->size); dmm_buffer_begin(output_buffer, output_buffer->size); msg.cmd = 1; msg.arg_1 = input_buffer->size; dsp_node_put_message(dsp_handle, node, &msg, -1); if (!check_events(node, &msg)) { done = true; break; } dmm_buffer_end(input_buffer, input_buffer->size); dmm_buffer_end(output_buffer, output_buffer->size); if (--times == 0) break; } dmm_buffer_unmap(output_buffer); dmm_buffer_unmap(input_buffer); dmm_buffer_free(output_buffer); dmm_buffer_free(input_buffer); printf("copied %lu times successfully\n", total_times); }
void VM::dequeue_thread(Thread* thread) { thread->queued(this, Qfalse); Tuple* scheduled = globals.scheduled_threads.get(); /** @todo Could it be in more than one somehow? --rue */ List* list = try_as<List>(scheduled->at(this, thread->priority()->to_native())); (void) list->remove(this, thread); check_events(); }
int zmq_poller_modify (void *poller_, void *s_, short events_) { if (-1 == check_poller_registration_args (poller_, s_) || -1 == check_events (events_)) return -1; zmq::socket_base_t *socket = static_cast<zmq::socket_base_t *> (s_); return (static_cast<zmq::socket_poller_t *> (poller_)) ->modify (socket, events_); }
void CControlAnimation::update_frame() { if (m_freeze) return; // move to schedule update START_PROFILE("BaseMonster/Animation/Update Tracks"); m_skeleton_animated->UpdateTracks (); STOP_PROFILE; START_PROFILE("BaseMonster/Animation/Check callbacks"); check_callbacks (); STOP_PROFILE; START_PROFILE("BaseMonster/Animation/Play"); play (); STOP_PROFILE; START_PROFILE("BaseMonster/Animation/Check Events"); check_events (m_data.global); check_events (m_data.torso); check_events (m_data.legs); STOP_PROFILE; }
void cScreenGetInput::process() { g_CurrentScreen = SCREEN_BROTHEL; if (!ids_set) set_ids(); if (check_keys()) return; init(); check_events(); }
void cScreenBrothelManagement::process() { g_CurrentScreen = SCREEN_BROTHEL; if (!id_set) set_ids(); if (check_keys()) return; init(); check_events(); }
// --------------------------------------------------------------------------- // // ----------- bool bXMapTopoCheck::event(EventRef evt){ UInt32 clss=GetEventClass(evt); if(clss==kEventClassMacMap){ UInt32 kind=GetEventKind(evt); switch(kind){ case kEventMacMapDataBase: check_events(); break; default: break; } } return(false); }
int main(void) { main_init(); timer_a0_init(); // PGA2311 needs to get the digital power after a delay // otherwise it will lock up timer_a0_delay_ccr4(_1s); pga_enable; spi_init(); spi_fast_mode(); // set chip selects high (deselect all slaves) P1OUT |= 0x54; P2OUT |= 0x1; P4OUT |= 0x84; settings_init(FLASH_ADDR); get_temperature(); #ifdef USE_UART uart1_init(); uart1_iface_init(); #endif #ifdef USE_I2C i2c_slave_init(); i2c_iface_init(); #endif sys_messagebus_register(&timer_a0_ovf_irq, SYS_MSG_TIMER0_IFG); led_off; while (1) { // go into low power mode until an IRQ wakes us up _BIS_SR(LPM0_bits + GIE); __no_operation(); //wake_up(); #ifdef USE_WATCHDOG WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL; #endif check_events(); } }
int main(void) { unsigned int i; check_events(); check_small_alloc(); check_malloc_zero(); check_calloc(); check_torture(3); check_torture(5); check_torture(7); for (i = 8; i < (16 * 1024); i = i * 2) check_torture(i); check_torture(9 * 1024); return 0; }
int main(void) { sysclk_init(); init_dbg_rs232(FMCK_HZ); init_gpio(); assign_main_event_handlers(); init_events(); init_tc(); init_spi(); init_adc(); irq_initialize_vectors(); register_interrupts(); cpu_irq_enable(); init_usb_host(); init_monome(); if(flash_is_fresh()) { // nothing has been stored in the flash memory so far // so you need to initialize any variables you store in flash here with appropriate default values } else { // read from flash flash_read(); } clock_pulse = &clock; clock_external = !gpio_get_pin_value(B09); // start timers that track clock, ADCs (including the clock and the param knobs) and the front panel button timer_add(&clockTimer,120,&clockTimer_callback, NULL); timer_add(&keyTimer,50,&keyTimer_callback, NULL); timer_add(&adcTimer,100,&adcTimer_callback, NULL); clock_temp = 10000; // out of ADC range to force tempo // main loop - you probably don't need to do anything here as everything should be done by handlers while (true) { check_events(); } }
// This function adds a new record to an existing linked list // or creates a new one if its a new event int lol_add_record(lol *lo, char *buff) { int i; lnode n; event e; char *ptr; llist *l; // Short circuit if event is not of interest if (extract_timestamp(buff, &e) == 0) return 0; ptr = strrchr(buff, 0x0a); if (ptr) *ptr = 0; n.message=strdup(buff); n.type = e.type; // Now see where this belongs for (i=0; i<=lo->maxi; i++) { if (lo->array[i].status == L_BUILDING) { l = lo->array[i].l; if (events_are_equal(&l->e, &e)) { free((char *)e.node); list_append(l, &n); return 1; } } } // Create new event and fill it in l = malloc(sizeof(llist)); list_create(l); l->e.milli = e.milli; l->e.sec = e.sec; l->e.serial = e.serial; l->e.node = e.node; l->e.type = e.type; list_append(l, &n); lol_append(lo, l); check_events(lo, e.sec); return 1; }
// Check Events Task routine. // void dispatch_CheckEvents(void *pUnused, int iUnused) { UNUSED_PARAMETER(pUnused); UNUSED_PARAMETER(iUnused); if (mudconf.control_flags & CF_EVENTCHECK) { const char *cmdsave = mudstate.debug_cmd; mudstate.debug_cmd = (char *)"< eventcheck >"; check_events(); mudstate.debug_cmd = cmdsave; } // Schedule ourselves again. // CLinearTimeAbsolute ltaNow; ltaNow.GetUTC(); CLinearTimeDelta ltd = time_15m; mudstate.events_counter = ltaNow + ltd; scheduler.DeferTask(mudstate.events_counter, PRIORITY_SYSTEM, dispatch_CheckEvents, 0, 0); }
static void run_ping(struct dsp_node *node, unsigned long times) { while (!done) { struct dsp_msg msg; if (!dsp_send_message(dsp_handle, node, 2, 0, 0)) { pr_err("dsp node put message failed"); continue; } if (!check_events(node, &msg)) { done = true; break; } printf("ping: id=%d, msg=%d, mem=%d\n", msg.cmd, msg.arg_1, msg.arg_2); if (--times == 0) break; } }
/*-----------------------------------------------------------------------------------*/ static void acked(void) { switch(vs->sendmsg) { case VNC_SEND_PFMT: vs->sendmsg = VNC_SEND_ENCODINGS; break; case VNC_SEND_ENCODINGS: vs->sendmsg = VNC_SEND_UPDATERQ; vs->waitmsg = VNC_WAIT_UPDATE; clearbuffer(); break; case VNC_SEND_EVENTS: vs->eventptr_acked = vs->eventptr_unacked; vs->sendmsg = VNC_SEND_NONE; check_events(); break; default: vs->sendmsg = VNC_SEND_NONE; break; } }
void qmp_trace_event_set_state(const char *name, bool enable, bool has_ignore_unavailable, bool ignore_unavailable, bool has_vcpu, int64_t vcpu, Error **errp) { Error *err = NULL; TraceEventIter iter; TraceEvent *ev; bool is_pattern = trace_event_is_pattern(name); CPUState *cpu; /* Check provided vcpu */ cpu = get_cpu(has_vcpu, vcpu, &err); if (err) { error_propagate(errp, err); return; } /* Check events */ if (!check_events(has_vcpu, has_ignore_unavailable && ignore_unavailable, is_pattern, name, errp)) { return; } /* Apply changes (all errors checked above) */ trace_event_iter_init(&iter, name); while ((ev = trace_event_iter_next(&iter)) != NULL) { if (!trace_event_get_state_static(ev) || (has_vcpu && !trace_event_is_vcpu(ev))) { continue; } if (has_vcpu) { trace_event_set_vcpu_state_dynamic(cpu, ev, enable); } else { trace_event_set_state_dynamic(ev, enable); } } }
//int main(void) { ////main function int main (void) { u32 waitForCard = 0; // set up avr32 hardware and peripherals init_avr32(); print_dbg("\r\n SRAM size: 0x"); print_dbg_hex(smc_get_cs_size(1)); cpu_irq_disable(); /// test the SRAM sram_test(); cpu_irq_enable(); //memory manager init_mem(); print_dbg("\r\n init_mem"); // wait for sdcard print_dbg("\r\n SD check... "); while (!sd_mmc_spi_mem_check()) { waitForCard++; } print_dbg("\r\nfound SD card. "); // intialize the FAT filesystem print_dbg("\r\n init fat"); fat_init(); // setup control logic print_dbg("\r\n init ctl"); init_ctl(); /* // initialize the application */ /* app_init(); */ /* print_dbg("\r\n init app"); */ // initialize flash: firstrun = init_flash(); print_dbg("r\n init flash, firstrun: "); print_dbg_ulong(firstrun); screen_startup(); // find and load dsp from sdcard files_search_dsp(); print_dbg("\r\n starting event loop.\r\n"); // dont do startup startup = 0; while(1) { check_events(); } }
bool render() { if (!vk_globals::is_init) { return false; } vkDeviceWaitIdle(vk_globals::device); if (!check_events()) { return false; } resources::s_render_context const* render_context; VERIFY(resources::get_current_render_context(&render_context)); uint32_t image_index; VkResult result = vkAcquireNextImageKHR(vk_globals::device, vk_globals::swapchain.handle, UINT64_MAX, render_context->image_available_semaphore, VK_NULL_HANDLE, &image_index); switch (result) { case VK_SUCCESS: break; case VK_SUBOPTIMAL_KHR: case VK_ERROR_OUT_OF_DATE_KHR: graphics::render3d::resources::create_pipeline(); return true; default: SET_ERROR (LOG_TYPE, "Problem occurred during swap chain image acquisition!", ""); return false; } VERIFY(fill_present_command_buffer(render_context->command_buffer, vk_globals::swapchain.images[image_index])); VkPipelineStageFlags wait_dst_stage_mask = VK_PIPELINE_STAGE_TRANSFER_BIT; VkSubmitInfo submit_info = { VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType nullptr, // const void *pNext 1, // uint32_t waitSemaphoreCount &render_context->image_available_semaphore, // const VkSemaphore *pWaitSemaphores &wait_dst_stage_mask, // const VkPipelineStageFlags *pWaitDstStageMask; 1, // uint32_t commandBufferCount &render_context->command_buffer, // const VkCommandBuffer *pCommandBuffers 1, // uint32_t signalSemaphoreCount &render_context->rendering_finished_semaphore // const VkSemaphore *pSignalSemaphores }; VK_VERIFY (vkQueueSubmit(vk_globals::present_queue.handle, 1, &submit_info, render_context->fence)); VkPresentInfoKHR present_info = { VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, // VkStructureType sType nullptr, // const void *pNext 1, // uint32_t waitSemaphoreCount &render_context->rendering_finished_semaphore, // const VkSemaphore *pWaitSemaphores 1, // uint32_t swapchainCount &(vk_globals::swapchain.handle), // const VkSwapchainKHR *pSwapchains &image_index, // const uint32_t *pImageIndices nullptr // VkResult *pResults }; result = vkQueuePresentKHR(vk_globals::present_queue.handle, &present_info); switch (result) { case VK_SUCCESS: break; case VK_ERROR_OUT_OF_DATE_KHR: case VK_SUBOPTIMAL_KHR: return true; default: SET_ERROR (LOG_TYPE, "Problem occurred during image presentation!", ""); return false; } return true; }
int main (int argc, char *argv[]) { struct params par = PAR_DEFAULT; int j, js, fd; int n_read; int spurious_count=0; struct timespec very_first, very_last; struct event *time_buf, *time_list, *event; struct event *big_time_buf=NULL, origin; int side, size; int *i_differ, *e_delay=NULL, *i_delay; int delta_e; int status; int count=0, first; float sigma, quantum; FILE * logfile=NULL, * listfile=NULL; FILE * plot=NULL; char buff[BUFLEN]; double *tevi=NULL, delta; double cf[2]; double average; int total_time; int block_size, full_size; int bin_size; parse_options (argc, argv, &par); if (par.p & MRC_PM) { bin_size = (par.n + BINS - 1) / BINS; if (par.v) printf ("Bin size is: %d\n", bin_size); } if (!par.e && par.p & LAT_PM) { printf ("The latency distribution will not be computed if" " the external clock is not specified [-e]\n"); par.p &= ~LAT_PM; } quantum = par.g * par.c; /* usec/channel in time distributions */ /* start auxiliary services: gnuplot */ if (par.p) { plot = popen("/usr/bin/gnuplot -noraise -persist -geometry " "1024x512", "w"); if (plot == NULL) { printf ("Start of graphical display failed!\n"); exit (-1); } else { if (par.v) printf ( "Time distributions will be plotted\n"); fprintf (plot, "set grid; set term X11\n"); } } /* open time device and log files */ if (par.i == NULL) par.i = "/dev/latim"; if (strcmp(par.i, "-") == 0) { /* data from standard input */ fd = 0; } else { fd = open (par.i, O_RDONLY); if (fd == -1) { printf ("Failed while opening time device '%s'\n", par.i); perror (""); exit (-1); } } if (!par.f) par.f = new_code(); logfile = fopen(par.f, "w"); if (!logfile) { perror ("Failed while opening log file"); exit (-1); } printf ("Log to file %s\n", par.f); if (par.L) { strcpy (par.f+strlen(par.f)-3, "lst"); listfile = fopen (par.f, "w"); if (!listfile) { perror ("Failed while opening list file"); exit (-1); } printf ("Time list to file %s\n", par.f); } /* save the full command line to log file */ fprintf (logfile, "# "); for ( j=0 ; j<argc ; j++) { fprintf (logfile, "%s ", *(argv+j)); if (par.v) printf ("%s ", *(argv+j)); } fprintf (logfile, "\n\n"); if (par.v) printf ("\n"); /* get memory for buffers */ block_size = par.n * SLOT; full_size = (par.U ? par.N : 1) * block_size; big_time_buf = malloc (full_size+SLOT); time_buf = big_time_buf; if (!time_buf) { perror ("malloc failed with time_buf"); exit (-1); } if (par.v) printf ("Allocated time buffer %d bytes wide at %p\n", (int) (full_size+SLOT), big_time_buf); time_list = time_buf + 1; tevi = malloc (par.n * sizeof(double)); if (!tevi) { perror ("malloc failed with tevi"); goto bad_exit; } if (par.v) printf ("Allocated count buffer %d bytes wide at %p\n", (int) (par.n * sizeof(*tevi)), tevi); side = par.m/par.c + 1.0; size = 2*side + 1; e_delay = calloc (3*size, sizeof(int)); if (!e_delay) { perror ("malloc failed with e_delay"); goto bad_exit; } if (par.v) printf ("Allocated distribution buffer %d bytes wide " "at %p\n", (int) (3*size*sizeof(int)), e_delay); i_differ = e_delay + size; i_delay = i_differ + size; /* * enter the main loop */ n_read = read (fd, (void *) time_buf, SLOT); if (n_read != SLOT) { printf ("reading of time origin failed with %d\n", n_read); goto bad_exit; } origin = *time_buf; count = 0; while (!par.N || count < par.N) { n_read = 0; while (n_read < block_size) { status = read (fd, (void *) time_list + n_read, block_size - n_read); if (status == 0) break; if (status < 0) { perror ("read operation failed"); goto bad_exit; } n_read += status; } if (status == 0) { printf ("Undue EOF after %d bytes\n", n_read); goto bad_exit; } if (n_read != block_size) { printf("read operation failed with return %d\n", n_read); perror ("reason"); goto bad_exit; } first = count * par.n; /* * issue a complete list of all events: * -l list to console * -L list to file */ list_events (&par, listfile, time_list, first, &origin); /* Analyze buffer for spurious events. * An event is spurious when the measured latency exceeds * the given threshold (-m). */ if (check_events (&par, time_list, logfile, count, &spurious_count, first, &origin) == -1) goto bad_exit; printf ("events/err.: %9d / %d", first+par.n, spurious_count); /* * histograms: * * i_differ: distribution of internal clock differences * e_delay: distribution of external counter delays * i_delay: distribution of internal clock delays * */ /* build i_differ and e_delay time distributions */ for ( j=0 ; j<par.n ; j++ ) { event = time_list+j; delta = (us_diff(&event->timic, &(event-1)->timic) - par.t) / quantum; if (delta < -side) delta = -side; else if (delta > side) delta = side; i_differ[(int) (delta + side)] += 1; // tevi[j] = us_diff(&event->timic, &origin.timic); tevi[j] = us_diff(&event->timic, &time_list->timic); if (par.e) { delta_e = diff_e(event) / par.g; if (delta_e > size) delta_e = size; e_delay[delta_e] += 1; } } /* compute clock rate and build 'i_delay' histogram */ fit1 (tevi, par.n, cf); printf (" clock rate: %9.3f %8.3f\n", cf[0], cf[1]+200); for ( j=0 ; j<par.n ; j++ ) { tevi[j] -= (cf[0]*(j+1) + cf[1]); if (tevi[j] < -par.m) tevi[j] = -par.m; if (tevi[j] >= par.m) tevi[j] = par.m; delta = tevi[j] / (par.g * par.c); i_delay[(int) (delta+side)] += 1; } /* plots */ plot_histograms (&par, plot, i_differ, i_delay, e_delay, tevi, time_list); /* * close the main loop */ if (!count) very_first = time_buf->timic; very_last = (time_buf + par.n)->timic; if (par.U) { time_buf += par.n; time_list = time_buf + 1; } else { *time_buf = *(time_buf + par.n); } count++; } /* print final logs */ if ((par.L || par.l) && par.U) { for ( j=0 ; j<par.n*par.N ; j++ ) { event = big_time_buf+j+1; delta = us_diff (&event->timic, &(event-1)->timic); sprintf (buff, "%8d %12ld.%09ld %10d %8.2f %6.2f", j, event->timic.tv_sec, event->timic.tv_nsec, tm_diff(&event->timic, &origin.timic), delta, delta - par.t); if (par.e) { delta_e = diff_e(event); sprintf (buff+strlen(buff), " %4d %4d", event->timec, delta_e); } sprintf (buff+strlen(buff), "\n"); if (par.l) printf (buff); if (par.L) fprintf (listfile, buff); } } /* print final time distributions */ if (par.S) { /* i_differ */ printf ("\nTime distribution from internal clock\n"); print_distrib (i_differ, size, logfile, side, quantum); if (par.e) { /* e_delay */ printf ("\nTime distribution from external clock\n"); fprintf (logfile, "\n\n"); print_distrib (e_delay, size, logfile, 0, quantum); } printf ("\nTime distribution of delays from internal clock\n"); fprintf (logfile, "\n\n"); /* delay */ print_distrib (i_delay, size, logfile, side, quantum); } /* time distribution average and width */ if (par.s || par.S) { sigma = 0.; average = 0.; for ( js=-side ; js<=side ; js++ ) average += i_differ[js+side] * js; average /= (par.n * par.N)/quantum; for ( js=-side ; js<=side ; js++ ) sigma += i_differ[js+side] * (js-average) * (js-average); sprintf (buff, "par.t: %d <T>: %f Sigma: %f\n", par.t, average, quantum*sqrt(sigma/(par.n * par.N - 1))); printf ("\n%s", buff); fprintf (logfile, "\n# %s", buff); } total_time = tm_diff(&very_last, &very_first); sprintf (buff, "Total time: %d skew: %d\n", total_time, total_time - par.n * par.N * par.t); printf (buff); fprintf (logfile, "# %s", buff); if (listfile) fclose (listfile); if (logfile) fclose (logfile); if (par.v) printf ("Cleaning buffers at %p %p %p\n", big_time_buf, tevi, e_delay); free (big_time_buf); free (tevi); free (e_delay); return 0; bad_exit: if (logfile) fclose (logfile); if (listfile) fclose (listfile); free (big_time_buf); free (tevi); free (e_delay); return -1; }
TraceEventInfoList *qmp_trace_event_get_state(const char *name, bool has_vcpu, int64_t vcpu, Error **errp) { Error *err = NULL; TraceEventInfoList *events = NULL; TraceEvent *ev; bool is_pattern = trace_event_is_pattern(name); CPUState *cpu; /* Check provided vcpu */ cpu = get_cpu(has_vcpu, vcpu, &err); if (err) { error_propagate(errp, err); return NULL; } /* Check events */ if (!check_events(has_vcpu, true, is_pattern, name, errp)) { return NULL; } /* Get states (all errors checked above) */ ev = NULL; while ((ev = trace_event_pattern(name, ev)) != NULL) { TraceEventInfoList *elem; bool is_vcpu = trace_event_is_vcpu(ev); if (has_vcpu && !is_vcpu) { continue; } elem = g_new(TraceEventInfoList, 1); elem->value = g_new(TraceEventInfo, 1); elem->value->vcpu = is_vcpu; elem->value->name = g_strdup(trace_event_get_name(ev)); if (!trace_event_get_state_static(ev)) { elem->value->state = TRACE_EVENT_STATE_UNAVAILABLE; } else { if (has_vcpu) { if (is_vcpu) { if (trace_event_get_vcpu_state_dynamic(cpu, ev)) { elem->value->state = TRACE_EVENT_STATE_ENABLED; } else { elem->value->state = TRACE_EVENT_STATE_DISABLED; } } /* else: already skipped above */ } else { if (trace_event_get_state_dynamic(ev)) { elem->value->state = TRACE_EVENT_STATE_ENABLED; } else { elem->value->state = TRACE_EVENT_STATE_DISABLED; } } } elem->next = events; events = elem; } return events; }
void cScreenMayor::process() { if (!ids_set) set_ids(); // we need to make sure the ID variables are set init(); // set up the window if needed check_events(); // check to see if there's a button event needing handling }
int main(void) { u8 i1; sysclk_init(); init_dbg_rs232(FMCK_HZ); init_gpio(); assign_main_event_handlers(); init_events(); init_tc(); init_spi(); init_adc(); irq_initialize_vectors(); register_interrupts(); cpu_irq_enable(); init_usb_host(); init_monome(); init_i2c_slave(0x30); print_dbg("\r\n\n// meadowphysics //////////////////////////////// "); print_dbg_ulong(sizeof(flashy)); print_dbg(" "); print_dbg_ulong(sizeof(m)); if(flash_is_fresh()) { print_dbg("\r\nfirst run."); flash_unfresh(); flashc_memset32((void*)&(flashy.preset_select), 0, 4, true); // clear out some reasonable defaults for(i1=0;i1<8;i1++) { m.positions[i1] = i1; m.points[i1] = i1; m.points_save[i1] = i1; m.triggers[i1] = 0; m.trig_dests[i1] = 0; m.rules[i1] = 0; m.rule_dests[i1] = i1; } m.positions[0] = m.points[0] = 3; m.trig_dests[0] = 254; // save all presets, clear glyphs for(i1=0;i1<8;i1++) { flashc_memcpy((void *)&flashy.m[i1], &m, sizeof(m), true); glyph[i1] = (1<<i1); flashc_memcpy((void *)&flashy.glyph[i1], &glyph, sizeof(glyph), true); } } else { // load from flash at startup preset_select = flashy.preset_select; flash_read(); for(i1=0;i1<8;i1++) glyph[i1] = flashy.glyph[preset_select][i1]; } LENGTH = 15; SIZE = 16; re = &refresh; process_ii = &mp_process_ii; clock_pulse = &clock; clock_external = !gpio_get_pin_value(B09); timer_add(&clockTimer,120,&clockTimer_callback, NULL); timer_add(&keyTimer,50,&keyTimer_callback, NULL); timer_add(&adcTimer,100,&adcTimer_callback, NULL); clock_temp = 10000; // out of ADC range to force tempo while (true) { check_events(); } }
int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_events_, long timeout_) { if (items.empty () && timeout_ < 0) { errno = EFAULT; return -1; } if (need_rebuild) rebuild (); if (unlikely (poll_size == 0)) { // We'll report an error (timed out) as if the list was non-empty and // no event occurred within the specified timeout. Otherwise the caller // needs to check the return value AND the event to avoid using the // nullified event data. errno = EAGAIN; if (timeout_ == 0) return -1; #if defined ZMQ_HAVE_WINDOWS Sleep (timeout_ > 0 ? timeout_ : INFINITE); return -1; #elif defined ZMQ_HAVE_ANDROID usleep (timeout_ * 1000); return -1; #elif defined ZMQ_HAVE_OSX usleep (timeout_ * 1000); errno = EAGAIN; return -1; #else usleep (timeout_ * 1000); return -1; #endif } #if defined ZMQ_POLL_BASED_ON_POLL zmq::clock_t clock; uint64_t now = 0; uint64_t end = 0; bool first_pass = true; while (true) { // Compute the timeout for the subsequent poll. int timeout; if (first_pass) timeout = 0; else if (timeout_ < 0) timeout = -1; else timeout = end - now; // Wait for events. while (true) { int rc = poll (pollfds, poll_size, timeout); if (rc == -1 && errno == EINTR) { return -1; } errno_assert (rc >= 0); break; } // Receive the signal from pollfd if (use_signaler && pollfds[0].revents & POLLIN) signaler->recv (); // Check for the events. int found = check_events (events_, n_events_); if (found) { if (found > 0) zero_trail_events (events_, n_events_, found); return found; } // Adjust timeout or break if (adjust_timeout (clock, timeout_, now, end, first_pass) == 0) break; } errno = EAGAIN; return -1; #elif defined ZMQ_POLL_BASED_ON_SELECT zmq::clock_t clock; uint64_t now = 0; uint64_t end = 0; bool first_pass = true; fd_set inset, outset, errset; while (true) { // Compute the timeout for the subsequent poll. timeval timeout; timeval *ptimeout; if (first_pass) { timeout.tv_sec = 0; timeout.tv_usec = 0; ptimeout = &timeout; } else if (timeout_ < 0) ptimeout = NULL; else { timeout.tv_sec = (long) ((end - now) / 1000); timeout.tv_usec = (long) ((end - now) % 1000 * 1000); ptimeout = &timeout; } // Wait for events. Ignore interrupts if there's infinite timeout. while (true) { #if defined ZMQ_HAVE_WINDOWS // On Windows we don't need to copy the whole fd_set. // SOCKETS are continuous from the beginning of fd_array in fd_set. // We just need to copy fd_count elements of fd_array. // We gain huge memcpy() improvement if number of used SOCKETs is much lower than FD_SETSIZE. memcpy (&inset, &pollset_in, (char *) (pollset_in.fd_array + pollset_in.fd_count ) - (char *) &pollset_in ); memcpy (&outset, &pollset_out, (char *) (pollset_out.fd_array + pollset_out.fd_count) - (char *) &pollset_out); memcpy (&errset, &pollset_err, (char *) (pollset_err.fd_array + pollset_err.fd_count) - (char *) &pollset_err); int rc = select (0, &inset, &outset, &errset, ptimeout); if (unlikely (rc == SOCKET_ERROR)) { errno = zmq::wsa_error_to_errno (WSAGetLastError ()); wsa_assert (errno == ENOTSOCK); return -1; } #else memcpy (&inset, &pollset_in, sizeof (fd_set)); memcpy (&outset, &pollset_out, sizeof (fd_set)); memcpy (&errset, &pollset_err, sizeof (fd_set)); int rc = select (maxfd + 1, &inset, &outset, &errset, ptimeout); if (unlikely (rc == -1)) { errno_assert (errno == EINTR || errno == EBADF); return -1; } #endif break; } if (use_signaler && FD_ISSET (signaler->get_fd (), &inset)) signaler->recv (); // Check for the events. int found = check_events(events_, n_events_, inset, outset, errset); if (found) { if (found > 0) zero_trail_events (events_, n_events_, found); return found; } // Adjust timeout or break if (adjust_timeout (clock, timeout_, now, end, first_pass) == 0) break; } errno = EAGAIN; return -1; #else // Exotic platforms that support neither poll() nor select(). errno = ENOTSUP; return -1; #endif }
void cellp( double delta_t) #endif { int itype,iindex, cn,ismax=False; int cells_survived = 0; int PrintLoopVar=PrintGap; double bigEndT, jjj; int snow; double TotalCells; int SendCellCountOneTime; char stemp[255]; int ksumlevel; int GiveTimeCount; int envnowl = 0; extern void release_mem(); extern double rand01(int), ranmarm(int); #ifdef TEST time_t stime; #endif #ifndef DLL FILE *out;/* the pointer to s2.out, the interface file to Java */ #endif #ifdef TESTMPI extern int nrepetitions; #endif if (Cured == False) { SendCellCountOneTime = True; } else { SendCellCountOneTime = False; } /*_ASSERT(0);*/ /* This func call inits the nexttoxtime variable*/ Tblength = (long) (ntypes/Class[0].no_levels); InitNextToxTime(); SetBBForPatient(); snow = 0; if ((GiveTimeCount = 48 - (ntypes * 3)) < 0) GiveTimeCount = 0; /* Changes: 12 September 1996 * while((timevec[itime] <= StartT) && (itime <= nallts)) itime++; * <= changed to < . This ensures that itime is no increased when timevec[itime] = startT */ /* added by Qinshou 10/25/96 for test suites */ #ifdef TEST /* construct output file name */ if ( nrepetitions == 1 ) { if (numTest <= 9 ) sprintf(outName,"%s0%1d.%d.%d.0%d.out",outName,numTest,nrepetitions,(int)EndT,(int)(delta_t*1000)); else sprintf(outName,"%s%2d.%d.%d.0%d.out",outName,numTest,nrepetitions,(int)EndT,(int)(delta_t*1000)); out = fopen(outName,"w"); } else out = fopen(outName,"a"); if ( out==NULL ) { printf("Error opening %s\n",outName); Memory=False; return; } if ( nrepetitions ==1 ) printvalue(out); #endif t=StartT; UpdateTime = 0.0; cellpitime = 2; nowenv = 0; if (KineticsModel == IsGompertz ) { for ( iindex=1; iindex<=active_ntypes;iindex++) { /* Number_of_Gomp_Classes includes gomp class for whole body */ for ( cn=0; cn <Number_of_Gomp_Classes; cn++ ) { if ( LookUp[iindex].mark != NEG ) { ksumlevel = SumGompLevel(cn,iindex); if ( IsGompSumOverFlow(ksumlevel,cn)) { Memory = False; return; } NGomp(cn,ksumlevel) += CN[iindex]; /* GompRuleIndex=0 is for whole body */ } } /* micro class add VE and CA cells */ cn = Number_of_Gomp_Classes; ksumlevel = SumGompLevel(cn,iindex); if ( (iindex > pre_ntypes ) && IsGompSumOverFlow(ksumlevel,cn)){ Memory = false; return; } NGomp(cn,ksumlevel) += CN[iindex]; } } while((timevec[cellpitime] > t) && (timevec[cellpitime] < t + delta_t) && (cellpitime <= nallts)) cellpitime++; /* For each sample, the cell population is got at time EndT. */ bigEndT = EndT + delta_t / 2; while ( t < bigEndT ) { /*for speed sake, only update cell counts if patient isn't cured*/ if (Cured != True) { if (NextPBin(&envnowl) == False ) { release_mem(SIM); Memory=False; #ifdef DLL MessageBox(NULL,"Sorry. The total number of cell types has exceeded the memory limits, Please reduce the number of levels or number of classes. Try again.","treat.dll",MB_ICONEXCLAMATION | MB_OK); #else printf("Sorry. The total number of cell types has exceeded the memory limits\n"); #endif return; } if ((t >= timevec[cellpitime] ) && ( timevec[cellpitime] < t+delta_t) && (cellpitime <= nallts)) { for ( itype = 1; itype <= active_ntypes; itype++ ) { if ( timesurv(cellpitime,itype,envnowl) < 1.0 ) { jjj = timesurv(cellpitime,itype,envnowl); nDescOfItype(itype) = grand_b_n( CN[itype], timesurv(cellpitime,itype,envnowl) ) - CN[itype]; if (Update_CN_NGomp(itype,envnowl)== false ){ release_mem(SIM); Memory=False; #ifdef DLL MessageBox(NULL,"Sorry. The total number of cell types has exceeded the memory limits, Please reduce the number of levels or number of classes. Try again.","treat.dll",MB_ICONEXCLAMATION | MB_OK); #else printf("Sorry. The total number of cell types has exceeded the memory limits\n"); #endif return ; } //should send treatment event right here //also, send plot update event } } if (CheckForTreatment()) PlotHandler(); CheckForTox(); cellpitime++; } } /* check for any toxicity events */ /*#ifdef DLL*/ CheckForTox(); /* call here for CheckBBRules */ CheckBBRules(); ResetBBEveryDeltaT(); //do this in case the enviroment was changed by a rule. envnowl = nowenv; // CheckForTreatment(); if ((HasGuaranteeTimeChecked == False) && (nconds >0)) { CheckGuaranteeTime(); } if ( TrialSim == False || TSFirstTreatmentHappened == True ) check_events(); /*#endif */ if (( t >= BeginPlotTime) && (t <= EndPlotTime)) { if ( PrintLoopVar == PrintGap) { if (nrepetitions == 1) { if (Cured != True) { /*#ifdef DLL */ //AddToCellQ(); PlotHandler(); #ifdef DLL if (SleepTime != 0) { if (SleepTime != -1) Sleep(SleepTime); else while(SleepTime == -1) Sleep(0); } #endif /*#else*/ #ifdef TEST /* fprintf(out,"%5.3e",t);*/ fprintf(out,"%5.3e [%d]",t, active_ntypes); #endif for (itype = 1; itype <= active_ntypes; itype++ ) { #ifdef TEST /* fprintf(out," %5.2e",CN[itype]); */ fprintf(out," %5.2e (%d,%s)",CN[itype],LookUp[itype].LookUpId,cellname(itype)); fflush(out); #endif } #ifdef TEST fprintf(out,"\n"); #endif /*#endif*/ }/* close cured */ if ((Cured == True) && (SendCellCountOneTime == True)) { // AddToCellQ(); PlotHandler(); SendCellCountOneTime = False; } } /* close nrepetions */ PrintLoopVar = 1; }/* printloopvar */ else PrintLoopVar++; }/*begin and end plot time */ /*#ifdef DLL*/ /* if (nrepetitions == 1) { if (snow++ == GiveTimeCount) { snow = 0; Sleep(0); } } */ /* check to see if patient has died, if so end simulation */ if ((Dead == True) || (EndSim == True)) { release_mem(SIM); return; } /* #endif */ #ifdef TEST if ( nrepetitions == 1 ) { if (( t >= 5.0 && t < 5.0 + delta_t ) || ( t >= 10.0 && t < 10.0 + delta_t ) || ( t >= 15.0 && t < 15.0 + delta_t ) || ( t >= 20.0 && t < 20.0 + delta_t ) || ( t >= 25.0 && t < 25.0 + delta_t ) || ( t >= 30.0 && t < 30.0 + delta_t ) || ( t >= 31.0 && t < 31.0 + delta_t ) || ( t >= 32.0 && t < 32.0 + delta_t ) || ( t >= 33.0 && t < 33.0 + delta_t ) || ( t >= 34.0 && t < 34.0 + delta_t ) || ( t >= 35.0 && t < 35.0 + delta_t ) || ( t >= 36.0 && t < 36.0 + delta_t ) || ( t >= 37.0 && t < 37.0 + delta_t ) || ( t >= 38.0 && t < 38.0 + delta_t ) || ( t >= 39.0 && t < 39.0 + delta_t ) || ( t >= 40.0 && t < 40.0 + delta_t ) || ( t >= 41.0 && t < 41.0 + delta_t ) || ( t >= 42.0 && t < 42.0 + delta_t ) || ( t >= 43.0 && t < 43.0 + delta_t ) || ( t >= 44.0 && t < 44.0 + delta_t ) || ( t >= 45.0 && t < 45.0 + delta_t )) { printf("At time %lf cell types = %d systime %d\n",t,active_ntypes,time(&stime)-saitime); } } #endif t = t+delta_t; } #ifdef TEST if ((GuaranteeReset == false) && ( nrepetitions > 1 )) { if ( ntypes > 10 ) { for (iindex =1;iindex<= active_ntypes;iindex++) fprintf(out,"%e ",CN[iindex]); fprintf(out,"\n"); } else { /* for pgf test, get rearranged output including zero cell counts */ for (iindex =1;iindex<= active_ntypes;iindex++) { itype = iindex-1; do { itype++; if ((int)LookUp[iindex].LookUpId == itype ) fprintf(out,"%e ",CN[itype]); else fprintf(out,"%e ",ZERO); } while ((int)LookUp[iindex].LookUpId != itype); } for (iindex = LookUp[active_ntypes].LookUpId+1;iindex<=(int)ntypes ;iindex++) fprintf(out,"%e ",ZERO); fprintf(out,"\n"); } } fclose(out); #endif /*#ifdef DLL*/ /* if patient didn't die and has cells less than diagnosis, then NED event */ if (GuaranteeReset == False) { TotalCells = AllCells(); sprintf(stemp,"%e",TotalCells); /* if(TotalCells < diagnosis_threshold)*/ if (DiagnosedNow == False ) { /*if patient didn't die and has cells less than diagnosis, // then an end of followup with NED event */ AddToEventQ((t-delta_t),EFUNEDEVENT,stemp,".","."); } else { /* Patient didn't die, and had a diagnosable tumor // so add an end of follow up event with tumor */ AddToEventQ((t - delta_t),EFUTUMEVENT,stemp,".","."); } /*//if a CR or PR is pending, but the simulation ended before it couldn't //be checked after the TumorExamInterval is up, post it now.*/ if (CompleteResponse.checked == True) AddToEventQ(CompleteResponse.time,CREVENT,".",".","."); else if (PartialResponse.checked == True) AddToEventQ(PartialResponse.time,RESPONSEEVENT,".",".","."); } /* // else // AddToEventQ((t - delta_t),NORESPONSEEVENT,".",".",".");*/ /*#endif */ SimRunning = False; release_mem(SIM); return; }
void prime_sieve(uint64_t low_prime, uint64_t high_prime, void(*fun)(uint64_t), uint32_t mod, const uint_fast32_t *map) { uint64_t composite, prime, low_end_of_range, candidate; uint_fast32_t *sieve; uint32_t sieve_index, i, j, k; assert(primes_in_prime_table > 0); if (low_prime <= prime_table[primes_in_prime_table-1]) { /* Skip ahead to low_prime. A binary search would be faster. */ for (i = 0; prime_table[i] < low_prime; i++) ; while (i < primes_in_prime_table) { if (mod == 0) /* Null filter */ for (j = MIN(i+PROGRESS_STEP/3,primes_in_prime_table); i < j; i++) { if (prime_table[i] > high_prime) return; check_events(prime_table[i]); fun(prime_table[i]); } else if (map == NULL) /* Global GFN filter */ for (j = MIN(i+PROGRESS_STEP/3,primes_in_prime_table); i < j; i++) { if (prime_table[i] > high_prime) return; if (((uint_fast32_t)prime_table[i] & mod) == 0) { check_events(prime_table[i]); fun(prime_table[i]); } } else /* Global QR filter */ for (j = MIN(i+PROGRESS_STEP/3,primes_in_prime_table); i < j; i++) { if (prime_table[i] > high_prime) return; if (test_bit(map,prime_table[i]%mod)) { check_events(prime_table[i]); fun(prime_table[i]); } } check_progress(); } low_end_of_range = prime_table[primes_in_prime_table-1]+1; } else /* Set low_end_of_range to the greatest even number <= low_prime */ low_end_of_range = (low_prime | 1) - 1; sieve = make_bitmap(RANGE_SIZE); primes_used_in_range = 0; while (low_end_of_range <= high_prime) { setup_sieve(low_end_of_range); fill_bits(sieve,0,RANGE_SIZE-1); for (i = 0; i < primes_used_in_range; i++) { prime = prime_table[i]; composite = composite_table[i]; sieve_index = (composite - low_end_of_range)/2; while (composite < low_end_of_range + 2*RANGE_SIZE) { clear_bit(sieve,sieve_index); sieve_index += prime; composite += 2*prime; } composite_table[i] = composite; } k = MIN((high_prime-low_end_of_range+1)/2,RANGE_SIZE); i = first_bit(sieve); while (i < k) { if (mod == 0) /* Null filter */ for (j = MIN(i+PROGRESS_STEP,k); i < j; i = next_bit(sieve,i+1)) { candidate = low_end_of_range + 2*i + 1; check_events(candidate); fun(candidate); } else if (map == NULL) /* Global GFN filter */ for (j = MIN(i+PROGRESS_STEP,k); i < j; i = next_bit(sieve,i+1)) { candidate = low_end_of_range + 2*i + 1; if (((uint_fast32_t)candidate & mod) == 0) { check_events(candidate); fun(candidate); } } else /* Global QR filter */ for (j = MIN(i+PROGRESS_STEP,k); i < j; i = next_bit(sieve,i+1)) { candidate = low_end_of_range + 2*i + 1; if (test_bit(map,candidate%mod)) { check_events(candidate); fun(candidate); } } check_progress(); } low_end_of_range += 2*RANGE_SIZE; } free(sieve); }
int main(void) { main_init(); rtca_init(); timer_a0_init(); uart0_init(); sim900_init_messagebus(); sim900.next_state = SIM900_OFF; settings_init(SEGMENT_B, VERSION_BASED); //settings_apply(); m.e = 0x0; m.seg[0] = 0x0; m.seg_num = 1; stat.http_post_version = POST_VERSION; stat.fix_id = 1; sim900.imei[0] = 0; sim900.flags = 0; gps_trigger_next = 0; gprs_trigger_next = s.gprs_loop_interval; rtca_set_next = 0; rtc_not_set = 1; gps_next_state = MAIN_GPS_IDLE; if (s.gps_invalidate_interval > s.gps_loop_interval) { s.gps_invalidate_interval = s.gps_loop_interval; } gprs_tx_trig = 0; gprs_tx_next = s.gprs_static_tx_interval; gprs_blackout_lift = 0; #ifdef DEBUG_GPS uart1_init(9600); uart1_tx_str("gps debug state\r\n", 17); #endif #ifdef DEBUG_GPRS uart0_tx_str("gprs debug state\r\n", 18); display_menu(); #endif #ifdef CALIBRATION sys_messagebus_register(&adc_calibration, SYS_MSG_RTC_SECOND); #else #ifndef DEBUG_GPRS sys_messagebus_register(&schedule, SYS_MSG_RTC_SECOND); sys_messagebus_register(&parse_gps, SYS_MSG_UART0_RX); #else sys_messagebus_register(&parse_UI, SYS_MSG_UART0_RX); #endif #ifndef DEBUG_GPS sys_messagebus_register(&parse_gprs, SYS_MSG_UART1_RX); #endif #endif #ifdef FM24_HAS_SLEEP_MODE fm24_sleep(); #endif // main loop while (1) { _BIS_SR(LPM3_bits + GIE); //wake_up(); #ifdef USE_WATCHDOG // reset watchdog counter WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL; #endif // new messages can be sent from within a check_events() call, so // parse the message linked list multiple times check_events(); check_events(); check_events(); #ifdef FM24_HAS_SLEEP_MODE // sleep if (fm24_status & FM24_AWAKE) { fm24_sleep(); } #endif // P4.0 and P4.1 //P4SEL &= ~0x3; /* PMMCTL0_H = 0xA5; SVSMHCTL &= ~SVMHE; SVSMLCTL &= ~(SVSLE+SVMLE); PMMCTL0_H = 0x00; */ } }