Exemplo n.º 1
0
int main(int ac, char** av)
{
	instr_t*	imem;
	int		imem_size;
	int		yyparse();
	int		yylex_destroy();

	progname = av[0];
	output = stdout;

	init_func();
	init_instr();
	init_stmt();
	init_sim();

	params(ac, av);

	if (yyin == NULL) {
		warning("no input file");
		exit(0);	
	}
		
	if (cfg_fp == NULL)
		yyparse();
	
	fclose(yyin);
	yylex_destroy();

	opt();

	if (cfg_fp != NULL)
		exit(0);

	imem = stmt2instr(&imem_size);

	free_func();
	deinit_symtab();
	deinit_sym();

	set_dmem_size(100000);
	set_imem(imem, imem_size);
	set_regs(32);

	run(); 

	print_stats();
		
	free_sim();

	if (output != NULL)
		fclose(output);

	if (yyin != NULL)
		fclose(yyin);

	return 0;
}
Exemplo n.º 2
0
static int init_statements(void)
{
	/* Don't initialize create_astdb_statment here as the astdb table needs to exist
	 * brefore these statments can be initialized */
	return init_stmt(&get_stmt, get_stmt_sql, sizeof(get_stmt_sql))
	|| init_stmt(&del_stmt, del_stmt_sql, sizeof(del_stmt_sql))
	|| init_stmt(&deltree_stmt, deltree_stmt_sql, sizeof(deltree_stmt_sql))
	|| init_stmt(&deltree_all_stmt, deltree_all_stmt_sql, sizeof(deltree_all_stmt_sql))
	|| init_stmt(&gettree_stmt, gettree_stmt_sql, sizeof(gettree_stmt_sql))
	|| init_stmt(&gettree_all_stmt, gettree_all_stmt_sql, sizeof(gettree_all_stmt_sql))
	|| init_stmt(&showkey_stmt, showkey_stmt_sql, sizeof(showkey_stmt_sql))
	|| init_stmt(&put_stmt, put_stmt_sql, sizeof(put_stmt_sql));
}
Exemplo n.º 3
0
static int db_create_astdb(void)
{
	int res = 0;

	if (!create_astdb_stmt) {
		init_stmt(&create_astdb_stmt, create_astdb_stmt_sql, sizeof(create_astdb_stmt_sql));
	}

	ast_mutex_lock(&dblock);
	if (sqlite3_step(create_astdb_stmt) != SQLITE_DONE) {
		ast_log(LOG_WARNING, "Couldn't create astdb table: %s\n", sqlite3_errmsg(astdb));
		res = -1;
	}
	sqlite3_reset(create_astdb_stmt);
	db_sync();
	ast_mutex_unlock(&dblock);

	return res;
}