Example #1
0
int main(int argc, char *argv[])
{
	int chunk_size = BSIZE;
	char str[256];
	struct stat sbuf;

	if (argc != 2 && argc != 3) {
		fprintf(stderr, "usage: %s <filename> {chunk size}\n", argv[0]);
		return 1;
	}
	if (argc == 3) {
		chunk_size = atoi(argv[2]);
	}
	stat(argv[1], &sbuf);
	sprintf(str,"%d", chunk_size);
	setenv("CMGR_CHUNK_SIZE", str, 1);
	sprintf(str,"%ld", sbuf.st_size / 10);
	setenv("CMGR_BCOUNT", str, 1);
	hcache_init(NULL);
	
	/*
	hash = (char *) calloc(EVP_MAX_MD_SIZE, sbuf.st_size / chunk_size + 1);
	for (i = 0; i < 10; i++) {
		gettimeofday(&begin, NULL);
		hcache_get(argv[1], 0, sbuf.st_size / chunk_size + 1, -1, hash);
		gettimeofday(&end, NULL);
		printf("Iteration %d took %g msec\n", i+1, diff(&end, &begin));
	}
	*/
	/*
	hash = (char *) calloc(EVP_MAX_MD_SIZE, 1000);
	for (j = 0; j < 10; j++) {
		for (i = 0; i < sbuf.st_size / chunk_size + 1; i++) {
			snprintf(hash, EVP_MAX_MD_SIZE, "murali%d", i);
			printf("Before Block %d has a hash of ", i);
			print(hash, CAPFS_MAXHASHLENGTH);
			gettimeofday(&begin, NULL);
			hcache_put(argv[1], i, 1, hash);
			gettimeofday(&end, NULL);
			printf("Iteration %d of block_put() %d took %g msec\n", j+1, i+1, diff(&end, &begin));

			memset(hash, 0, EVP_MAX_MD_SIZE);

			gettimeofday(&begin, NULL);
			hcache_get(argv[1], i, 1, -1, hash);
			gettimeofday(&end, NULL);
			printf("Iteration %d of block_get() %d took %g msec\n", j+1, i+1, diff(&end, &begin));
			printf("After Block %d has a hash of ", i);
			print(hash, CAPFS_MAXHASHLENGTH);
			//print(hash + i * CAPFS_MAXHASHLENGTH, CAPFS_MAXHASHLENGTH);
		}
		hcache_clear(argv[1]);
	}
	free(hash);
	*/
	func(argv[1]);
	hcache_finalize();
	return 0;
}
Example #2
0
int
make( 
	int		n_targets,
	const char	**targets,
	int		anyhow )
{
	int i;
	COUNTS counts[1];
	int status = 0;		/* 1 if anything fails */

#ifdef OPT_HEADER_CACHE_EXT
	hcache_init();
#endif

	memset( (char *)counts, 0, sizeof( *counts ) );

	for( i = 0; i < n_targets; i++ )
	{
	    TARGET *t = bindtarget( targets[i] );

	    make0( t, 0, 0, counts, anyhow );
	}

	if( DEBUG_MAKE )
	{
	    if( counts->targets )
		printf( "...found %d target(s)...\n", counts->targets );
	    if( counts->temp )
		printf( "...using %d temp target(s)...\n", counts->temp );
	    if( counts->updating )
		printf( "...updating %d target(s)...\n", counts->updating );
	    if( counts->cantfind )
		printf( "...can't find %d target(s)...\n", counts->cantfind );
	    if( counts->cantmake )
		printf( "...can't make %d target(s)...\n", counts->cantmake );
	}

#ifdef OPT_HEADER_CACHE_EXT
	hcache_done();
#endif

	status = counts->cantfind || counts->cantmake;

	for( i = 0; i < n_targets; i++ )
	    status |= make1( bindtarget( targets[i] ) );

	return status;
}
Example #3
0
int
make( 
	int		n_targets,
	const char	**targets,
	int		anyhow )
{
	int i;
	COUNTS counts[1];
	int status = 0;		/* 1 if anything fails */

#ifdef OPT_HEADER_CACHE_EXT
	hcache_init();
#endif

	memset( (char *)counts, 0, sizeof( *counts ) );

    /* First bind all targets with LOCATE_TARGET setting. This is
       needed to correctly handle dependencies to generated headers.       
    */
    bind_explicitly_located_targets();

    { PROFILE_ENTER(MAKE_MAKE0);
	for( i = 0; i < n_targets; i++ )
	{
	    TARGET *t = bindtarget( targets[i] );

	    make0( t, 0, 0, counts, anyhow );
	}
    PROFILE_EXIT(MAKE_MAKE0); }
        
#ifdef OPT_GRAPH_DEBUG_EXT
	if( DEBUG_GRAPH )
	{
	    for( i = 0; i < n_targets; i++ )
	    {
		TARGET *t = bindtarget( targets[i] );
		dependGraphOutput( t, 0 );
	    }
	}
#endif

	if( DEBUG_MAKE )
	{
	    if( counts->targets )
		printf( "...found %d target%s...\n", counts->targets,
		        counts->targets > 1 ? "s" : "" );
	    if( counts->temp )
		printf( "...using %d temp target%s...\n", counts->temp,
		        counts->temp > 1 ? "s" : "" );
	    if( counts->updating )
		printf( "...updating %d target%s...\n", counts->updating,
		        counts->updating > 1 ? "s" : "" );
	    if( counts->cantfind )
		printf( "...can't find %d target%s...\n", counts->cantfind,
		        counts->cantfind > 1 ? "s" : "" );
	    if( counts->cantmake )
		printf( "...can't make %d target%s...\n", counts->cantmake,
		        counts->cantmake > 1 ? "s" : "" );
	}

#ifdef OPT_HEADER_CACHE_EXT
	hcache_done();
#endif

	status = counts->cantfind || counts->cantmake;

    { PROFILE_ENTER(MAKE_MAKE1);
	for( i = 0; i < n_targets; i++ )
	    status |= make1( bindtarget( targets[i] ) );
    PROFILE_EXIT(MAKE_MAKE1); }

	return status;
}
Example #4
0
int make( LIST * targets, int anyhow )
{
    COUNTS counts[ 1 ];
    int status = 0;  /* 1 if anything fails */

#ifdef OPT_HEADER_CACHE_EXT
    hcache_init();
#endif

    memset( (char *)counts, 0, sizeof( *counts ) );

    /* Make sure that the tables are set up correctly.
     */
    exec_init();

    /* First bind all targets with LOCATE_TARGET setting. This is needed to
     * correctly handle dependencies to generated headers.
     */
    bind_explicitly_located_targets();

    {
        LISTITER iter, end;
        PROFILE_ENTER( MAKE_MAKE0 );
        for ( iter = list_begin( targets ), end = list_end( targets ); iter != end; iter = list_next( iter ) )
        {
            TARGET * t = bindtarget( list_item( iter ) );
            if ( t->fate == T_FATE_INIT )
                make0( t, 0, 0, counts, anyhow, 0 );
        }
        PROFILE_EXIT( MAKE_MAKE0 );
    }

#ifdef OPT_GRAPH_DEBUG_EXT
    if ( DEBUG_GRAPH )
    {
        LISTITER iter, end;
        for ( iter = list_begin( targets ), end = list_end( targets ); iter != end; iter = list_next( iter ) )
           dependGraphOutput( bindtarget( list_item( iter ) ), 0 );
    }
#endif

    if ( DEBUG_MAKE )
    {
        if ( counts->targets )
            out_printf( "...found %d target%s...\n", counts->targets,
                counts->targets > 1 ? "s" : "" );
        if ( counts->temp )
            out_printf( "...using %d temp target%s...\n", counts->temp,
                counts->temp > 1 ? "s" : "" );
        if ( counts->updating )
            out_printf( "...updating %d target%s...\n", counts->updating,
                counts->updating > 1 ? "s" : "" );
        if ( counts->cantfind )
            out_printf( "...can't find %d target%s...\n", counts->cantfind,
                counts->cantfind > 1 ? "s" : "" );
        if ( counts->cantmake )
            out_printf( "...can't make %d target%s...\n", counts->cantmake,
                counts->cantmake > 1 ? "s" : "" );
    }

    status = counts->cantfind || counts->cantmake;

    {
        PROFILE_ENTER( MAKE_MAKE1 );
        status |= make1( targets );
        PROFILE_EXIT( MAKE_MAKE1 );
    }

    return status;
}