static void * open_load( PImgCodec instance, PImgLoadFileInstance fi) { LoadRec * l; unsigned char buf[8]; if ( req_seek( fi-> req, 0, SEEK_SET) < 0) return false; if ( req_read( fi-> req, 8, buf) < 0) { req_seek( fi-> req, 0, SEEK_SET); return false; } if ( png_sig_cmp( buf, 0, 8) != 0) { req_seek( fi-> req, 0, SEEK_SET); return false; } fi-> stop = true; fi-> frameCount = 1; l = malloc( sizeof( LoadRec)); if ( !l) outcm( sizeof( LoadRec)); memset( l, 0, sizeof( LoadRec)); if ( !( l-> png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, fi-> errbuf, error_fn, warning_fn))) { free( l); return false; } if ( !( l-> info_ptr = png_create_info_struct(l->png_ptr))) { png_destroy_read_struct(&l->png_ptr, (png_infopp)NULL, (png_infopp)NULL); free( l); return false; } fi-> instance = l; if (setjmp(png_jmpbuf( l-> png_ptr))) { /* If we get here, we had a problem inside open_load */ png_destroy_read_struct(&l-> png_ptr, &l-> info_ptr, (png_infopp)NULL); fi-> instance = nil; free( l); return false; } png_set_read_fn( l-> png_ptr, fi, img_png_read); png_set_sig_bytes( l-> png_ptr, 8); return l; }
void utemp() { INT check ; unsigned i2 ; INT i , freeze ; if( orientation_optimizationG ) { pairtestG = TRUE ; } fraction_doneG = 0.0 ; check = 0 ; freeze = 10000000 ; init_table() ; attprcelG = compute_attprcel(1); if( pairtestG == 0 ) { attmaxG = attprcelG * moveable_cellsG ; if( iterationG < 1 ) { resume_runG = 0 ; } if( !resume_runG && !good_initial_placementG ) { from_beginning() ; } else if( resume_runG ) { from_middle() ; } } for( ; ; ) { if( pairtestG == FALSE && TG >= 0.01 ) { uloop() ; savewolf(0) ; } else { D( "twsc/after_annealing", G( process_graphics() ) ; ) ; pairtestG = TRUE ; if( check == 0 ) { check = 1 ; savewolf(0) ; freeze = iterationG ; if( connection_machineG == TRUE ) { findunlap(0) ; outcm() ; } findunlap(0) ; #ifndef MITLL if( SGGRG || (!doglobalG) ) { even_the_rows(0,FALSE) ; M( MSG, NULL,"evening the row lengths\n") ; findunlap(0) ; } #else if( check_row_lengths() ) { gate_array_even_the_rows(0) ; M( MSG, NULL,"evening the row lengths\n") ; findunlap(0) ; for( i = 1 ; i <= 5 ; i++ ) { if( check_row_lengths() ) { sprintf(YmsgG,"evening the row lengths %d\n", i+1) ; M( MSG, NULL, YmsgG ) ; even_the_rows_2( i ) ; findunlap(0) ; } } } #endif penaltyG = 0 ; /* * This computes new wire costs for the compacted * placement (and feed insertion). It calls unlap() * which sorts and places the cells end-to-end */ M( MSG, NULL,"Removed the cell overlaps --- "); M( MSG, NULL,"Will do neighbor interchanges only now\n"); sprintf( YmsgG, "\nTOTAL INTERCONNECT LENGTH: %d\n",funccostG); M( MSG, NULL, YmsgG ) ; sprintf(YmsgG,"initialRowControl:%8.3f\n", initialRowControlG); M( MSG, NULL, YmsgG ) ; sprintf(YmsgG,"finalRowControl:%8.3f\n", finalRowControlG); M( MSG, NULL, YmsgG ) ; fflush(fpoG); attmaxG = 5 * moveable_cellsG ; if( noPairsG == 0 ) { TG = 0.001 ; M( MSG, NULL, "iter T Wire accept Time\n" ) ; upair() ; savewolf(1) ; } } else { if( noPairsG == 0 ) { TG = 0.001 ; upair() ; savewolf(1) ; } } print_paths() ; } if(!(Ymessage_get_mode() )){ /* if we aren't dumping everything to the screen */ /* show iteration number */ USER_INCR_METER() ; printf("%3d ", iterationG ); if( iterationG % 15 == 0 ) { printf("\n"); } } ++iterationG; fflush( stdout ) ; G( check_graphics(TRUE) ) ; if( iterationG >= freeze + 3 ) { ASSERT( dprint_error(), NULL, NULL ) ; if( doglobalG ) { execute_global_router() ; } else { findunlap(0) ; output() ; } sprintf(YmsgG,"FINAL TOTAL INTERCONNECT LENGTH: %d\n",funccostG); M( MSG, NULL, YmsgG ) ; sprintf(YmsgG,"FINAL OVERLAP PENALTY: %d ", penaltyG ); M( MSG, NULL, YmsgG ) ; sprintf(YmsgG, "FINAL VALUE OF TOTAL COST IS: %d\n", funccostG + penaltyG ) ; M( MSG, NULL, YmsgG ) ; sprintf(YmsgG,"MAX NUMBER OF ATTEMPTED FLIPS PER T:%8d\n",attmaxG); M( MSG, NULL, YmsgG ) ; break ; } }