string_t addr_id_to_string(const addr_id_t *id) { string_t ret ; switch(id->kind) { case ADDR_UDP: { string_t s = sys_addr_to_string(&id->u.udp) ; ret = sys_sprintf("Addr{Udp;%s}", s) ; string_free(s) ; } break ; case ADDR_NETSIM: ret = sys_sprintf("Addr{Netsim;mux=%u}", id->u.netsim) ; break ; OTHERWISE_ABORT() ; } return ret ; }
void __attribute__((destructor)) __ibprof_exit(void) { IBPROF_ERROR status = IBPROF_ERR_NONE; UNREFERENCED_PARAMETER(status); /* check if it has been activated */ if (ibprof_obj) { IBPROF_MODULE_OBJECT *temp_module_obj = NULL; int i = 0; ibprof_obj->task_obj->wall_time = ibprof_task_wall_time(ibprof_obj->task_obj->t_start); /* Dump all gathered information */ ibprof_dump(); temp_module_obj = ibprof_obj->module_array[0]; while (temp_module_obj) { if (temp_module_obj->id != IBPROF_MODULE_INVALID) { if (temp_module_obj->exit) status = temp_module_obj->exit(temp_module_obj); } temp_module_obj = ibprof_obj->module_array[++i]; } ibprof_hash_destroy(ibprof_obj->hash_obj); ibprof_task_destroy(ibprof_obj->task_obj); DELETE_CRITICAL(&(ibprof_obj->lock)); sys_free(ibprof_obj); ibprof_obj = NULL; } if (ibprof_dump_file && ibprof_dump_file != stdout && ibprof_dump_file != stderr) { struct stat statbuf; char fd_path[255]; char *filename = sys_malloc(255); size_t ret = 0; sys_sprintf(fd_path, "/proc/self/fd/%d", fileno(ibprof_dump_file)); ret = readlink(fd_path, filename, 255); if (ret > 0) { sys_fflush(ibprof_dump_file); sys_fclose(ibprof_dump_file); if (!sys_fstat(filename, &statbuf)) if (!statbuf.st_size) ret = sys_fremove(filename); } sys_free(filename); } return ; }
int EnvInit(void) { #ifdef _STANDALONE #ifdef PERMANENT_VARIABLES unsigned int index = 0; char *env_name; #endif #endif static char after_init = 0; if( after_init ) return SBL_SUCCESS; else after_init = 1; env_size = psbl_rec->env_size; env_base = psbl_rec->env_base; MaxEnvVarsNum = (env_size)/(ENV_CELL_SIZE) - 1; /* Ignore the header */ if(strcmp(( char *)env_base, envVersion) != 0) { FormatEnvBlock(); } #if 0 else { /* TODO: Visit each environment variable and calculate the checksum. * If incorrect, mark as garbage */ } #endif #ifdef _STANDALONE #ifdef PERMANENT_VARIABLES /* Initialize permanent variables section */ __sys_initpermenv(); /* Hai: Copy variables from permanent to temporary storage */ while( ( env_name = ( char *) __sys_getpermenvname( index ) ) != NULL ) { if( __sys_setenv( env_name, __sys_getpermenvval( index ), TRUE ) == SBL_ERESCRUNCH ) { sys_printf( "\nUnable to copy variable %s", env_name ); } index++; } if( index == 0 ) { /* No permanent variables were found, check if PSPBoot was upgraded. if so, copy the backed up permanent variables back to their place */ for(index = 0; index < MaxEnvVarsNum; index++) { ENV_VAR* pVar; char *pName, *pValue; if( !(pVar = GetEnvBlockByNumber( index )) ) break; GetNameAndValueFromEnvVar(pVar, &pName, &pValue); if( !pName ) continue; if( IsEnvPerm( pVar ) ) { /* This is a permanent variable */ sys_setpermenv( ( char *)pName, ( char *)pValue ); } } } #endif if( sys_getenv( "BUILD_OPS" ) == 0 ) { unsigned int flag; char buf[ 16 ]; flag = #ifdef FFS BLDOPS_FFS | #endif #ifdef INCLUDE_LZMA BLDOPS_LZMA | #endif #ifdef INCLUDE_7ZIP BLDOPS_7ZIP | #endif #ifdef INCLUDE_GZIP BLDOPS_GZIP | #endif #ifdef FTP BLDOPS_FTP | #endif #ifdef TFTP BLDOPS_TFTP | #endif #ifdef DUAL_IMAGE_SUPPORT BLDOPS_DUAL_IMAGE | #endif #ifdef TFTP_FAILOVER_SUPPROT BLDOPS_TFTP_FAILOVER | #endif #ifdef DHCP_SUPPORT BLDOPS_DHCP | #endif #ifdef FTP_SERVER_SUPPORT BLDOPS_PCAPP | #endif #ifdef TIBINARY_SUPPORT BLDOPS_TI_BINARY | #endif #ifdef ELF_SUPPORT BLDOPS_ELF | #endif 0; sys_sprintf( buf, "0x%x", flag ); sys_setenv( "BUILD_OPS", buf ); } #endif return SBL_SUCCESS; }