extern Function* function_createWithTruthTable(TruthTable* table) { Function* f = function_init(); f -> table = table; f -> vars = btable_generateVars(table); f -> tree = btable_toFunctionTree(f->table, f->vars); // Init tree as a basic truth table traduction f -> btree = btree_simplify(btable_toBoolTree(f->table, f->vars)); f -> fmd = btree_toFunctionTree(f->btree); // Init fmd as the Disjunctive normal form of the function return f; }
extern Function* function_createWithFunctionTree(FunctionTree* tree) { Function* f = function_init(); f -> tree = tree; // Init tree with the given expr without simplifications f -> vars = ftree_getVars(tree); f -> table = ftree_toTruthTable(tree, f->vars); f -> btree = btree_simplify(btable_toBoolTree(f->table, f->vars)); f -> fmd = btree_toFunctionTree(f->btree); // Init fmd as the Disjunctive normal form of the function return f; }
void init () { g_type_init (); scm_c_eval_string ("(use-modules (gnome-2) (gnome gobject))"); repository_init (); types_init (); registered_type_init (); object_init (); function_init (); callable_init (); argument_init (); }
/******************************************************************************* * * 函数名 : main * 负责人 : 彭鹏 * 创建日期: 20160112 * 函数功能: MPU9250 主函数 * * 输入参数: 无 * 输出参数: 无 * 返回值 : 主程序永不返回 * * 调用关系: 无 * 其 它 : 获取MPU9250数据 中断中完成 * ******************************************************************************/ int main(void) { hardware_init(); #define _HARDWARE_DEBUG_ #ifdef _HARDWARE_DEBUG_ hardware_test(); #else function_init(); while(1) { fusion(); pid(); } #endif }
static function* function_push (uintptr_t address) { ++nfunctions; functions = realloc(functions, sizeof(*functions) * nfunctions); assert_inner_ptr(functions, "realloc"); function *f = functions + nfunctions - 1; function_init(f); f->address = address; addr_translate(f->address, &(f->name), &(f->file), &(f->line)); feedback_assert_wrn(strcmp(f->name, "??"), "unable to identify instrumented function at 0x%" PRIxPTR " - missing debug symbols?", address); return f; }
/** Main test */ int main( int argc, char **argv ) { setlocale( LC_ALL, "" ); srand( time( 0 ) ); program_name=L"(ignore)"; say( L"Testing low-level functionality"); say( L"Lines beginning with '(ignore):' are not errors, they are warning messages\ngenerated by the fish parser library when given broken input, and can be\nignored. All actual errors begin with 'Error:'." ); proc_init(); halloc_util_init(); event_init(); parser_init(); function_init(); builtin_init(); reader_init(); env_init(); test_util(); test_escape(); test_convert(); test_tok(); test_parser(); test_expand(); test_path(); say( L"Encountered %d errors in low-level tests", err_count ); /* Skip performance tests for now, since they seem to hang when running from inside make (?) */ // say( L"Testing performance" ); // perf_complete(); env_destroy(); reader_destroy(); parser_destroy(); function_destroy(); builtin_destroy(); wutil_destroy(); event_destroy(); proc_destroy(); halloc_util_destroy(); }
int main(int argc, char **argv) { stats = (__u64 *)calloc(IOCTLS_NR,sizeof(__u64)); if(stats == NULL) { fprintf(stderr,"No more memory\n"); exit(1); } if((sock = socket(PF_MAPI,SOCK_RAW,htons(ETH_P_ALL))) < 0) { perror("socket"); exit(1); } function_init(); signal(SIGINT,sigint_handler); while(1) { long int rand = random(); rand = rand >> 5; rand %= IOCTLS_NR; stats[rand]++; if(ioctl(sock,ioctl_calls[rand],&fs) == -1) { perror("ioctl"); continue; } printf("%s succeeded\n",ioctl_names[rand]); } close(sock); }
static VALUE function_initialize(int argc, VALUE* argv, VALUE self) { VALUE rbReturnType = Qnil, rbParamTypes = Qnil, rbProc = Qnil, rbOptions = Qnil; VALUE rbFunctionInfo = Qnil; VALUE infoArgv[3]; int nargs; nargs = rb_scan_args(argc, argv, "22", &rbReturnType, &rbParamTypes, &rbProc, &rbOptions); // // Callback with block, // e.g. Function.new(:int, [ :int ]) { |i| blah } // or Function.new(:int, [ :int ], { :convention => :stdcall }) { |i| blah } // if (rb_block_given_p()) { if (nargs > 3) { rb_raise(rb_eArgError, "cannot create function with both proc/address and block"); } rbOptions = rbProc; rbProc = rb_block_proc(); } else { // Callback with proc, or Function with address // e.g. Function.new(:int, [ :int ], Proc.new { |i| }) // Function.new(:int, [ :int ], Proc.new { |i| }, { :convention => :stdcall }) // Function.new(:int, [ :int ], addr) // Function.new(:int, [ :int ], addr, { :convention => :stdcall }) } infoArgv[0] = rbReturnType; infoArgv[1] = rbParamTypes; infoArgv[2] = rbOptions; rbFunctionInfo = rb_class_new_instance(rbOptions != Qnil ? 3 : 2, infoArgv, rbffi_FunctionTypeClass); function_init(self, rbFunctionInfo, rbProc); return self; }
int main( int argc, char **argv ) { struct stat tmp; int res=1; const char *cmd=0; int my_optind=0; set_main_thread(); setup_fork_guards(); wsetlocale( LC_ALL, L"" ); is_interactive_session=1; program_name=L"fish"; stat("----------FISH_HIT_MAIN----------", &tmp); my_optind = fish_parse_opt( argc, argv, &cmd ); /* No-exec is prohibited when in interactive mode */ if( is_interactive_session && no_exec) { debug( 1, _(L"Can not use the no-execute mode when running an interactive session") ); no_exec = 0; } const struct config_paths_t paths = determine_config_directory_paths(argv[0]); proc_init(); event_init(); wutil_init(); //parser_init(); builtin_init(); function_init(); env_init(&paths); reader_init(); history_init(); parser_t &parser = parser_t::principal_parser(); if (g_log_forks) printf("%d: g_fork_count: %d\n", __LINE__, g_fork_count); if( read_init(paths) ) { if( cmd != 0 ) { wchar_t *cmd_wcs = str2wcs( cmd ); res = parser.eval( cmd_wcs, 0, TOP ); free(cmd_wcs); reader_exit(0, 0); } else { if( my_optind == argc ) { res = reader_read( STDIN_FILENO, 0 ); } else { char **ptr; char *file = *(argv+(my_optind++)); int i; int fd; wchar_t *rel_filename, *abs_filename; if( ( fd = open(file, O_RDONLY) ) == -1 ) { wperror( L"open" ); return 1; } // OK to not do this atomically since we cannot have gone multithreaded yet set_cloexec(fd); if( *(argv+my_optind)) { wcstring sb; for( i=1,ptr = argv+my_optind; *ptr; i++, ptr++ ) { if( i != 1 ) sb.append( ARRAY_SEP_STR ); sb.append( str2wcstring( *ptr )); } env_set( L"argv", sb.c_str(), 0 ); } rel_filename = str2wcs( file ); abs_filename = wrealpath( rel_filename, 0 ); if( !abs_filename ) { abs_filename = wcsdup(rel_filename); } reader_push_current_filename( intern( abs_filename ) ); free( rel_filename ); free( abs_filename ); res = reader_read( fd, 0 ); if( res ) { debug( 1, _(L"Error while reading file %ls\n"), reader_current_filename()?reader_current_filename(): _(L"Standard input") ); } reader_pop_current_filename(); } } } proc_fire_event( L"PROCESS_EXIT", EVENT_EXIT, getpid(), res ); history_destroy(); proc_destroy(); builtin_destroy(); reader_destroy(); parser.destroy(); wutil_destroy(); event_destroy(); env_destroy(); if (g_log_forks) printf("%d: g_fork_count: %d\n", __LINE__, g_fork_count); return res?STATUS_UNKNOWN_COMMAND:proc_get_last_status(); }
VALUE rbffi_Function_NewInstance(VALUE rbFunctionInfo, VALUE rbProc) { return function_init(function_allocate(rbffi_FunctionClass), rbFunctionInfo, rbProc); }
int main(int argc, char **argv) { int res=1; int my_optind=0; set_main_thread(); setup_fork_guards(); wsetlocale(LC_ALL, L""); is_interactive_session=1; program_name=L"fish"; //struct stat tmp; //stat("----------FISH_HIT_MAIN----------", &tmp); std::vector<std::string> cmds; my_optind = fish_parse_opt(argc, argv, &cmds); /* No-exec is prohibited when in interactive mode */ if (is_interactive_session && no_exec) { debug(1, _(L"Can not use the no-execute mode when running an interactive session")); no_exec = 0; } /* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */ if (is_interactive_session) { save_term_foreground_process_group(); } const struct config_paths_t paths = determine_config_directory_paths(argv[0]); proc_init(); event_init(); wutil_init(); builtin_init(); function_init(); env_init(&paths); reader_init(); history_init(); /* For setcolor to support term256 in config.fish (#1022) */ update_fish_term256(); parser_t &parser = parser_t::principal_parser(); if (g_log_forks) printf("%d: g_fork_count: %d\n", __LINE__, g_fork_count); const io_chain_t empty_ios; if (read_init(paths)) { /* Stop the exit status of any initialization commands (#635) */ proc_set_last_status(STATUS_BUILTIN_OK); /* Run the commands specified as arguments, if any */ if (! cmds.empty()) { /* Do something nasty to support OpenSUSE assuming we're bash. This may modify cmds. */ if (is_login) { fish_xdm_login_hack_hack_hack_hack(&cmds, argc - my_optind, argv + my_optind); } for (size_t i=0; i < cmds.size(); i++) { const wcstring cmd_wcs = str2wcstring(cmds.at(i)); res = parser.eval(cmd_wcs, empty_ios, TOP); } reader_exit(0, 0); } else { if (my_optind == argc) { res = reader_read(STDIN_FILENO, empty_ios); } else { char **ptr; char *file = *(argv+(my_optind++)); int i; int fd; if ((fd = open(file, O_RDONLY)) == -1) { wperror(L"open"); return 1; } // OK to not do this atomically since we cannot have gone multithreaded yet set_cloexec(fd); if (*(argv+my_optind)) { wcstring sb; for (i=1,ptr = argv+my_optind; *ptr; i++, ptr++) { if (i != 1) sb.append(ARRAY_SEP_STR); sb.append(str2wcstring(*ptr)); } env_set(L"argv", sb.c_str(), 0); } const wcstring rel_filename = str2wcstring(file); const wchar_t *abs_filename = wrealpath(rel_filename, NULL); if (!abs_filename) { abs_filename = wcsdup(rel_filename.c_str()); } reader_push_current_filename(intern(abs_filename)); free((void *)abs_filename); res = reader_read(fd, empty_ios); if (res) { debug(1, _(L"Error while reading file %ls\n"), reader_current_filename()?reader_current_filename(): _(L"Standard input")); } reader_pop_current_filename(); } } } proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res); restore_term_mode(); restore_term_foreground_process_group(); history_destroy(); proc_destroy(); builtin_destroy(); reader_destroy(); parser.destroy(); wutil_destroy(); event_destroy(); env_destroy(); if (g_log_forks) printf("%d: g_fork_count: %d\n", __LINE__, g_fork_count); exit_without_destructors(res ? STATUS_UNKNOWN_COMMAND : proc_get_last_status()); return EXIT_FAILURE; //above line should always exit }
int main(int argc, char **argv) { struct type_info *type; char *bi[] = {"int", "short", "char", "void *"}; char *bi2[] = {"struct hello", "struct ok", "struct hello", "struct hello *", "struct you", "struct f**k", "struct muni", "struct fuck_you_foreya"}; int i = 0; struct func_info *fi; struct variant_info *vi; char *types[] = {"int", "struct hello", "struct pointrt", "struct he", "int * *"}; char *names[] = {"k", "j", "f**k", "you", "doc"}; char *param_list[] = {"char * hua , int hello", "void", "", "void * hello", "void * type , struct hello * * f**k , int k"}; char *name; struct HashTable *func_table; type_init(); for(i = 0; i < sizeof(bi) / sizeof(char*); i ++) { type = get_type(bi[i]); printf("full_name:%s, name:%s, level:%d, len:%d, is_struct:%d\n", bi[i], type->ti_name, type->pointer_level, type->len, type->is_struct); } for(i = 0; i < sizeof(bi2)/ sizeof(char*); i ++) { type = create_type_info(bi2[i], i + 1); } for(i = 0; i < sizeof(bi2) / sizeof(char*); i ++) { type = get_type(bi2[i]); printf("Full name:%s, name %s, level %d, len %d, is_struct %d, ref %d\n", bi2[i], type->si->name, type->pointer_level, type->len, type->is_struct, type->ref); } /*测试函数信息*/ function_init(); func_table = create_func_table(); printf("--------------function------------------------\n"); for(i = 0; i < sizeof(types) / sizeof(char*); i ++) { fi = create_func_info(types[i], names[i], param_list[i]); printf("%d\n", insert_func_table(func_table, fi)); } for(i = 0; i < sizeof(types) / sizeof(char*); i ++) { fi = get_func_from_table(func_table, names[i]); printf("Full-name:%s, param_num:%d, name:%s\n", names[i], fi->param_info->param_num, fi->fi_name); print_type_info(fi->ret_info); print_param_info(fi->param_info); } printf("---------------------------------------------\n"); for(i = 0; i < sizeof(types) / sizeof(char*); i ++) { vi = create_variant_info(types[i], names[i]); if(vi->type_info->is_struct) name = vi->type_info->si->name; else name = vi->type_info->ti_name; printf("full-name:%s, type_name:%s, real_name:%s, ref:%d\n", names[i], name, vi->vi_name, vi->type_info->ref); } return 0; }
int main(int argc, char **argv) { int res = 1; int my_optind = 0; program_name = L"fish"; set_main_thread(); setup_fork_guards(); setlocale(LC_ALL, ""); fish_setlocale(); // struct stat tmp; // stat("----------FISH_HIT_MAIN----------", &tmp); if (!argv[0]) { static const char *dummy_argv[2] = {"fish", NULL}; argv = (char **)dummy_argv; //!OCLINT(parameter reassignment) argc = 1; //!OCLINT(parameter reassignment) } std::vector<std::string> cmds; my_optind = fish_parse_opt(argc, argv, &cmds); // No-exec is prohibited when in interactive mode. if (is_interactive_session && no_exec) { debug(1, _(L"Can not use the no-execute mode when running an interactive session")); no_exec = 0; } // Only save (and therefore restore) the fg process group if we are interactive. See issues // #197 and #1002. if (is_interactive_session) { save_term_foreground_process_group(); } const struct config_paths_t paths = determine_config_directory_paths(argv[0]); proc_init(); event_init(); builtin_init(); function_init(); env_init(&paths); reader_init(); history_init(); // For set_color to support term256 in config.fish (issue #1022). update_fish_color_support(); misc_init(); parser_t &parser = parser_t::principal_parser(); const io_chain_t empty_ios; if (read_init(paths)) { // Stomp the exit status of any initialization commands (issue #635). proc_set_last_status(STATUS_BUILTIN_OK); // Run the commands specified as arguments, if any. if (!cmds.empty()) { // Do something nasty to support OpenSUSE assuming we're bash. This may modify cmds. if (is_login) { fish_xdm_login_hack_hack_hack_hack(&cmds, argc - my_optind, argv + my_optind); } for (size_t i = 0; i < cmds.size(); i++) { const wcstring cmd_wcs = str2wcstring(cmds.at(i)); res = parser.eval(cmd_wcs, empty_ios, TOP); } reader_exit(0, 0); } else if (my_optind == argc) { // Interactive mode check_running_fishd(); res = reader_read(STDIN_FILENO, empty_ios); } else { char *file = *(argv + (my_optind++)); int fd = open(file, O_RDONLY); if (fd == -1) { perror(file); } else { // OK to not do this atomically since we cannot have gone multithreaded yet. set_cloexec(fd); if (*(argv + my_optind)) { wcstring sb; char **ptr; int i; for (i = 1, ptr = argv + my_optind; *ptr; i++, ptr++) { if (i != 1) sb.append(ARRAY_SEP_STR); sb.append(str2wcstring(*ptr)); } env_set(L"argv", sb.c_str(), 0); } const wcstring rel_filename = str2wcstring(file); reader_push_current_filename(rel_filename.c_str()); res = reader_read(fd, empty_ios); if (res) { debug(1, _(L"Error while reading file %ls\n"), reader_current_filename() ? reader_current_filename() : _(L"Standard input")); } reader_pop_current_filename(); } } } int exit_status = res ? STATUS_UNKNOWN_COMMAND : proc_get_last_status(); proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), exit_status); restore_term_mode(); restore_term_foreground_process_group(); if (g_profiling_active) { parser.emit_profiling(s_profiling_output_filename); } history_destroy(); proc_destroy(); builtin_destroy(); reader_destroy(); event_destroy(); exit_without_destructors(exit_status); return EXIT_FAILURE; // above line should always exit }