/* initialise the mangling code */ NTSTATUS pvfs_mangle_init(struct pvfs_state *pvfs) { struct pvfs_mangle_context *ctx; ctx = talloc(pvfs, struct pvfs_mangle_context); if (ctx == NULL) { return NT_STATUS_NO_MEMORY; } /* by default have a max of 512 entries in the cache. */ ctx->cache_size = lpcfg_parm_int(pvfs->ntvfs->ctx->lp_ctx, NULL, "mangle", "cachesize", 512); ctx->prefix_cache = talloc_array(ctx, char *, ctx->cache_size); if (ctx->prefix_cache == NULL) { return NT_STATUS_NO_MEMORY; } ctx->prefix_cache_hashes = talloc_array(ctx, uint32_t, ctx->cache_size); if (ctx->prefix_cache_hashes == NULL) { return NT_STATUS_NO_MEMORY; } memset(ctx->prefix_cache, 0, sizeof(char *) * ctx->cache_size); memset(ctx->prefix_cache_hashes, 0, sizeof(uint32_t) * ctx->cache_size); ctx->mangle_prefix = lpcfg_parm_int(pvfs->ntvfs->ctx->lp_ctx, NULL, "mangle", "prefix", -1); if (ctx->mangle_prefix < 0 || ctx->mangle_prefix > 6) { ctx->mangle_prefix = DEFAULT_MANGLE_PREFIX; } init_tables(ctx); pvfs->mangle_ctx = ctx; return NT_STATUS_OK; }
/* \brief Handles archetecture-specific initialization for i586. * * This function initializes various tables, paging, and the initial heap, * various timers, then passes the locations of modules and elf info (if any) * to \ref kmain. * * @param mboot The multiboot header passed by a compliant bootloader. * @param blarg At the moment, the initial stack placement. This parameter * is unused and will be removed soon. * @param magic The multiboot header checksum. */ void arch_init( multiboot_header_t *mboot, int blarg, int magic ){ void *modules = 0; void *elfinfo = 0; init_serial( ); // Take care of multiboot stuff... if ( magic != 0x2badb002 ) panic( "Need multiboot-compliant bootloader to boot Helix kernel.\n" ); if ( mboot->flags & MULTIBOOT_FLAG_ELF ) elfinfo = &mboot->elf_headers; if ( mboot->flags & MULTIBOOT_FLAG_MODS && mboot->mods_count ){ modules = *(int **)mboot->mods_addr; early_placement = *(int *)(mboot->mods_addr + 4); } // Set up memory utils init_tables( ); init_paging( mboot->mem_lower + mboot->mem_upper ); kheap = kmalloc_early( sizeof( mheap_t ), 0 ); init_heap( kheap, kernel_dir, 0xd0000000, PAGE_SIZE * 32 ); init_timer( ); kmain( 0, modules, elfinfo ); while( 1 ) asm volatile( "hlt" ); }
std::vector<property_element_c> & property_element_c::get_table_for(const EbmlCallbacks &master_callbacks, const EbmlCallbacks *sub_master_callbacks, bool full_table) { if (s_properties.empty()) init_tables(); std::map<uint32_t, std::vector<property_element_c> >::iterator src_map_it = s_properties.find(master_callbacks.GlobalId.Value); if (s_properties.end() == src_map_it) mxerror(boost::format("property_element_c::get_table_for(): programming error: no table found for EBML ID %|1$08x|\n") % master_callbacks.GlobalId.Value); if (full_table) return src_map_it->second; uint32_t element_id = !sub_master_callbacks ? master_callbacks.GlobalId.Value : sub_master_callbacks->GlobalId.Value; std::map<uint32_t, std::vector<property_element_c> >::iterator composed_map_it = s_composed_properties.find(element_id); if (s_composed_properties.end() != composed_map_it) return composed_map_it->second; s_composed_properties[element_id] = std::vector<property_element_c>(); std::vector<property_element_c> &table = s_composed_properties[element_id]; for (auto &property : src_map_it->second) if (!property.m_sub_master_callbacks || (sub_master_callbacks && (sub_master_callbacks->GlobalId == property.m_sub_master_callbacks->GlobalId))) table.push_back(property); return table; }
/* * Build the full tables */ static void build_tables() { state_t i; init_tables(); for (i=0; i<NSTATES; i++) { find_base(i); } }
/* * valid_arch -- see if the arch was mentioned in the set file. */ int valid_arch(const char *arch_name) { if (Vers == NULL) { init_tables(); } return (in_stringtable(Varch, arch_name)); }
/* * valid_version -- see if a version string was mentioned in the set file. */ int valid_version(const char *vers_name) { if (Vers == NULL) { init_tables(); } return (in_stringtable(Vers, vers_name)); }
/* * add_valid_version and _arch -- add a name to the table. */ static void add_valid_version(char *vers_name) { errlog(BEGIN, "add_valid_version(\"%s\") {", vers_name); if (Vers == NULL) { init_tables(); } Vers = add_to_stringtable(Vers, vers_name); errlog(END, "}"); }
int main ( int argc, char ** argv ) { int fpsave; bitmap_t * vert_mask; bitmap_t * edge_mask; struct cinfo cinfo; fpsave = set_floating_point_double_precision (); setbuf (stdout, NULL); decode_params (argc, argv); init_tables (); read_phase_1_data (&cinfo); if (description NE NULL) { free ((char *) cinfo.description); cinfo.description = gst_strdup (description); } if ((cinfo.metric NE RECTILINEAR) AND (cinfo.metric NE EUCLIDEAN)) { fprintf (stderr, "This only be done for geometric (Euclidean or rectilinear) FSTs\n"); exit (1); } vert_mask = cinfo.initial_vert_mask; edge_mask = cinfo.initial_edge_mask; if ((cinfo.metric EQ RECTILINEAR) AND (NOT Print_Unscaled)) { /* Force printing of integer data. */ cinfo.scale.min_precision = 0; if (cinfo.scale.scale > 0) { cinfo.scale.scale = 0; } } if ((cinfo.metric EQ EUCLIDEAN) OR (!Print_Grid_Graph)) { compute_edge_graph (vert_mask, edge_mask, &cinfo); } else { compute_grid_graph (vert_mask, edge_mask, &cinfo); } free_phase_1_data (&cinfo); restore_floating_point_precision (fpsave); exit (0); }
static void add_valid_arch(char *arch_name) { errlog(BEGIN, "add_valid_arch(\"%s\") {", arch_name); if (Vers == NULL) { init_tables(); } Varch = add_to_stringtable(Varch, arch_name); errlog(END, "}"); }
static void initialize_ucpp(struct lexer_state *ls, FILE *in) { int i; /* * This code is an adaption of ucpp's sample.c */ /* step 1 */ init_cpp(); /* step 2 */ no_special_macros = 0; emit_defines = emit_assertions = 0; /* step 3 -- with assertions */ init_tables(1); /* step 4 -- no default include path */ init_include_path(0); /* step 5 -- no need to reset the two emit_* variables set in 2 */ emit_dependencies = 0; /* step 6 -- we work with stdin, this is not a real filename */ set_init_filename("[stdin]", 0); /* step 7 -- we make sure that assertions are on, and pragma are handled */ init_lexer_state(ls); init_lexer_mode(ls); ls->flags |= HANDLE_ASSERTIONS | HANDLE_PRAGMA | LINE_NUM; /* step 8 -- input is from specified FILE stream */ ls->input = in; /* step 9 -- we do not have any macro to define, but we add any argument as an include path */ /* for (i = 1; i < argc; i ++) add_incpath(argv[i]);*/ add_incpath("/usr/local/nwcc/include"); /* XXXXXXXXXXXXXXXX */ add_incpath("/usr/include"); /* XXXXXXXXXXXXXXXX */ for (i = 0; cpp_args[i] != NULL; ++i ){ if (strncmp(cpp_args[i], "-I", 2) == 0) { add_incpath(cpp_args[i]+2); } else if (strncmp(cpp_args[i], "-D", 2) == 0) { define_macro(ls, cpp_args[i]+2); } else if (strncmp(cpp_args[i], "-U", 2) == 0) { undef_macro(ls, cpp_args[i]+2); } } /* step 10 -- we are a lexer and we want CONTEXT tokens */ enter_file(ls, ls->flags); }
int * init_server(struct Config *c) { config = c; signal(SIGINT, sig_handler); signal(SIGTERM, sig_handler); signal(SIGHUP, sig_handler); signal(SIGUSR1, sig_handler); /* ignore SIGPIPE, or it will kill us */ signal(SIGPIPE, SIG_IGN); init_tables(&config->tables); return init_listeners(&config->listeners, &config->tables); }
void msm5232_device::init(int clock, int rate) { int j; m_chip_clock = clock; m_rate = rate ? rate : 44100; /* avoid division by 0 */ init_tables(); for (j=0; j<8; j++) { memset(&m_voi[j],0,sizeof(VOICE)); init_voice(j); } }
/* Initialize GLib hash tables */ void init_storage (void) { GModule module; ht_agent_keys = new_str_ht (g_free, g_free); ht_agent_vals = new_str_ht (g_free, g_free); ht_hostnames = new_str_ht (g_free, g_free); ht_unique_keys = new_str_ht (g_free, g_free); ht_storage = new_gstorage (TOTAL_MODULES); for (module = 0; module < TOTAL_MODULES; ++module) { init_tables (module); } }
/* * MSB * * Return the position of the most significant 1 bit in the number. * * Parameters: number - a number * * Returns: the position of the most significant 1 bit */ static unsigned int MSB(unsigned int number) { if (!init_flag) init_tables(); if (number & (0xff << 24)) return 24 + msb_table[number >> 24]; if (number & (0xff << 16)) return 16 + msb_table[number >> 16]; if (number & (0xff << 8)) return 8 + msb_table[number >> 8]; if (number & 0xff) return msb_table[number]; return 32; }
/* Initialize Tokyo Cabinet storage tables */ void init_storage (void) { GModule module; ht_agent_keys = tc_adb_create (get_dbname (DB_AGENT_KEYS, -1)); ht_agent_vals = tc_adb_create (get_dbname (DB_AGENT_VALS, -1)); ht_general_stats = tc_adb_create (get_dbname (DB_GEN_STATS, -1)); ht_hostnames = tc_adb_create (get_dbname (DB_HOSTNAMES, -1)); ht_unique_keys = tc_adb_create (get_dbname (DB_UNIQUE_KEYS, -1)); ht_storage = new_gstorage (TOTAL_MODULES); for (module = 0; module < TOTAL_MODULES; ++module) { init_tables (module); } }
pdp_t *create_domain_control(mrp_context_t *ctx, const char *extaddr, const char *intaddr, const char *wrtaddr, const char *httpdir) { pdp_t *pdp; pdp = mrp_allocz(sizeof(*pdp)); if (pdp != NULL) { pdp->ctx = ctx; pdp->address = extaddr; if (init_proxies(pdp) && init_tables(pdp)) { if (extaddr && *extaddr) pdp->extt = create_transport(pdp, extaddr); if (intaddr && *intaddr) pdp->intt = create_transport(pdp, intaddr); if (wrtaddr && *wrtaddr) { pdp->wrtt = create_transport(pdp, wrtaddr); if (pdp->wrtt != NULL) { const char *sm_opt = MRP_WSCK_OPT_SENDMODE; const char *sm_val = MRP_WSCK_SENDMODE_TEXT; const char *hd_opt = MRP_WSCK_OPT_HTTPDIR; const char *hd_val = httpdir; mrp_transport_setopt(pdp->wrtt, sm_opt, sm_val); mrp_transport_setopt(pdp->wrtt, hd_opt, hd_val); } } if ((!extaddr || !*extaddr || pdp->extt != NULL) && (!intaddr || !*intaddr || pdp->intt != NULL) && (!wrtaddr || !*wrtaddr || pdp->wrtt != NULL)) return pdp; } destroy_domain_control(pdp); } return NULL; }
/* return the methods for this mangling implementation */ const struct mangle_fns *mangle_hash2_init(void) { /* the mangle prefix can only be in the mange 1 to 6 */ mangle_prefix = lp_mangle_prefix(); if (mangle_prefix > 6) { mangle_prefix = 6; } if (mangle_prefix < 1) { mangle_prefix = 1; } #if DYNAMIC_MANGLE_TABLES init_tables(); #endif mangle_reset(); return &mangle_hash2_fns; }
YM2151::YM2151(uint32_t clk, uint32_t rate) { int chn; init_tables(); clock = clk; sampfreq = rate ? rate : 44100; init_chip_tables(); lfo_timer_add = (1<<LFO_SH) * (clock/64.0) / sampfreq; eg_timer_add = (1<<EG_SH) * (clock/64.0) / sampfreq; eg_timer_overflow = ( 3 ) * (1<<EG_SH); tim_A = tim_B = 0; for(chn = 0; chn < 8; chn ++) Muted[chn] = 0x00; }
/* ----------------------------- MNI Header ----------------------------------- @NAME : OpenMPEG @INPUT : MPEGfile - pointer to a stream opened for reading, positioned at the beginning of an MPEG stream ImgInfo - pointer to an ImageDesc structure which will have information such as frame height, width, depth and size (total bytes per frame) put in it. @OUTPUT : @RETURNS : @DESCRIPTION: Creates and initializes the variables needed to start reading/decoding an MPEG stream. This function is part of the MNI front end to the Berkeley MPEG decoder, adapted from the original Berkeley code. @METHOD : @GLOBALS : theStream ditherType input LUM_RANGE, CR_RANGE, CB_RANGE lum_values, cr_values, cb_values @CALLS : GetMPEGInfo() init_tables() InitDither() @CREATED : 94/6/16, Greg Ward (adapted from main() in the original Berkeley source) @MODIFIED : ---------------------------------------------------------------------------- */ Boolean OpenMPEG (FILE *MPEGfile, ImageDesc *ImgInfo) { /* * First reinitialize these globals in case we're opening a second * (or more) file - thanks to Loring Holding <*****@*****.**> * for the patch. */ curBits = bitOffset = bufLength = 0; EOF_flag = FALSE; /* * Create the video stream and read the first chunk to get movie * stats -- width and height in particular. */ theStream = NewVidStream(BUF_LENGTH); if (theStream == NULL) { fprintf (stderr, "Error creating video stream\n"); return (FALSE); } input = MPEGfile; if (mpegVidRsrc(0, theStream) == NULL) { fprintf (stderr, "Error reading video stream, or stream empty\n"); return (FALSE); } GetMPEGInfo (theStream, ImgInfo); /* Allocate/initialize tables used for dithering (?) */ lum_values = (int *) malloc(LUM_RANGE*sizeof(int)); cr_values = (int *) malloc(CR_RANGE*sizeof(int)); cb_values = (int *) malloc(CB_RANGE*sizeof(int)); init_tables(); /* initialize decoding stuff */ InitDither (ImgInfo); /* initializes dithering structures and */ /* colormap (i.e. this is where we do */ /* all dither-specific stuff) */ return (TRUE); } /* OpenMPEG () */
/* * h * * Return the position of the least significant 1 bit in the number. * * Parameters: number - a number * * Returns: the position of the least significant 1 bit */ static unsigned int h(unsigned int number) { if (!init_flag) init_tables(); if (number & 0xff) return lsb_table[number & 0xff]; number >>= 8; if (number & 0xff) return 8 + lsb_table[number & 0xff]; number >>= 8; if (number & 0xff) return 16 + lsb_table[number & 0xff]; number >>= 8; if (number & 0xff) return 24 + lsb_table[number & 0xff]; return 32; }
/* return the methods for this mangling implementation */ struct mangle_fns *mangle_hash2_init(void) { /* the mangle prefix can only be in the mange 1 to 6 */ mangle_prefix = lp_mangle_prefix(); if (mangle_prefix > 6) { mangle_prefix = 6; } if (mangle_prefix < 1) { mangle_prefix = 1; } init_tables(); mangle_reset(); if (!cache_init()) { return NULL; } return &mangle_fns; }
/* Initialize hash tables */ void init_storage (void) { GModule module; size_t idx = 0; /* Hashes used across the whole app (not per module) */ ht_agent_keys = tc_adb_create (get_dbname (DB_AGENT_KEYS, -1)); ht_agent_vals = tc_adb_create (get_dbname (DB_AGENT_VALS, -1)); ht_general_stats = tc_adb_create (get_dbname (DB_GEN_STATS, -1)); ht_hostnames = tc_adb_create (get_dbname (DB_HOSTNAMES, -1)); ht_unique_keys = tc_adb_create (get_dbname (DB_UNIQUE_KEYS, -1)); tc_storage = new_tcstorage (TOTAL_MODULES); FOREACH_MODULE (idx, module_list) { module = module_list[idx]; tc_storage[module].module = module; init_tables (module); }
long er_iodb_vmsinit(long dev) { #if 0 struct _ucb * ucb=&er$ucb; struct _ddb * ddb=&er$ddb; struct _crb * crb=&er$crb; #endif struct _ucb * ucb=kmalloc(sizeof(struct _ucbnidef),GFP_KERNEL); struct _ddb * ddb=kmalloc(sizeof(struct _ddb),GFP_KERNEL); struct _crb * crb=kmalloc(sizeof(struct _crb),GFP_KERNEL); unsigned long idb=0,orb=0; memset(ucb,0,sizeof(struct _ucbnidef)); memset(ddb,0,sizeof(struct _ddb)); memset(crb,0,sizeof(struct _crb)); #if 0 init_ddb(&er$ddb,&er$ddt,&er$ucb,"dqa"); init_ucb(&er$ucb, &er$ddb, &er$ddt, &er$crb); init_crb(&er$crb); #endif ucb -> ucb$w_size = sizeof(struct _ucbnidef); // temp placed ((struct _ucbnidef *)ucb)->ucb$l_extra_l_1=dev; init_ddb(ddb,&er$ddt,ucb,"era"); init_ucb(ucb, ddb, &er$ddt, crb); init_crb(crb); // ioc_std$clone_ucb(&er$ucb,&ucb); er$init_tables(); er$struc_init (crb, ddb, idb, orb, ucb); er$struc_reinit (crb, ddb, idb, orb, ucb); er$unit_init (idb, ucb); insertdevlist(ddb); return ddb; }
enum plugin_status plugin_start(const void* parameter) { int w, h; char *off = "[Off] to stop"; (void)(parameter); rb->lcd_setfont(FONT_SYSFIXED); rb->lcd_clear_display(); /* Get horizontel centering for text */ rb->lcd_getstringsize((unsigned char *)SS_TITLE, &w, &h); rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, (LCD_HEIGHT/2) - h / 2, (unsigned char *)SS_TITLE); /* Get horizontel centering for text */ rb->lcd_getstringsize((unsigned char *)off, &w, &h); rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, LCD_HEIGHT - 2 * h, (unsigned char *)off); rb->lcd_update(); rb->sleep(HZ); rb->lcd_set_drawmode(DRMODE_FG); init_tables(); #if CONFIG_RTC init_clock(); #endif do { h = loopit(); if (h > 0) h = scrollit(); } while(h > 0); rb->lcd_set_drawmode(DRMODE_SOLID); rb->lcd_setfont(FONT_UI); return (h == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED; }
/************************************************************************ * Function: http_get_code_text * * Parameters: * int statusCode ; Status code based on which the status table and * status message is returned * * Description: Return the right status message based on the passed in * int statusCode input parameter * * Returns: * const char* ptr - pointer to the status message string ************************************************************************/ const char * http_get_code_text( int statusCode ) { int index; int table_num; if( !gInitialized ) { init_tables( ); } if( statusCode < 100 && statusCode >= 600 ) { return NULL; } index = statusCode % 100; table_num = statusCode / 100; if( table_num == 1 && index < NUM_1XX_CODES ) { return Http1xxCodes[index]; } if( table_num == 2 && index < NUM_2XX_CODES ) { return Http2xxCodes[index]; } if( table_num == 3 && index < NUM_3XX_CODES ) { return Http3xxCodes[index]; } if( table_num == 4 && index < NUM_4XX_CODES ) { return Http4xxCodes[index]; } if( table_num == 5 && index < NUM_5XX_CODES ) { return Http5xxCodes[index]; } return NULL; }
long ft_iodb_vmsinit(void) { #if 0 struct _ucb * ucb=&ft$ucb; struct _ddb * ddb=&ft$ddb; struct _crb * crb=&ft$crb; #endif struct _ucb * ucb=kmalloc(sizeof(struct _ft_ucb),GFP_KERNEL); struct _ddb * ddb=kmalloc(sizeof(struct _ddb),GFP_KERNEL); struct _crb * crb=kmalloc(sizeof(struct _crb),GFP_KERNEL); unsigned long idb=0,orb=0; memset(ucb,0,sizeof(struct _ft_ucb)); memset(ddb,0,sizeof(struct _ddb)); memset(crb,0,sizeof(struct _crb)); #if 0 init_ddb(&ft$ddb,&ft$ddt,&ft$ucb,"dqa"); init_ucb(&ft$ucb, &ft$ddb, &ft$ddt, &ft$crb); init_crb(&ft$crb); #endif ucb -> ucb$w_size = sizeof(struct _ft_ucb); // temp placed init_ddb(ddb,&ft$ddt,ucb,"fta"); init_ucb(ucb, ddb, &ft$ddt, crb); init_crb(crb); // ioc_std$clone_ucb(&ft$ucb,&ucb); ft$init_tables(); ft$struc_init (crb, ddb, idb, orb, ucb); ft$struc_reinit (crb, ddb, idb, orb, ucb); ft$unit_init (idb, ucb); insertdevlist(ddb); return ddb; }
int main( int argc, char *argv[]) { srand( time(NULL) ); /* random seed to choose one score between equal score vectores */ if(argc != 4){ printf("Usage: %s <seq1_file> <seq2_file> <mid_bounds_number>\n", argv[0]); return 0; } read_sequence(seq1, argv[1]); read_sequence(seq2, argv[2]); M = strlen(seq1); N = strlen(seq2); init_bounds( atoi(argv[3]) ); init_tables(); align(); traceback(); remove_tables(); remove_bounds_tables(); return 0; }
long kbd_iodb_vmsinit(void) { #if 0 struct _ucb * ucb=&kb$ucb; struct _ddb * ddb=&kb$ddb; struct _crb * crb=&kb$crb; #endif struct _ucb * ucb=kmalloc(sizeof(struct _ucb),GFP_KERNEL); struct _ddb * ddb=kmalloc(sizeof(struct _ddb),GFP_KERNEL); struct _crb * crb=kmalloc(sizeof(struct _crb),GFP_KERNEL); unsigned long idb=0,orb=0; bzero(ucb,sizeof(struct _ucb)); bzero(ddb,sizeof(struct _ddb)); bzero(crb,sizeof(struct _crb)); #if 0 init_ddb(&kb$ddb,&kb$ddt,&kb$ucb,"dqa"); init_ucb(&kb$ucb, &kb$ddb, &kb$ddt, &kb$crb); init_crb(&kb$crb); #endif init_ddb(ddb,&kb$ddt,ucb,"opa"); init_ucb(ucb, ddb, &kb$ddt, crb); init_crb(crb); // ioc_std$clone_ucb(&kb$ucb,&ucb); kb$init_tables(); kb$struc_init (crb, ddb, idb, orb, ucb); kb$struc_reinit (crb, ddb, idb, orb, ucb); kb$unit_init (idb, ucb); insertdevlist(ddb); return ddb; }
CGEN_CPU_DESC xstormy16_cgen_cpu_open (enum cgen_cpu_open_arg arg_type, ...) { CGEN_CPU_TABLE *cd = (CGEN_CPU_TABLE *) xmalloc (sizeof (CGEN_CPU_TABLE)); static int init_p; CGEN_BITSET *isas = 0; /* 0 = "unspecified" */ unsigned int machs = 0; /* 0 = "unspecified" */ enum cgen_endian endian = CGEN_ENDIAN_UNKNOWN; va_list ap; if (! init_p) { init_tables (); init_p = 1; } memset (cd, 0, sizeof (*cd)); va_start (ap, arg_type); while (arg_type != CGEN_CPU_OPEN_END) { switch (arg_type) { case CGEN_CPU_OPEN_ISAS : isas = va_arg (ap, CGEN_BITSET *); break; case CGEN_CPU_OPEN_MACHS : machs = va_arg (ap, unsigned int); break; case CGEN_CPU_OPEN_BFDMACH : { const char *name = va_arg (ap, const char *); const CGEN_MACH *mach = lookup_mach_via_bfd_name (xstormy16_cgen_mach_table, name); machs |= 1 << mach->num; break; } case CGEN_CPU_OPEN_ENDIAN : endian = va_arg (ap, enum cgen_endian); break; default : fprintf (stderr, "xstormy16_cgen_cpu_open: unsupported argument `%d'\n", arg_type); abort (); /* ??? return NULL? */ } arg_type = va_arg (ap, enum cgen_cpu_open_arg); } va_end (ap); /* Mach unspecified means "all". */ if (machs == 0) machs = (1 << MAX_MACHS) - 1; /* Base mach is always selected. */ machs |= 1; if (endian == CGEN_ENDIAN_UNKNOWN) { /* ??? If target has only one, could have a default. */ fprintf (stderr, "xstormy16_cgen_cpu_open: no endianness specified\n"); abort (); } cd->isas = cgen_bitset_copy (isas); cd->machs = machs; cd->endian = endian; /* FIXME: for the sparc case we can determine insn-endianness statically. The worry here is where both data and insn endian can be independently chosen, in which case this function will need another argument. Actually, will want to allow for more arguments in the future anyway. */ cd->insn_endian = endian; /* Table (re)builder. */ cd->rebuild_tables = xstormy16_cgen_rebuild_tables; xstormy16_cgen_rebuild_tables (cd); /* Default to not allowing signed overflow. */ cd->signed_overflow_ok_p = 0; return (CGEN_CPU_DESC) cd; }
int Timidity_Init(int rate, int format, int channels, int samples) { const char *env = getenv("TIMIDITY_CFG"); if (!env || read_config_file(env)<0) { if (read_config_file(CONFIG_FILE)<0) { if (read_config_file(CONFIG_FILE_ETC)<0) { return(-1); } } } if (channels < 1 || channels == 3 || channels == 5 || channels > 6) return(-1); num_ochannels = channels; /* Set play mode parameters */ play_mode->rate = rate; play_mode->encoding = 0; if ( (format&0xFF) == 16 ) { play_mode->encoding |= PE_16BIT; } if ( (format&0x8000) ) { play_mode->encoding |= PE_SIGNED; } if ( channels == 1 ) { play_mode->encoding |= PE_MONO; } switch (format) { case AUDIO_S8: s32tobuf = s32tos8; break; case AUDIO_U8: s32tobuf = s32tou8; break; case AUDIO_S16LSB: s32tobuf = s32tos16l; break; case AUDIO_S16MSB: s32tobuf = s32tos16b; break; case AUDIO_U16LSB: s32tobuf = s32tou16l; break; case AUDIO_U16MSB: s32tobuf = s32tou16b; break; default: ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Unsupported audio format"); return(-1); } AUDIO_BUFFER_SIZE = samples; /* Allocate memory for mixing (WARNING: Memory leak!) */ resample_buffer = safe_malloc(AUDIO_BUFFER_SIZE*sizeof(resample_t)+100); common_buffer = safe_malloc(AUDIO_BUFFER_SIZE*num_ochannels*sizeof(int32)); init_tables(); if (ctl->open(0, 0)) { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Couldn't open %s\n", ctl->id_name); return(-1); } if (!control_ratio) { control_ratio = play_mode->rate / CONTROLS_PER_SECOND; if(control_ratio<1) control_ratio=1; else if (control_ratio > MAX_CONTROL_RATIO) control_ratio=MAX_CONTROL_RATIO; } if (*def_instr_name) set_default_instrument(def_instr_name); return(0); }