Line data Source code
1 : #include "../fd_config.h" 2 : #include "../fd_action.h" 3 : 4 : extern action_t * ACTIONS[]; 5 : 6 : static void 7 : mem_cmd_args( int * pargc, 8 : char *** pargv, 9 0 : args_t * args ) { 10 0 : char const * topo_name = fd_env_strip_cmdline_cstr( pargc, pargv, "--topo", NULL, "" ); 11 : 12 0 : ulong topo_name_len = strlen( topo_name ); 13 0 : if( FD_UNLIKELY( topo_name_len > sizeof(args->mem.topo)-1 ) ) FD_LOG_ERR(( "Unknown --topo %s", topo_name )); 14 0 : fd_cstr_fini( fd_cstr_append_text( fd_cstr_init( args->mem.topo ), topo_name, topo_name_len ) ); 15 0 : } 16 : 17 : static void 18 : reconstruct_topo( config_t * config, 19 0 : char const * topo_name ) { 20 0 : if( !topo_name[0] ) return; /* keep default action topo */ 21 : 22 0 : action_t const * selected = NULL; 23 0 : for( action_t ** a=ACTIONS; a; a++ ) { 24 0 : action_t const * action = *a; 25 0 : if( 0==strcmp( action->name, topo_name ) ) { 26 0 : selected = action; 27 0 : break; 28 0 : } 29 0 : } 30 : 31 0 : if( !selected ) FD_LOG_ERR(( "Unknown --topo %s", topo_name )); 32 0 : if( !selected->topo ) FD_LOG_ERR(( "Cannot recover topology for --topo %s", topo_name )); 33 : 34 0 : selected->topo( config ); 35 0 : } 36 : 37 : void 38 : mem_cmd_fn( args_t * args, 39 0 : config_t * config ) { 40 0 : reconstruct_topo( config, args->mem.topo ); 41 0 : fd_topo_print_log( 1, &config->topo ); 42 0 : } 43 : 44 : action_t fd_action_mem = { 45 : .name = "mem", 46 : .args = mem_cmd_args, 47 : .fn = mem_cmd_fn, 48 : .require_config = 1, 49 : .perm = NULL, 50 : .description = "Print workspace memory and tile topology information", 51 : };