void caml_set_minor_heap_size (asize_t size) { char *new_heap; void *new_heap_base; Assert (size >= Minor_heap_min); Assert (size <= Minor_heap_max); Assert (size % sizeof (value) == 0); if (caml_young_ptr != caml_young_end) caml_minor_collection (); Assert (caml_young_ptr == caml_young_end); new_heap = caml_aligned_malloc(size, 0, &new_heap_base); if (new_heap == NULL) caml_raise_out_of_memory(); if (caml_page_table_add(In_young, new_heap, new_heap + size) != 0) caml_raise_out_of_memory(); if (caml_young_start != NULL){ #ifdef SYS_xen /* XXX temporary until memory allocator works properly */ printk("caml_set_minor_heap_size: resize unsupported\n"); caml_raise_out_of_memory(); #else caml_page_table_remove(In_young, caml_young_start, caml_young_end); free (caml_young_base); #endif } caml_young_base = new_heap_base; caml_young_start = new_heap; caml_young_end = new_heap + size; caml_young_limit = caml_young_start; caml_young_ptr = caml_young_end; caml_minor_heap_size = size; reset_table (&caml_ref_table); reset_table (&caml_weak_ref_table); }
void caml_set_minor_heap_size (asize_t size) { char *new_heap; void *new_heap_base; Assert (size >= Minor_heap_min); Assert (size <= Minor_heap_max); Assert (size % sizeof (value) == 0); if (caml_young_ptr != caml_young_end) caml_minor_collection (); Assert (caml_young_ptr == caml_young_end); new_heap = caml_aligned_malloc(size, 0, &new_heap_base); if (new_heap == NULL) caml_raise_out_of_memory(); if (caml_page_table_add(In_young, new_heap, new_heap + size) != 0) caml_raise_out_of_memory(); if (caml_young_start != NULL){ caml_page_table_remove(In_young, caml_young_start, caml_young_end); free (caml_young_base); } caml_young_base = new_heap_base; caml_young_start = new_heap; caml_young_end = new_heap + size; caml_young_limit = caml_young_start; caml_young_ptr = caml_young_end; caml_minor_heap_size = size; reset_table (&caml_ref_table); reset_table (&caml_weak_ref_table); }
void caml_free_minor_tables(struct caml_minor_tables* r) { CAMLassert(r->major_ref.ptr == r->major_ref.base); CAMLassert(r->minor_ref.ptr == r->minor_ref.base); reset_table((struct generic_table *)&r->major_ref); reset_table((struct generic_table *)&r->minor_ref); reset_table((struct generic_table *)&r->ephe_ref); reset_table((struct generic_table *)&r->custom); caml_stat_free(r); }
void caml_set_minor_heap_size (asize_t wsize) { caml_domain_state* domain_state = Caml_state; struct caml_minor_tables *r = domain_state->minor_tables; if (domain_state->young_ptr != domain_state->young_end) caml_minor_collection (); caml_reallocate_minor_heap(wsize); reset_table ((struct generic_table *)&r->major_ref); reset_table ((struct generic_table *)&r->minor_ref); reset_table ((struct generic_table *)&r->ephe_ref); reset_table((struct generic_table *)&r->custom); }
G_MODULE_EXPORT void on_solver_class_changed (GtkComboBox *widget, gpointer user_data) { TableData *data = (TableData *) user_data; gtk_entry_set_text (data->indep_var1_entry, ""); gtk_entry_set_text (data->indep_var2_entry, ""); if( gtk_combo_box_get_active( data->SolverClassCombo ) == SINGLE_PHASE_SOLVER ) { gtk_combo_box_set_model( data->IndVariablesCombo, GTK_TREE_MODEL(data->IndVarsSinglePhaseModel) ); gtk_combo_box_set_active (data->IndVariablesCombo, 0); } else if( gtk_combo_box_get_active( data->SolverClassCombo ) == SATURATION_SOLVER ) { gtk_combo_box_set_model( data->IndVariablesCombo, GTK_TREE_MODEL(data->IndVarsSaturationModel) ); gtk_combo_box_set_active (data->IndVariablesCombo, 0); } reset_table (data); }
/* size in bytes */ void caml_set_minor_heap_size (asize_t size) { if (caml_domain_state->young_ptr != caml_domain_state->young_end) caml_minor_collection (); caml_reallocate_minor_heap(size); reset_table (&caml_domain_state->remembered_set->ref); }
G_MODULE_EXPORT void on_indep_variables_combo_changed (GtkComboBox *widget, gpointer user_data) { TableData *data = (TableData *) user_data; gtk_entry_set_text (data->indep_var1_entry, ""); gtk_entry_set_text (data->indep_var2_entry, ""); /* the single phase solvers list is active */ if( gtk_combo_box_get_active( data->SolverClassCombo ) == SINGLE_PHASE_SOLVER ) { if( gtk_combo_box_get_active( data->IndVariablesCombo ) == SOLVER_PT ) { gtk_label_set_text( data->IndVar1Label, "Pressure [bar]" ); gtk_label_set_text( data->IndVar2Label, "Temperature [°C]" ); } else if( gtk_combo_box_get_active( data->IndVariablesCombo ) == SOLVER_PH ) { gtk_label_set_text( data->IndVar1Label, "Pressure [bar]" ); gtk_label_set_text( data->IndVar2Label, "Enthalpy [kJ/kg]" ); } else if( gtk_combo_box_get_active( data->IndVariablesCombo ) == SOLVER_PS ) { gtk_label_set_text( data->IndVar1Label, "Pressure [bar]" ); gtk_label_set_text( data->IndVar2Label, "Entropy [kJ/kg·K]" ); } else if( gtk_combo_box_get_active( data->IndVariablesCombo ) == SOLVER_PU ) { gtk_label_set_text( data->IndVar1Label, "Pressure [bar]" ); gtk_label_set_text( data->IndVar2Label, "Internal energy [kJ/kg]" ); } else if (gtk_combo_box_get_active( data->IndVariablesCombo ) == SOLVER_TS) { gtk_label_set_text( data->IndVar1Label, "Temperature [°C]" ); gtk_label_set_text( data->IndVar2Label, "Entropy [kJ/kg·K]" ); } } /* the saturated solvers list is active */ else if( gtk_combo_box_get_active( data->SolverClassCombo ) == SATURATION_SOLVER ) { if( gtk_combo_box_get_active( data->IndVariablesCombo ) == SAT_SOLVER_TX ) { gtk_label_set_text( data->IndVar1Label, "Temperature [°C]" ); gtk_label_set_text( data->IndVar2Label, "Quality [-]" ); } else if( gtk_combo_box_get_active( data->IndVariablesCombo ) == SAT_SOLVER_PX ) { gtk_label_set_text( data->IndVar1Label, "Pressure [bar]" ); gtk_label_set_text( data->IndVar2Label, "Quality [-]" ); } } reset_table (data); }
G_MODULE_EXPORT void on_indep_var1_entry_editing_done(GtkEntry *cell_editable, gpointer user_data) { TableData *data = (TableData *) user_data; int code; status_bar_update (READY, data); code = eval_state (data); if (code==DOMAIN_ERROR) reset_table (data); status_bar_update (code, data); }
int main(int argc, char* argv[]) { Table t; /* Initialize the table */ init_table(&t); /* Insert into the table */ test_assert(key_count(&t) == 0, "insert", 0); test_assert(!insert(&t, "202", "DC"), "insert", 1); test_assert(key_count(&t) == 1, "insert", 2); /* Reset the table */ reset_table(&t); test_assert(key_count(&t) == 0, "reset", 3); return 0; }
void update_table_liststore( int column, int reset, TableData *data , SteamState *S) { if (reset) reset_table (data); gtk_tree_model_get_iter_first( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_p(*S) * 1e-5, -1); gtk_tree_model_iter_next( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_T(*S) - 273.15, -1); gtk_tree_model_iter_next( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_h(*S) * 1e-3, -1); gtk_tree_model_iter_next( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_s(*S) * 1e-3, -1); gtk_tree_model_iter_next( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_u(*S) * 1e-3, -1); gtk_tree_model_iter_next( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_v(*S), -1); gtk_tree_model_iter_next( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_rho(*S), -1); gtk_tree_model_iter_next( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_cp(*S) * 1e-3, -1); gtk_tree_model_iter_next( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_cv(*S) * 1e-3, -1); gtk_tree_model_iter_next( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_x(*S), -1); gtk_tree_model_iter_next( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_k(*S), -1); gtk_tree_model_iter_next( GTK_TREE_MODEL(data->list), data->iter ); gtk_list_store_set( data->list, data->iter, column, freesteam_mu(*S), -1); }
/************************************************************** * main takes in a number of arguments, for this project only * * 1 or 2 arguments is considered valid. If there is only one * * argument, we will treat stdin as the input source. If there * * are two arguments, we will treat the second argument as a * * data file that commands may be read from. * **************************************************************/ int main(int argc, char *argv[]){ FILE *input; char line[MAX_LEN + 1], first_word[MAX_LEN + 1], second_word[MAX_LEN + 1] , val[MAX_LEN + 1]; Table t; int index; init_table(&t); /* If only one argument is present, command line input will be used.*/ if(argc == 1){ input = stdin; /* IF two arguments are present, the second argument is taken to be a data file.*/ } else if(argc == 2){ input = fopen(argv[1], "r"); /*If the file cannot be opened, an error message will be printed, and the program will exit. */ if(input == NULL){ fprintf(stderr, "File %s open failed. Error: %s.\n", argv[1], strerror(errno)); exit(EX_OSERR); } /*If there are more than two arguments present, an error message will be printed, and the program will exit.*/ } else{ fprintf(stderr, "Too many input arguments. Error : %s.\n", strerror(errno)); exit(EX_USAGE); } /* As fgets reads in each line of the input, sscanf reads the first word of each line and assigns it to first_word.*/ while (fgets(line, MAX_LEN + LEN_EXTRA, input) != NULL) { /*If a line is too long, an error message is printed out, and the program exits.*/ if(strlen(line) > MAX_LEN){ fprintf(stderr, "Line is greater than 1024 characters. Error: %s.\n", strerror(errno)); exit(EX_DATAERR); } sscanf(line, "%s", first_word); /*If we have a blank line, we skip it.*/ if(strcmp(line, "\n") == 0){ continue; } /*If the first non-whitespace character is a '#', this line is a comment, and we skip it.*/ else if(first_word[0] == '#'){ continue; /*If the first word in a line is "insert" and all arguments are present, we attempt to insert a key/value pair*/ }else if(strcmp(first_word, "insert") == 0 && sscanf(line, "%s %s %s", first_word, second_word, val) == INSERT_ARGS){ /*If the insertion is successful, we print the success message*/ if(insert(&t, second_word, val) == 0){ printf("Insertion of %s => %s succeeded.\n", second_word, val); /*Otherwise, we print the failure message.*/ } else{ printf("Insertion of %s => %s failed.\n", second_word, val); } /*If the first word of a line is "search" and both arguments are present, we attempt to search for a key in the table.*/ } else if(strcmp(first_word, "search") == 0 && sscanf(line, "%s %s", first_word, second_word) == SEARCH_ARGS){ /*If the search succeeds, we print the success message*/ if(search(&t, second_word, val) == 0){ printf("Search for %s succeeded (%s).\n", second_word, val); /*If the search fails, we print the failure message.*/ } else{ printf("Search for %s failed.\n", second_word); } /*If the first word in the line is "delete" and both arguments are present, we attempt to delete a key from the table. */ } else if(strcmp(first_word, "delete") == 0 && sscanf(line, "%s %s", first_word, second_word) == DELETE_ARGS){ /*If the deletion succeeds, we print out the success message.*/ if(delete(&t, second_word) == 0){ printf("Deletion of %s succeeded.\n", second_word); /*If the deletion fails, we print out the ffailure message.*/ } else{ printf("Deletion of %s failed.\n", second_word); } /*If the first word in a line is "reset", we attempt to reset the table.*/ }else if(strcmp(first_word, "reset") == 0){ /*Reset the table, then print success message.*/ reset_table(&t); printf("Table reset.\n"); /*If the first word in a line is "display" and both arguments are present, we display either the contents of the table or the key count.*/ } else if(strcmp(first_word, "display") == 0 && sscanf(line, "%s %s", first_word, second_word) == DISPLAY_ARGS){ /*If the item to display is key count we attempt to display the key_count.*/ if(strcmp(second_word, "key_count") == 0){ /*If key_count succeeds, the key count will be printed, otherwise 0 will be printed. */ if(key_count(&t) != -1){ printf("Key count: %d\n", key_count(&t)); } else{ printf("Key count: 0\n"); } /*If the item to be displayed is the table, we will attempt to print out the contents of the table. */ } else if(strcmp(second_word, "table") == 0){ /*We iterate through the table and print out the bucket number, state, and (if the bucket is full) its key and value.*/ for(index = 0; index < NUM_BUCKETS; index++){ if(t.buckets[index].state == EMPTY){ printf("Bucket %d: EMPTY\n", index); } else if(t.buckets[index].state == DELETED){ printf("Bucket %d: DELETED\n", index); } else{ printf("Bucket %d: FULL (%s => %s)\n", index, t.buckets[index].data.key, t.buckets[index].data.value); } } } /*If an invalid line is found we print out an error message and exit.*/ } else{ fprintf(stderr, "Invalid line found, retry with valid command, comment, or empty line. Error: %s.\n", strerror(errno)); exit(EX_DATAERR); } } /*When we are done, we close the file and return 0.*/ fclose(input); return 0; }
extern void DEBUG_LoadSymbols( char *name ) { bfd* abfd; char **matching; bfd_init(); abfd = bfd_openr(name, "default"); if (abfd == NULL) { barf("can't open executable %s to get symbol table", name); } if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { barf("mismatch"); } { long storage_needed; asymbol **symbol_table; long number_of_symbols; long num_real_syms = 0; long i; storage_needed = bfd_get_symtab_upper_bound (abfd); if (storage_needed < 0) { barf("can't read symbol table"); } #if 0 if (storage_needed == 0) { debugBelch("no storage needed"); } #endif symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); if (number_of_symbols < 0) { barf("can't canonicalise symbol table"); } for( i = 0; i != number_of_symbols; ++i ) { symbol_info info; bfd_get_symbol_info(abfd,symbol_table[i],&info); /*debugBelch("\t%c\t0x%x \t%s\n",info.type,(nat)info.value,info.name); */ if (isReal(info.type, info.name)) { num_real_syms += 1; } } IF_DEBUG(interpreter, debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", number_of_symbols, num_real_syms) ); reset_table( num_real_syms ); for( i = 0; i != number_of_symbols; ++i ) { symbol_info info; bfd_get_symbol_info(abfd,symbol_table[i],&info); if (isReal(info.type, info.name)) { insert( info.value, info.name ); } } stgFree(symbol_table); } prepare_table(); }
static int run_all_tbl_perf_tests(unsigned with_pushes) { unsigned i, j, with_data, with_hash; printf("Measuring performance, please wait"); fflush(stdout); for (with_data = 0; with_data <= 1; with_data++) { for (i = 0; i < NUM_KEYSIZES; i++) { if (create_table(with_data, i) < 0) return -1; if (get_input_keys(with_pushes, i) < 0) return -1; for (with_hash = 0; with_hash <= 1; with_hash++) { if (timed_adds(with_hash, with_data, i) < 0) return -1; for (j = 0; j < NUM_SHUFFLES; j++) shuffle_input_keys(i); if (timed_lookups(with_hash, with_data, i) < 0) return -1; if (timed_lookups_multi(with_data, i) < 0) return -1; if (timed_deletes(with_hash, with_data, i) < 0) return -1; /* Print a dot to show progress on operations */ printf("."); fflush(stdout); reset_table(i); } free_table(i); } } printf("\nResults (in CPU cycles/operation)\n"); printf("-----------------------------------\n"); for (with_data = 0; with_data <= 1; with_data++) { if (with_data) printf("\n Operations with 8-byte data\n"); else printf("\n Operations without data\n"); for (with_hash = 0; with_hash <= 1; with_hash++) { if (with_hash) printf("\nWith pre-computed hash values\n"); else printf("\nWithout pre-computed hash values\n"); printf("\n%-18s%-18s%-18s%-18s%-18s\n", "Keysize", "Add", "Lookup", "Lookup_bulk", "Delete"); for (i = 0; i < NUM_KEYSIZES; i++) { printf("%-18d", hashtest_key_lens[i]); for (j = 0; j < NUM_OPERATIONS; j++) printf("%-18"PRIu64, cycles[i][j][with_hash][with_data]); printf("\n"); } } } return 0; }
/*----------------------------------------------------------------------- | createPS(int arrayDim) | create the acode for the Pulse Sequence. +-----------------------------------------------------------------------*/ void createPS(int arrayDim) { int i; if (ra_flag) { ra_inovaacqparms(ix); } set_counters(); /* code for HSrotor? */ new_lcinit_arrayvars(); if ( ix == getStartFidNum() ) { /* * We may have a monitor system (ILI, ISI, ...) and * we might have an MTS Grad Power Amp attached * * SAFETY CHECK & setupcode */ } /* Do initialization for RF , DDR & Gradient that happens for each FID setRF(); */ postInitScanCodes(); /* if (ix == getStartFidNum()) { ifzero(initflagrt); reset_pgdflag(); initHSlines(); endif(initflagrt); } */ arrayedshims(); /* if shims arrayed, set them again, load will be */ /* set to 'y' in arrayfuncs */ if (vttemp != oldvttemp) /* change vt setting only if it changed */ { /* why?, (because it takes time) */ setvt(); /* And it includes fifoStop/Sync */ wait4vt(); /* And this includes fifoStop/Sync */ } oldvttemp = vttemp; /* if arrayed, vttemp will get new value */ if (spin != oldspin) /* chag spin setting only if it changed */ { /* why?, (because it takes time) */ setspin(); /* And it includes fifoStop/Sync */ wait4spin(); /* And this includes fifoStop/Sync */ } oldspin = spin; /* capture elapsed time prior to pad and nt looping */ preNextScanDuration(); ifzero((oph-8)); preacqdelay(padactive); endif((oph-8)); /* ###################################################################### */ nextscan(); /* nt looping reset to this point. */ /* ###################################################################### */ loadtablecall = -1; /* initializes loadtablecall variable */ inittablevar(); /* initialize all internal table variables */ initparms_img(); /* does getval on many variables */ enableHDWshim(); /* config done internally */ setAmpBlanking(); /* if unblank mode, restore unblank */ if ( doSampling() ) { zerofid=0; pulsesequence(); /* generate Acodes from USER Pulse Sequence */ initializeSeq = 0; } else { zerofid=1; sendzerofid(arrayDim); } /* reset tables between array elements */ for (i = 0; i < MAXTABLE; i++) { tmptable_order[i] = table_order[i]; if (Table[i]->reset) reset_table(Table[i]); } return; }
void Reset_Hash_Table() { reset_table(); }