/* Dump user databases */ int main(){ umask(066); try { cfg.read(CFG_FILE); /* read parameters from the config file */ local_dump_db(cfg, 0, NULL); } catch(Err e) { process_result(e); } catch(Json::Err e) { process_result(e); } catch(JsonDB::Err e){ process_result(e); } catch (Exc e) { process_result(e); } exit(0); }
int ofApp::engineClose() { char const *uttid; int rv; int32 score; rv = ps_end_utt(ps); if (rv < 0) { return 1; } hyp = ps_get_hyp(ps, &score); if (hyp == NULL) { return 1; } printf("NEWLINE_________\n\n\nRecognized: %s\n", hyp); sentence = hyp; process_result(); }
/** * Select a subset of the items in the datastore and call * the given iterator for each of them. * * @param cls our `struct Plugin *` * @param offset offset of the result (modulo num-results); * specific ordering does not matter for the offset * @param type entries of which type should be considered? * Use 0 for any type. * @param proc function to call on the matching value; * will be called with a NULL if no value matches * @param proc_cls closure for @a proc */ static void postgres_plugin_get_zero_anonymity (void *cls, uint64_t offset, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls) { struct Plugin *plugin = cls; uint32_t utype = type; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint32 (&utype), GNUNET_PQ_query_param_uint64 (&offset), GNUNET_PQ_query_param_end }; PGresult *ret; ret = GNUNET_PQ_exec_prepared (plugin->dbh, "select_non_anonymous", params); process_result (plugin, proc, proc_cls, ret, __FILE__, __LINE__); }
static awk_value_t * do_pg_exec(int nargs, awk_value_t *result) { PGconn *conn; awk_value_t command; PGresult *res; if (do_lint && (nargs > 2)) lintwarn(ext_id, _("pg_exec: called with too many arguments")); if (!(conn = find_handle(conns, 0))) { set_ERRNO(_("pg_exec called with unknown connection handle")); RET_NULSTR; } if (!get_argument(1, AWK_STRING, &command)) { set_ERRNO(_("pg_exec 2nd argument should be a string")); RET_NULSTR; } res = PQexec(conn, command.str_value.str); if (!res) { /* I presume the connection is probably bad, since no result returned */ set_error(conn, PQresultStatus(NULL), result); set_ERRNO(PQerrorMessage(conn)); return result; } return process_result(conn, res, result); }
static json_t * hardware_process(void *results) { hardware_results_t *raw_results = results; result_desc_t desc = { .stable = false, .name = "Nop syscall overhead", .ignored = N_IGNORED }; result_t nopnulsyscall_result = process_result(N_RUNS, raw_results->nullSyscall_overhead, desc); /* Execlude ccnt, user-level and loop overheads */ desc.overhead = nopnulsyscall_result.min; result_t result = process_result(N_RUNS, raw_results->nullSyscall_results, desc); result_set_t set = { .name = "Hardware null_syscall thread", .n_results = 1, .n_extra_cols = 0, .results = &result }; json_t *array = json_array(); json_array_append_new(array, result_set_to_json(set)); set.name = "Nop syscall overhead"; set.results = &nopnulsyscall_result; json_array_append_new(array, result_set_to_json(set)); return array; } static benchmark_t hardware_benchmark = { .name = "hardware", .enabled = config_set(CONFIG_APP_HARDWAREBENCH), .results_pages = BYTES_TO_SIZE_BITS_PAGES(sizeof(hardware_results_t), seL4_PageBits), .process = hardware_process, .init = blank_init }; benchmark_t * hardware_benchmark_new(void) { return &hardware_benchmark; }
/**************************************************************************\ * Name: fc_test_exec * * Input: * * Output: None * * Description: Unit test executer function. Can be autogenerated in future* \**************************************************************************/ void fc_test_exec() { BYTE index; /* TODO - Declare local variables for function parameters */ /* e.g. PARAM1_TYPE arg1; */ PARAM_0_TYPE arg0; /* TODO - (Optional) declare local variables for return type */ #if __RET_TYP_NOT_VOID__ RETURN_TYPE expected_res; RETURN_TYPE actual_res; #endif for(index = 0; index < MAX_NUM_TEST_CASES; index++) { /* Set global variables */ set_global_vars(index); /* TODO- populate the function arguments */ /* e.g. arg1 = st_arr_test_inputs[index].arg1; */ arg0 = st_arr_test_inputs[index].arg0; #if __RET_TYP_NOT_VOID__ expected_res = st_arr_test_inputs[index].ret_val; if(NULL != st_arr_test_inputs[index].fptr) { /* TODO - Edit following line to pass all arguments to the function */ actual_res = st_arr_test_inputs[index].fptr(arg0); process_result(expected_res, actual_res, index); } else { /*printf("Null function pointer for testId: %d\n",index);*/ } #else if(NULL != st_arr_test_inputs[index].fptr) { /* TODO - Edit following line to pass all arguments to the function */ st_arr_test_inputs[index].fptr(arg0); } else { /*printf("Null function pointer for testId: %d\n",index);*/ } #endif /* potentially pass this value to a logger for pass or fail */ } }
static gboolean process_completed (GckCallClass *klass) { gpointer call; g_assert (klass->completed_queue); call = g_async_queue_try_pop (klass->completed_queue); if (call) { process_result (call, NULL); g_object_unref (call); return TRUE; } return FALSE; }
int process_output_file(const char* file_name, SuiteSummary *summary) { char* buffer = read_file_to_memory(file_name); char* p = buffer; if (buffer == NULL) { return -1; } process_header(read_line(&p), summary); while(*p && *p != '#') { process_result(read_line(&p), summary->name); } process_footer(read_line(&p), summary); return 0; }
static awk_value_t * do_pg_getresult(int nargs, awk_value_t *result) { PGconn *conn; PGresult *res; if (do_lint && (nargs > 1)) lintwarn(ext_id, _("pg_getresult: called with too many arguments")); if (!(conn = find_handle(conns, 0))) { set_ERRNO(_("pg_getresult called with unknown connection handle")); RET_NULSTR; } if (!(res = PQgetResult(conn))) /* this just means there are no results currently available, so it is not necessarily an error */ RET_NULSTR; return process_result(conn, res, result); }
/** * Get a random item for replication. Returns a single, not expired, * random item from those with the highest replication counters. The * item's replication counter is decremented by one IF it was positive * before. Call @a proc with all values ZERO or NULL if the datastore * is empty. * * @param cls closure with the `struct Plugin` * @param proc function to call the value (once only). * @param proc_cls closure for @a proc */ static void postgres_plugin_get_replication (void *cls, PluginDatumProcessor proc, void *proc_cls) { struct Plugin *plugin = cls; struct ReplCtx rc; PGresult *ret; rc.plugin = plugin; rc.proc = proc; rc.proc_cls = proc_cls; ret = PQexecPrepared (plugin->dbh, "select_replication_order", 0, NULL, NULL, NULL, 1); process_result (plugin, &repl_proc, &rc, ret, __FILE__, __LINE__); }
static awk_value_t * do_pg_execparams(int nargs, awk_value_t *result) { PGconn *conn; awk_value_t command; int nParams; const char **paramValues; PGresult *res; if (do_lint && (nargs > 4)) lintwarn(ext_id, _("pg_execparams: called with too many arguments")); if (!(conn = find_handle(conns, 0))) { set_ERRNO(_("pg_execparams called with unknown connection handle")); RET_NULSTR; } if ((nParams = get_params(nargs, 2, ¶mValues)) < 0) { set_ERRNO(_("pg_execparams called with negative nParams")); RET_NULSTR; } if (!get_argument(1, AWK_STRING, &command)) { set_ERRNO(_("pg_execparams 2nd argument should be a string")); RET_NULSTR; } res = PQexecParams(conn, command.str_value.str, nParams, NULL, paramValues, NULL, NULL, 0); if (paramValues) free(paramValues); if (!res) { /* I presume the connection is probably bad, since no result returned */ set_error(conn, PQresultStatus(NULL), result); set_ERRNO(PQerrorMessage(conn)); return result; } return process_result(conn, res, result); }
/** * Get a random item for expiration. Call @a proc with all values * ZERO or NULL if the datastore is empty. * * @param cls closure with the `struct Plugin` * @param proc function to call the value (once only). * @param proc_cls closure for @a proc */ static void postgres_plugin_get_expiration (void *cls, PluginDatumProcessor proc, void *proc_cls) { struct Plugin *plugin = cls; struct GNUNET_TIME_Absolute now; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_absolute_time (&now), GNUNET_PQ_query_param_end }; PGresult *ret; now = GNUNET_TIME_absolute_get (); ret = GNUNET_PQ_exec_prepared (plugin->dbh, "select_expiration_order", params); process_result (plugin, proc, proc_cls, ret, __FILE__, __LINE__); }
/** * Listen for incoming messages on this chat room. Also, support servers going * away/coming back (i.e. rejoin chat room to keep server state up to date). * * @param cls closure, pointer to the 'struct GNUNET_CHAT_Room' * @param msg message received, NULL on timeout or fatal error */ static void receive_results (void *cls, const struct GNUNET_MessageHeader *msg) { struct GNUNET_CHAT_Room *chat_room = cls; #if DEBUG_CHAT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a message from the service\n"); #endif if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason ())) return; if (NULL == msg) { GNUNET_break (0); rejoin_room (chat_room); return; } process_result (chat_room, msg); if (NULL == chat_room->client) return; /* fatal error */ /* continue receiving */ GNUNET_CLIENT_receive (chat_room->client, &receive_results, chat_room, GNUNET_TIME_UNIT_FOREVER_REL); }
static json_t * process(void *results) { irq_results_t *irq_results = (irq_results_t *) results; /* Sort and group data by tracepoints. A stable sort is used so the first N_IGNORED * results of each tracepoint can be ignored, as this keeps the data in chronological * order. */ logging_stable_sort_log(irq_results->kernel_log, irq_results->n); logging_group_log_by_key(irq_results->kernel_log, irq_results->n, sizes, offsets, CONFIG_MAX_NUM_TRACE_POINTS); /* Copy the cycle counts into a separate array to simplify further processing */ for (int i = 0; i < irq_results->n; ++i) { kernel_log_data[i] = kernel_logging_entry_get_data(&irq_results->kernel_log[i]); } /* Process log entries generated by an "empty" tracepoint, which recorded * the number of cycles between starting a tracepoint and stopping it * immediately afterwards. This will determine the overhead introduced by * using tracepoints. */ int n_overhead_data = sizes[TRACE_POINT_OVERHEAD] - N_IGNORED; if (n_overhead_data <= 0) { ZF_LOGF("Insufficient data recorded. Was the kernel built with the relevant tracepoints?\n"); } ccnt_t *overhead_data = &kernel_log_data[offsets[TRACE_POINT_OVERHEAD] + N_IGNORED]; /* The results of the IRQ path benchmark are split over multiple tracepoints. * A new buffer is allocated to store the amalgamated results. */ int n_data = sizes[TRACE_POINT_IRQ_PATH_START] - N_IGNORED; if (n_data <= 0) { ZF_LOGF("Insufficient data recorded. Was the kernel built with the relevant tracepoints?\n"); } ccnt_t *data = (ccnt_t*)malloc(sizeof(ccnt_t) * n_data); if (data == NULL) { ZF_LOGF("Failed to allocate memory\n"); } json_t *array = json_array(); result_desc_t desc = {0}; result_t result = process_result(n_overhead_data, overhead_data, desc); result_set_t set = { .name = "Tracepoint overhead", .n_results = 1, .results = &result, }; json_array_append_new(array, result_set_to_json(set)); /* Add the results from the IRQ path tracepoints to get the total IRQ path cycle counts. * The average overhead is subtracted from each cycle count (doubled as there are 2 * tracepoints) to account for overhead added to the cycle counts by use of tracepoints. */ ccnt_t *starts = &kernel_log_data[offsets[TRACE_POINT_IRQ_PATH_START] + N_IGNORED]; ccnt_t *ends = &kernel_log_data[offsets[TRACE_POINT_IRQ_PATH_END] + N_IGNORED]; for (int i = 0; i < n_data; ++i) { data[i] = starts[i] + ends[i] - (result.mean * 2); } set.name = "IRQ Path Cycle Count (accounting for overhead)"; result = process_result(n_data, data, desc); json_array_append_new(array, result_set_to_json(set)); free(data); return array; } static benchmark_t irq_benchmark = { .name = "irq", .enabled = config_set(CONFIG_APP_IRQBENCH) && CONFIG_MAX_NUM_TRACE_POINTS == 3, .results_pages = BYTES_TO_SIZE_BITS_PAGES(sizeof(irq_results_t), seL4_PageBits), .process = process, .init = blank_init }; benchmark_t * irq_benchmark_new(void) { return &irq_benchmark; } static json_t * irquser_process(void *r) { irquser_results_t *raw_results = r; result_desc_t desc = { .ignored = N_IGNORED, .name = "IRQ user measurement overhead" }; result_t results[3]; results[0] = process_result(N_RUNS, raw_results->overheads, desc); desc.overhead = results[0].min; results[1] = process_result(N_RUNS, raw_results->thread_results, desc); results[2] = process_result(N_RUNS, raw_results->process_results, desc); char *types[] = {"Measurement overhead", "Without context switch", "With context switch"}; column_t col = { .header = "Type", .type = JSON_STRING, .string_array = types }; result_set_t set = { .name = "IRQ path cycle count (measured from user level)", .n_results = 3, .results = results, .n_extra_cols = 1, .extra_cols = &col }; json_t *json = json_array(); json_array_append_new(json, result_set_to_json(set)); return json; } static benchmark_t irquser_benchmark = { .name = "irquser", .enabled = config_set(CONFIG_APP_IRQUSERBENCH), .results_pages = BYTES_TO_SIZE_BITS_PAGES(sizeof(irquser_results_t), seL4_PageBits), .process = irquser_process, .init = blank_init }; benchmark_t * irquser_benchmark_new(void) { return &irquser_benchmark; }
/** * Iterate over the results for a particular key * in the datastore. * * @param cls closure with the 'struct Plugin' * @param offset offset of the result (modulo num-results); * specific ordering does not matter for the offset * @param key maybe NULL (to match all entries) * @param vhash hash of the value, maybe NULL (to * match all values that have the right key). * Note that for DBlocks there is no difference * betwen key and vhash, but for other blocks * there may be! * @param type entries of which type are relevant? * Use 0 for any type. * @param proc function to call on the matching value; * will be called once with a NULL if no value matches * @param proc_cls closure for iter */ static void postgres_plugin_get_key (void *cls, uint64_t offset, const struct GNUNET_HashCode *key, const struct GNUNET_HashCode *vhash, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls) { struct Plugin *plugin = cls; uint32_t utype = type; PGresult *ret; uint64_t total; uint64_t limit_off; if (0 != type) { if (NULL != vhash) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (key), GNUNET_PQ_query_param_auto_from_type (vhash), GNUNET_PQ_query_param_uint32 (&utype), GNUNET_PQ_query_param_end }; ret = GNUNET_PQ_exec_prepared (plugin->dbh, "count_getvt", params); } else { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (key), GNUNET_PQ_query_param_uint32 (&utype), GNUNET_PQ_query_param_end }; ret = GNUNET_PQ_exec_prepared (plugin->dbh, "count_gett", params); } } else { if (NULL != vhash) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (key), GNUNET_PQ_query_param_auto_from_type (vhash), GNUNET_PQ_query_param_end }; ret = GNUNET_PQ_exec_prepared (plugin->dbh, "count_getv", params); } else { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (key), GNUNET_PQ_query_param_end }; ret = GNUNET_PQ_exec_prepared (plugin->dbh, "count_get", params); } } if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh, ret, PGRES_TUPLES_OK, "PQexecParams", "count")) { proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); return; } if ( (PQntuples (ret) != 1) || (PQnfields (ret) != 1) || (PQgetlength (ret, 0, 0) != sizeof (uint64_t))) { GNUNET_break (0); PQclear (ret); proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); return; } total = GNUNET_ntohll (*(const uint64_t *) PQgetvalue (ret, 0, 0)); PQclear (ret); if (0 == total) { proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); return; } limit_off = offset % total; if (0 != type) { if (NULL != vhash) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (key), GNUNET_PQ_query_param_auto_from_type (&vhash), GNUNET_PQ_query_param_uint32 (&utype), GNUNET_PQ_query_param_uint64 (&limit_off), GNUNET_PQ_query_param_end }; ret = GNUNET_PQ_exec_prepared (plugin->dbh, "getvt", params); } else { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (key), GNUNET_PQ_query_param_uint32 (&utype), GNUNET_PQ_query_param_uint64 (&limit_off), GNUNET_PQ_query_param_end }; ret = GNUNET_PQ_exec_prepared (plugin->dbh, "gett", params); } } else { if (NULL != vhash) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (key), GNUNET_PQ_query_param_auto_from_type (&vhash), GNUNET_PQ_query_param_uint64 (&limit_off), GNUNET_PQ_query_param_end }; ret = GNUNET_PQ_exec_prepared (plugin->dbh, "getv", params); } else { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (key), GNUNET_PQ_query_param_uint64 (&limit_off), GNUNET_PQ_query_param_end }; ret = GNUNET_PQ_exec_prepared (plugin->dbh, "get", params); } } process_result (plugin, proc, proc_cls, ret, __FILE__, __LINE__); }
void check_connections(void) { fd_set fds_write; fd_set fds_read; int i; struct timeval timeout; time_t now; FD_ZERO(&fds_write); /* These are for connection being established */ FD_ZERO(&fds_read); /* These are for a reply being ready */ /* FD_SET(0, &fds_read);*/ for (i = 0 ; i < MAX_IDENTS_IN_PROGRESS ; i++) { if (idents_in_progress[i].local_port) { if (idents_in_progress[i].flags & IDENT_CONNREFUSED) { process_result(i); } else if (!(idents_in_progress[i].flags & IDENT_CONNECTED)) { FD_SET(idents_in_progress[i].fd, &fds_write); } else { FD_SET(idents_in_progress[i].fd, &fds_read); } } else { /* Free slot, so lets try to fill it */ take_off_queue(i); } } #if defined(NOALARM) timeout.tv_sec = 1; timeout.tv_usec = 0; #else /* !NOALARM */ timeout.tv_sec = 0; timeout.tv_usec = 0; #endif /* NOALARM */ i = select(FD_SETSIZE, &fds_read, &fds_write, 0, &timeout); switch (i) { case -1: #if defined(DEBUG_IDENT_TOO) fprintf(stderr, "ident: select failed\n"); #endif /* DEBUG_IDENT_TOO */ break; case 0: break; default: for (i = 0 ; i < MAX_IDENTS_IN_PROGRESS ; i++) { if (FD_ISSET(idents_in_progress[i].fd, &fds_write)) { /* Has now connected, so send request */ idents_in_progress[i].flags |= IDENT_CONNECTED; write_request(&idents_in_progress[i]); } else if (FD_ISSET(idents_in_progress[i].fd, &fds_read)) { /* Reply is ready, so process it */ idents_in_progress[i].flags |= IDENT_REPLY_READY; process_result(i); } } } now = time(NULL); for (i = 0 ; i < MAX_IDENTS_IN_PROGRESS ; i++) { if (idents_in_progress[i].local_port) { if (now > (idents_in_progress[i].request_time + IDENT_TIMEOUT)) { /* Request has timed out, whether on connect or reply */ idents_in_progress[i].flags |= IDENT_TIMEDOUT; process_result(i); } } } }
static int test_case(int in, int ref) { return process_result(in, main_test(in), ref); }
int main(void) { char *send_buf = NULL; // negotiate type 2 vuln on fd 3 unsigned int neg[1] = {2}; // vals[0] == type2_addr, vals[1] == type2_size, vals[2] == type2_length unsigned int vals[3] = {0}; if (sizeof(neg) != send_bytes(3, (const char *)neg, sizeof(neg))) { _terminate(4); } if (sizeof(vals) != recv_bytes(3, (char *)vals, sizeof(vals))) { _terminate(5); } // define random CONTENT_LEN between 10 and 255 rand(&CONTENT_LEN, 1); if (10 > CONTENT_LEN) { CONTENT_LEN += 10; } #ifdef DEBUG fprintf(stderr, "CONTENT LEN...%i.\n", CONTENT_LEN); #endif if (0 != allocate(CONTENT_LEN, 0, (void **)&send_buf)) { _terminate(6); } cgc_memset(secret, 0, RAND_PG_SZ); cgc_memset(found, 0, RAND_PG_SZ); // loop until have enough consecutive bytes while (get_consecutive_cnt() < vals[2]) { cgc_memset(send_buf, 0, CONTENT_LEN); get_gimme_banner(); create_content(send_buf); // set offset // caution: this might insert TERM value into send_buf; // but it shouldn't because index 3 will be recovered // at the same time as index 0, so it should skip index 3. *(unsigned short *)send_buf = get_first_empty_offset(); send_content(send_buf); get_done_banner(); process_result(send_buf); } if (0 != deallocate(send_buf, CONTENT_LEN)) { _terminate(7); } #ifdef DEBUG fprintf(stderr, "SUBMIT FLAG...\n"); #endif // submit secret bytes #ifdef DEBUG char *s_ptr = secret; fprintf(stderr, "FLAG: "); for (unsigned int i = 0; i < vals[2]; i++) { fprintf(stderr, "%02x", (unsigned char) *s_ptr++); } fprintf(stderr, "\n"); #endif if (vals[2] != send_bytes(3, secret, vals[2])) { _terminate(10); } #ifdef DEBUG fprintf(stderr, "sent\n"); #endif }