void test_pipeline_uniforms (void) { TestState state; init_state (&state); cogl_framebuffer_orthographic (test_fb, 0, 0, cogl_framebuffer_get_width (test_fb), cogl_framebuffer_get_height (test_fb), -1, 100); paint (&state); validate_result (); /* Try the test again after querying the location of a large number of uniforms. This should verify that the bitmasks still work even if they have to allocate a separate array to store the bits */ init_long_pipeline_state (&state); paint (&state); paint_long_pipeline (&state); validate_result (); validate_long_pipeline_result (); destroy_state (&state); if (cogl_test_verbose ()) g_print ("OK\n"); }
/* * remove specified channel state from table * (scrubs and frees space in table for a new channel) */ void remove_channel(int channel){ channelTable[channel-1].nextChannel = nextFree; init_state(&(channelTable[channel-1].state),channel); channelTable[channel-1].active = 0; nextFree = &channelTable[channel-1]; size--; }
int main() { init_state(); terminal_initialize(); char s[MAX_LEN]; int result; while (1) { result = insert_nxt_char(s); if (result == -1) { write_sentence(COLOR_WHITE, "Error: buffer overflow"); break; } else if (result == 1) break; } if (result != -1) //if no error write_sentence(COLOR_WHITE, s); //restores state of eflags __asm__ ( "pushfl \n\t" "mov old_eflags, %ecx \n\t" "mov %ecx, 0(%esp) \n\t" "popfl" ); return 0; }
void test_correctness(void) { struct watchman_ignore state; static const struct test_case tests[] = { {"some/path", false}, {"buck-out/gen/foo", true}, {".hg/wlock", false}, {".hg/store/foo", true}, {"buck-out", true}, {"foo/buck-out", true}, {"foo/hello", false}, {"baz/hello", false}, {".hg", false}, {"buil", false}, {"build", true}, {"build/lower", true}, {"builda", false}, {"build/bar", true}, {"buildfile", false}, {"build/lower/baz", true}, {"builda/hello", false}, }; init_state(&state); run_correctness_test(&state, tests, sizeof(tests) / sizeof(tests[0])); }
void init_world() { init_encoders(); init_state(); init_goals_buffer(); init_captors(); }
bool vl_zscan_init(struct vl_zscan *zscan, struct pipe_context *pipe, unsigned buffer_width, unsigned buffer_height, unsigned blocks_per_line, unsigned blocks_total, unsigned num_channels) { assert(zscan && pipe); zscan->pipe = pipe; zscan->buffer_width = buffer_width; zscan->buffer_height = buffer_height; zscan->num_channels = num_channels; zscan->blocks_per_line = blocks_per_line; zscan->blocks_total = blocks_total; if(!init_shaders(zscan)) return false; if(!init_state(zscan)) { cleanup_shaders(zscan); return false; } return true; }
int _tmain(int argc, TCHAR *argv[]) { int res = -1; program_state_t state; if (argc != 4) { _tprintf(_T("Usage: %s <file> <num of threads> <max chunk size (bytes)>\n"), argv[0]); return -1; } _tcscpy_s(state.filename, argv[1]); state.num_of_threads = _tstoi(argv[2]); state.chunk_size = _tstoi(argv[3]); if (!init_state(&state)) { goto cleanup; } if (compute_checksums(&state)) { // return checksum _tprintf(_T("Total checksum: %d"), (unsigned int)state.checksum); res = (unsigned int)state.checksum; } cleanup: fini_state(&state); return res; }
int engine_init(struct engine *engine, knot_mm_t *pool) { if (engine == NULL) { return kr_error(EINVAL); } memset(engine, 0, sizeof(*engine)); engine->pool = pool; /* Initialize state */ int ret = init_state(engine); if (ret != 0) { engine_deinit(engine); } /* Initialize resolver */ ret = init_resolver(engine); if (ret != 0) { engine_deinit(engine); return ret; } /* Initialize network */ network_init(&engine->net, uv_default_loop()); return ret; }
VCL_BACKEND sharddir_pick_be(VRT_CTX, struct sharddir *shardd, uint32_t key, VCL_INT alt, VCL_REAL warmup, VCL_BOOL rampup, enum healthy_e healthy) { VCL_BACKEND be; struct shard_state state[1]; unsigned picklist_sz; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC); sharddir_rdlock(shardd); if (shardd->n_backend == 0) { shard_err0(ctx, shardd, "no backends"); sharddir_unlock(shardd); return (NULL); } picklist_sz = VBITMAP_SZ(shardd->n_backend); char picklist_spc[picklist_sz]; memset(state, 0, sizeof(state)); init_state(state, ctx, shardd, vbit_init(picklist_spc, picklist_sz)); be = sharddir_pick_be_locked(ctx, shardd, key, alt, warmup, rampup, healthy, state); sharddir_unlock(shardd); vbit_destroy(state->picklist); return (be); }
static void reconf_reboot(int action, int argc, char **argv, int oi) { struct if_head *ifs; struct interface *ifn, *ifp; ifs = discover_interfaces(argc - oi, argv + oi); if (ifs == NULL) return; while ((ifp = TAILQ_FIRST(ifs))) { TAILQ_REMOVE(ifs, ifp, next); ifn = find_interface(ifp->name); if (ifn) { if (action) if_reboot(ifn, argc, argv); else ipv4_applyaddr(ifn); free_interface(ifp); } else { init_state(ifp, argc, argv); TAILQ_INSERT_TAIL(ifaces, ifp, next); start_interface(ifp); } } free(ifs); sort_interfaces(); }
MatrixCubicVerifier::MatrixCubicVerifier(int batch, int reps, int ip_size, int optimize_answers, char *prover_url) : Verifier(batch, NUM_REPS_PCP, ip_size, optimize_answers, prover_url, NAME_PROVER) { size_input = 2 * ip_size * ip_size; size_output = ip_size * ip_size; init_state(); }
/** * _pango_layout_line_ellipsize: * @line: a #PangoLayoutLine * @attrs: Attributes being used for itemization/shaping * * Given a PangoLayoutLine with the runs still in logical order, ellipsize * it according the layout's policy to fit within the set width of the layout. **/ void _pango_layout_line_ellipsize (PangoLayoutLine *line, PangoAttrList *attrs) { EllipsizeState state; if (line->layout->ellipsize == PANGO_ELLIPSIZE_NONE || line->layout->width < 0) return; init_state (&state, line, attrs); if (state.total_width <= state.layout->width) goto out; find_initial_span (&state); while (current_width (&state) > state.layout->width) { if (!remove_one_span (&state)) break; } fixup_ellipsis_run (&state); g_slist_free (line->runs); line->runs = get_run_list (&state); out: free_state (&state); }
int _tmain(int argc, TCHAR *argv[]) { int res = 0; program_state_t state; if (argc != 4) { _tprintf(_T("Usage: %s <port> <in folder> <num of threads>\n"), argv[0]); return -1; } state.port = _tstoi(argv[1]); _tcscpy_s(state.in_dir, argv[2]); state.num_of_threads = _tstoi(argv[3]); if (!init_state(&state)) { res = -1; goto cleanup; } if (!run_server(&state)) { res = -1; } cleanup: if (!fini_state(&state)) { res = -1; } return res; }
void test_cts(int bench, void cts_interp(), int iterations) { int start_time, end_time; int i; /* normal */ printf("[Tempo CTS]\n"); init_state(); /* initialize memory */ if (bench == TEST) { dump_mem(); /* verify memory contents */ cts_interp(); dump_mem(); } else { start_time = unix_time(); for( i = 0; i < iterations; i++) cts_interp(); end_time = unix_time(); print_time(start_time, end_time, 1); } printf("\n"); }
/* Used to read packets in random-access fashion */ static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info) { int num_bytes; direction_enum direction; pppdump_t *state; pkt_id *pid; gint64 num_bytes_to_skip; state = (pppdump_t *)wth->priv; pid = (pkt_id *)g_ptr_array_index(state->pids, seek_off); if (!pid) { *err = WTAP_ERR_BAD_FILE; /* XXX - better error? */ *err_info = g_strdup("pppdump: PID not found for record"); return FALSE; } if (file_seek(wth->random_fh, pid->offset, SEEK_SET, err) == -1) return FALSE; init_state(state->seek_state); state->seek_state->offset = pid->offset; /* * We'll start reading at the first record containing data from * this packet; however, that doesn't mean "collate()" will * stop only when we've read that packet, as there might be * data for packets going in the other direction as well, and * we might finish processing one of those packets before we * finish processing the packet we're reading. * * Therefore, we keep reading until we get a packet that's * going in the direction we want. */ num_bytes_to_skip = pid->num_bytes_to_skip; do { if (!collate(state->seek_state, wth->random_fh, err, err_info, pd, &num_bytes, &direction, NULL, num_bytes_to_skip)) return FALSE; num_bytes_to_skip = 0; } while (direction != pid->dir); if (len != num_bytes) { *err = WTAP_ERR_BAD_FILE; /* XXX - better error? */ *err_info = g_strdup_printf("pppdump: requested length %d doesn't match record length %d", len, num_bytes); return FALSE; } pseudo_header->p2p.sent = (pid->dir == DIRECTION_SENT ? TRUE : FALSE); return TRUE; }
int ui_main(){ register pState state = init_state(); while(1){ get_command(state); } return 0; }
bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe, unsigned buffer_width, unsigned buffer_height, unsigned nr_of_render_targets, struct pipe_sampler_view *matrix, struct pipe_sampler_view *transpose) { assert(idct && pipe); assert(matrix && transpose); idct->pipe = pipe; idct->buffer_width = buffer_width; idct->buffer_height = buffer_height; idct->nr_of_render_targets = nr_of_render_targets; pipe_sampler_view_reference(&idct->matrix, matrix); pipe_sampler_view_reference(&idct->transpose, transpose); if(!init_shaders(idct)) return false; if(!init_state(idct)) { cleanup_shaders(idct); return false; } return true; }
/** * rarch_main_new: * * Will teardown drivers and clears all * internal state of RetroArch. * If @inited is true, will initialize all * drivers again after teardown. **/ void rarch_main_new(void) { main_clear_state_drivers(); init_state(); main_init_state_config(); event_command(EVENT_CMD_MSG_QUEUE_INIT); }
int start() { unsigned short character = 0x00; int ipc_status; message msg; int irq_set_kb = kb_subscribe_int(); int irq_set_timer = timer_subscribe_int(); int irq_set_mouse = mouse_subscribe_int(); int r; unsigned char packet[3]; unsigned short counter = 0; space_invaders_font = font_init("spaceinvader_font_transparent.bmp"); srand(1); options_load(); mouse_init(); init_state(); highscore_load(); vg_init(VBE_VIDEO_MODE); while (1) { //TODO change condition /* Get a request message. */ if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) { printf("driver_receive failed with: %d", r); continue; } if (is_ipc_notify(ipc_status)) { /* received notification */ switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: /* hardware interrupt notification */ if (msg.NOTIFY_ARG & irq_set_kb) { /* keyboard interrupt */ character = kb_int_handler(); if (character != KB_2BYTE_SCODE) kb_event_handler(character); } if (msg.NOTIFY_ARG & irq_set_mouse){ /* mouse interrupt */ mouse_int_handler(counter, packet); if(packet[0] != MOUSE_ACK && (packet[0] & BIT(3))) counter++; if(counter == 3){ counter = 0; mouse_event_handler(packet); } } if (msg.NOTIFY_ARG & irq_set_timer){ /* timer interrupt */ timer_int_handler(); } break; default: break; /* no other notifications expected: do nothing */ } } else { /* received a standard message, not a notification */ /* no standard messages expected: do nothing */ } } return 0; }
tpr_t * guamps_init_tpr(const int natoms) { tpr_t *tpr = (tpr_t *)calloc(1, sizeof(tpr_t)); tpr->natoms = natoms; init_inputrec (&tpr->inputrec); init_state (&tpr->state, -1,-1,-1,-1); tpr->f = (rvec *)calloc(natoms, sizeof(rvec)); init_mtop (&tpr->mtop); return tpr; }
/* Used to read packets in random-access fashion */ static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { int num_bytes; guint8 *pd; direction_enum direction; pppdump_t *state; pkt_id *pid; gint64 num_bytes_to_skip; state = (pppdump_t *)wth->priv; pid = (pkt_id *)g_ptr_array_index(state->pids, seek_off); if (!pid) { *err = WTAP_ERR_BAD_FILE; /* XXX - better error? */ *err_info = g_strdup("pppdump: PID not found for record"); return FALSE; } if (file_seek(wth->random_fh, pid->offset, SEEK_SET, err) == -1) return FALSE; init_state(state->seek_state); state->seek_state->offset = pid->offset; ws_buffer_assure_space(buf, PPPD_BUF_SIZE); pd = ws_buffer_start_ptr(buf); /* * We'll start reading at the first record containing data from * this packet; however, that doesn't mean "collate()" will * stop only when we've read that packet, as there might be * data for packets going in the other direction as well, and * we might finish processing one of those packets before we * finish processing the packet we're reading. * * Therefore, we keep reading until we get a packet that's * going in the direction we want. */ num_bytes_to_skip = pid->num_bytes_to_skip; do { if (!collate(state->seek_state, wth->random_fh, err, err_info, pd, &num_bytes, &direction, NULL, num_bytes_to_skip)) return FALSE; num_bytes_to_skip = 0; } while (direction != pid->dir); pppdump_set_phdr(phdr, num_bytes, pid->dir); return TRUE; }
static void adsi_load(int reload) { int x = 0; struct ast_config *conf = NULL; struct ast_variable *v; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; char *name, *sname; init_state(); conf = ast_config_load("adsi.conf", config_flags); if (conf == CONFIG_STATUS_FILEMISSING || conf == CONFIG_STATUS_FILEUNCHANGED || conf == CONFIG_STATUS_FILEINVALID) { return; } for (v = ast_variable_browse(conf, "intro"); v; v = v->next) { if (!strcasecmp(v->name, "alignment")) { alignment = str2align(v->value); } else if (!strcasecmp(v->name, "greeting")) { if (x < ADSI_MAX_INTRO) { aligns[x] = alignment; ast_copy_string(intro[x], v->value, sizeof(intro[x])); x++; } } else if (!strcasecmp(v->name, "maxretries")) { if (atoi(v->value) > 0) { maxretries = atoi(v->value); } } } if (x) { total = x; } x = 0; for (v = ast_variable_browse(conf, "speeddial"); v; v = v->next) { char buf[3 * SPEEDDIAL_MAX_LEN]; char *stringp = buf; ast_copy_string(buf, v->value, sizeof(buf)); name = strsep(&stringp, ","); sname = strsep(&stringp, ","); if (!sname) { sname = name; } if (x < ADSI_MAX_SPEED_DIAL) { ast_copy_string(speeddial[x][0], v->name, sizeof(speeddial[x][0])); ast_copy_string(speeddial[x][1], name, 18); ast_copy_string(speeddial[x][2], sname, 7); x++; } } if (x) { speeds = x; } ast_config_destroy(conf); return; }
static ERL_NIF_TERM sig_init(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { state_t *state = init_state(); state->job = rs_sig_begin(RS_DEFAULT_BLOCK_LEN, RS_DEFAULT_STRONG_LEN); state->type = SIGNATURE; ERL_NIF_TERM result = enif_make_resource(env, state); enif_release_resource(state); return result; }
static ERL_NIF_TERM loadsig_init(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { state_t *state = init_state(); state->job = rs_loadsig_begin(&state->sig); state->type = LOADSIG; ERL_NIF_TERM result = enif_make_resource(env, state); enif_release_resource(state); return result; }
void handle_interface(int action, const char *ifname) { struct if_head *ifs; struct interface *ifp, *ifn, *ifl = NULL; const char * const argv[] = { ifname }; int i; if (action == -1) { ifp = find_interface(ifname); if (ifp != NULL) { ifp->options->options |= DHCPCD_DEPARTED; stop_interface(ifp); } return; } /* If running off an interface list, check it's in it. */ if (ifc) { for (i = 0; i < ifc; i++) if (strcmp(ifv[i], ifname) == 0) break; if (i >= ifc) return; } ifs = discover_interfaces(-1, UNCONST(argv)); TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) { if (strcmp(ifp->name, ifname) != 0) continue; /* Check if we already have the interface */ ifl = find_interface(ifp->name); if (ifl) { /* The flags and hwaddr could have changed */ ifl->flags = ifp->flags; ifl->hwlen = ifp->hwlen; if (ifp->hwlen != 0) memcpy(ifl->hwaddr, ifp->hwaddr, ifl->hwlen); } else { TAILQ_REMOVE(ifs, ifp, next); TAILQ_INSERT_TAIL(ifaces, ifp, next); } if (action == 1) { init_state(ifp, margc, margv); start_interface(ifp); } } /* Free our discovered list */ while ((ifp = TAILQ_FIRST(ifs))) { TAILQ_REMOVE(ifs, ifp, next); free_interface(ifp); } free(ifs); }
void bound_build(bound_t * bound, size_t end) { size_t hypothesis, i, j = 0, jstart; // Note: j does not require to be set to 0 bound_state_t * state; probability_t cur_state; // Handle potential nulls if (!bound || !(bound->nk_table) || !(bound->state)) { goto ERR_NULL_ARG; } state = bound->state; hypothesis = HSTART; // If expanding the build to higher hypotheses if (end > bound->max_n) { if (reallocate_bound(bound, end)) { hypothesis = bound->max_n + 1; // Begin at next hypothesis bound->max_n = end; } } for ( ; hypothesis <= bound->max_n; ++hypothesis) { cur_state = init_state(bound, state); jstart = 2; // Walk horizontally accross state space for (i = 1; continue_condition(jstart, hypothesis, cur_state, bound); ++i) { // Compute values and fill vector (vertically) for (j = jstart; j < hypothesis; ++j) { cur_state = calculate(state, hypothesis, j); // If at a previously computed stopping point, enter // unreachable state (probability 0). Add probability of // failure at this level to pk_table if (NUM_PROBES(i, j) == (bound->nk_table)[j + 1]) { jstart = j + 1; state->second[j] = 0.0; state->first[j] = 0.0; (bound->pk_table)[j + 1] = cur_state; } else { state->second[j] = cur_state; } } jstart = (i == 1) ? 1 : jstart; // Awkward check required to get around state(1, 1) = 1.0 necessarily swap(state); } bound->nk_table[hypothesis] = NUM_PROBES(i, j) - 2; // Sub 2 for increment of i and j after stopping condition } return; ERR_NULL_ARG: fprintf(stderr, "Provided bound struct contained null values or was itself null\n"); }
static ErlDrvSSizeT control(ErlDrvData drvstate, unsigned int command, char *args, ErlDrvSizeT argslen, char **rbuf, ErlDrvSizeT rbuflen) { state *st = (state *)drvstate; init_state(st, args, argslen); switch (command) { case ENDWIN: do_endwin(st); break; case INITSCR: do_initscr(st); break; case REFRESH: do_refresh(st); break; case CBREAK: do_cbreak(st); break; case NOCBREAK: do_nocbreak(st); break; case ECHO: do_echo(st); break; case NOECHO: do_noecho(st); break; case ADDCH: do_addch(st); break; case ADDSTR: do_addstr(st); break; case MOVE: do_move(st); break; case GETYX: do_getyx(st); break; case GETMAXYX: do_getmaxyx(st); break; case CURS_SET: do_curs_set(st); break; case WERASE: do_werase(st); break; case HAS_COLORS: do_has_colors(st); break; case START_COLOR: do_start_color(st); break; case INIT_PAIR: do_init_pair(st); break; case WATTRON: do_wattron(st); break; case WATTROFF: do_wattroff(st); break; case NL: do_nl(st); break; case NONL: do_nonl(st); break; case SCROLLOK: do_scrollok(st); break; case MVADDCH: do_mvaddch(st); break; case MVADDSTR: do_mvaddstr(st); break; case NEWWIN: do_newwin(st); break; case DELWIN: do_delwin(st); break; case WMOVE: do_wmove(st); break; case WADDSTR: do_waddstr(st); break; case WADDCH: do_waddch(st); break; case MVWADDSTR: do_mvwaddstr(st); break; case MVWADDCH: do_mvwaddch(st); break; case WREFRESH: do_wrefresh(st); break; case WHLINE: do_whline(st); break; case WVLINE: do_wvline(st); break; case WBORDER: do_wborder(st); break; case BOX: do_box(st); break; case KEYPAD: do_keypad(st); break; default: break; } int rlen = st->eixb.index; ErlDrvBinary *response = driver_alloc_binary(rlen); memcpy(response->orig_bytes, st->eixb.buff, rlen); ei_x_free(&(st->eixb)); *rbuf = (char *)response; return rlen; }
int main(int argc, char **argv) { static GameState state = {NULL, NULL}; setjmp(resetbuf); init_state(&state); if (runlua(&state, "boot.lua")) { luareport(&state); } return 0; }
// for create new replica only used in replica_stub::on_config_proposal replica::replica(replica_stub* stub, global_partition_id gpid, replication_options& options) : serverlet<replica>("replica") { dassert (stub, ""); _stub = stub; _app = nullptr; _options = options; init_state(); _config.gpid = gpid; }
// for replica::load(..) only replica::replica(replica_stub* stub, replication_options& options) : serverlet<replica>("replica") { dassert (stub, ""); _stub = stub; _app = nullptr; _options = options; init_state(); }