WARNSify
This commit is contained in:
parent
1bb761e96f
commit
795e0608f6
@ -1,7 +1,6 @@
|
|||||||
# $NetBSD: Makefile,v 1.19 1997/10/24 09:00:31 lukem Exp $
|
# $NetBSD: Makefile,v 1.20 1998/02/22 12:55:44 christos Exp $
|
||||||
# @(#)Makefile 8.1 (Berkeley) 6/29/93
|
# @(#)Makefile 8.1 (Berkeley) 6/29/93
|
||||||
|
|
||||||
WARNS= 0
|
|
||||||
PROG= gprof
|
PROG= gprof
|
||||||
SRCS= gprof.c arcs.c dfn.c lookup.c ${MACHINE_ARCH}.c hertz.c \
|
SRCS= gprof.c arcs.c dfn.c lookup.c ${MACHINE_ARCH}.c hertz.c \
|
||||||
printgprof.c printlist.c
|
printgprof.c printlist.c
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/* $NetBSD: alpha.c,v 1.1 1995/04/19 07:24:19 cgd Exp $ */
|
/* $NetBSD: alpha.c,v 1.2 1998/02/22 12:55:44 christos Exp $ */
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: alpha.c,v 1.1 1995/04/19 07:24:19 cgd Exp $";
|
__RCSID("$NetBSD: alpha.c,v 1.2 1998/02/22 12:55:44 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "gprof.h"
|
#include "gprof.h"
|
||||||
@ -9,6 +10,7 @@ static char rcsid[] = "$NetBSD: alpha.c,v 1.1 1995/04/19 07:24:19 cgd Exp $";
|
|||||||
/*
|
/*
|
||||||
* gprof -c isn't currently supported...
|
* gprof -c isn't currently supported...
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
findcall( parentp , p_lowpc , p_highpc )
|
findcall( parentp , p_lowpc , p_highpc )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
unsigned long p_lowpc;
|
unsigned long p_lowpc;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: arcs.c,v 1.6 1995/04/19 07:15:52 cgd Exp $ */
|
/* $NetBSD: arcs.c,v 1.7 1998/02/22 12:55:44 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@ -33,11 +33,12 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)arcs.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)arcs.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: arcs.c,v 1.6 1995/04/19 07:15:52 cgd Exp $";
|
__RCSID("$NetBSD: arcs.c,v 1.7 1998/02/22 12:55:44 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -48,11 +49,12 @@ int visited;
|
|||||||
int viable;
|
int viable;
|
||||||
int newcycle;
|
int newcycle;
|
||||||
int oldcycle;
|
int oldcycle;
|
||||||
#endif DEBUG
|
#endif /* DEBUG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* add (or just increment) an arc
|
* add (or just increment) an arc
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
addarc( parentp , childp , count )
|
addarc( parentp , childp , count )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
nltype *childp;
|
nltype *childp;
|
||||||
@ -60,23 +62,23 @@ addarc( parentp , childp , count )
|
|||||||
{
|
{
|
||||||
arctype *arcp;
|
arctype *arcp;
|
||||||
|
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & TALLYDEBUG ) {
|
if ( debug & TALLYDEBUG ) {
|
||||||
printf( "[addarc] %d arcs from %s to %s\n" ,
|
printf( "[addarc] %d arcs from %s to %s\n" ,
|
||||||
count , parentp -> name , childp -> name );
|
count , parentp -> name , childp -> name );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
arcp = arclookup( parentp , childp );
|
arcp = arclookup( parentp , childp );
|
||||||
if ( arcp != 0 ) {
|
if ( arcp != 0 ) {
|
||||||
/*
|
/*
|
||||||
* a hit: just increment the count.
|
* a hit: just increment the count.
|
||||||
*/
|
*/
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & TALLYDEBUG ) {
|
if ( debug & TALLYDEBUG ) {
|
||||||
printf( "[tally] hit %d += %d\n" ,
|
printf( "[tally] hit %d += %d\n" ,
|
||||||
arcp -> arc_count , count );
|
arcp -> arc_count , count );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
arcp -> arc_count += count;
|
arcp -> arc_count += count;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -106,10 +108,12 @@ addarc( parentp , childp , count )
|
|||||||
*/
|
*/
|
||||||
nltype **topsortnlp;
|
nltype **topsortnlp;
|
||||||
|
|
||||||
topcmp( npp1 , npp2 )
|
int
|
||||||
nltype **npp1;
|
topcmp( v1 , v2 )
|
||||||
nltype **npp2;
|
const void *v1, *v2;
|
||||||
{
|
{
|
||||||
|
const nltype *const *npp1 = v1;
|
||||||
|
const nltype *const *npp2 = v2;
|
||||||
return (*npp1) -> toporder - (*npp2) -> toporder;
|
return (*npp1) -> toporder - (*npp2) -> toporder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,11 +176,11 @@ doarcs()
|
|||||||
/*
|
/*
|
||||||
* analyze cycles to determine breakup
|
* analyze cycles to determine breakup
|
||||||
*/
|
*/
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & BREAKCYCLE ) {
|
if ( debug & BREAKCYCLE ) {
|
||||||
printf("[doarcs] pass %d, cycle(s) %d\n" , pass , ncycle );
|
printf("[doarcs] pass %d, cycle(s) %d\n" , pass , ncycle );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
if ( pass == 1 ) {
|
if ( pass == 1 ) {
|
||||||
printf( "\n\n%s %s\n%s %d:\n" ,
|
printf( "\n\n%s %s\n%s %d:\n" ,
|
||||||
"The following arcs were deleted" ,
|
"The following arcs were deleted" ,
|
||||||
@ -210,7 +214,7 @@ doarcs()
|
|||||||
topsortnlp[ index ] = &nl[ index ];
|
topsortnlp[ index ] = &nl[ index ];
|
||||||
}
|
}
|
||||||
qsort( topsortnlp , nname , sizeof(nltype *) , topcmp );
|
qsort( topsortnlp , nname , sizeof(nltype *) , topcmp );
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[doarcs] topological sort listing\n" );
|
printf( "[doarcs] topological sort listing\n" );
|
||||||
for ( index = 0 ; index < nname ; index += 1 ) {
|
for ( index = 0 ; index < nname ; index += 1 ) {
|
||||||
@ -220,7 +224,7 @@ doarcs()
|
|||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
/*
|
/*
|
||||||
* starting from the topological top,
|
* starting from the topological top,
|
||||||
* propagate print flags to children.
|
* propagate print flags to children.
|
||||||
@ -256,6 +260,7 @@ doarcs()
|
|||||||
return( timesortnlp );
|
return( timesortnlp );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
dotime()
|
dotime()
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
@ -266,6 +271,7 @@ dotime()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
timepropagate( parentp )
|
timepropagate( parentp )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
{
|
{
|
||||||
@ -339,7 +345,7 @@ timepropagate( parentp )
|
|||||||
parentp -> cyclehead -> childtime += share;
|
parentp -> cyclehead -> childtime += share;
|
||||||
parentp -> cyclehead -> propchild += propshare;
|
parentp -> cyclehead -> propchild += propshare;
|
||||||
}
|
}
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & PROPDEBUG ) {
|
if ( debug & PROPDEBUG ) {
|
||||||
printf( "[dotime] child \t" );
|
printf( "[dotime] child \t" );
|
||||||
printname( childp );
|
printname( childp );
|
||||||
@ -350,10 +356,11 @@ timepropagate( parentp )
|
|||||||
printname( parentp );
|
printname( parentp );
|
||||||
printf( "\n[dotime] share %f\n" , share );
|
printf( "\n[dotime] share %f\n" , share );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
cyclelink()
|
cyclelink()
|
||||||
{
|
{
|
||||||
register nltype *nlp;
|
register nltype *nlp;
|
||||||
@ -412,13 +419,13 @@ cyclelink()
|
|||||||
cyclenlp -> cnext = nlp; /* pointer to next member of cycle */
|
cyclenlp -> cnext = nlp; /* pointer to next member of cycle */
|
||||||
cyclenlp -> parents = 0; /* list of caller arcs */
|
cyclenlp -> parents = 0; /* list of caller arcs */
|
||||||
cyclenlp -> children = 0; /* list of callee arcs */
|
cyclenlp -> children = 0; /* list of callee arcs */
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & CYCLEDEBUG ) {
|
if ( debug & CYCLEDEBUG ) {
|
||||||
printf( "[cyclelink] " );
|
printf( "[cyclelink] " );
|
||||||
printname( nlp );
|
printname( nlp );
|
||||||
printf( " is the head of cycle %d\n" , cycle );
|
printf( " is the head of cycle %d\n" , cycle );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
/*
|
/*
|
||||||
* link members to cycle header
|
* link members to cycle header
|
||||||
*/
|
*/
|
||||||
@ -448,6 +455,7 @@ cyclelink()
|
|||||||
/*
|
/*
|
||||||
* analyze cycles to determine breakup
|
* analyze cycles to determine breakup
|
||||||
*/
|
*/
|
||||||
|
bool
|
||||||
cycleanalyze()
|
cycleanalyze()
|
||||||
{
|
{
|
||||||
arctype **cyclestack;
|
arctype **cyclestack;
|
||||||
@ -486,14 +494,14 @@ cycleanalyze()
|
|||||||
if ( cyclestack == 0 ) {
|
if ( cyclestack == 0 ) {
|
||||||
fprintf( stderr , "%s: No room for %d bytes of cycle stack\n" ,
|
fprintf( stderr , "%s: No room for %d bytes of cycle stack\n" ,
|
||||||
whoami , ( size + 1 ) * sizeof( arctype * ) );
|
whoami , ( size + 1 ) * sizeof( arctype * ) );
|
||||||
return;
|
return done;
|
||||||
}
|
}
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & BREAKCYCLE ) {
|
if ( debug & BREAKCYCLE ) {
|
||||||
printf( "[cycleanalyze] starting cycle %d of %d, size %d\n" ,
|
printf( "[cycleanalyze] starting cycle %d of %d, size %d\n" ,
|
||||||
cycleno , ncycle , size );
|
cycleno , ncycle , size );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
for ( nlp = cyclenl[ cycleno ] . cnext ; nlp ; nlp = nlp -> cnext ) {
|
for ( nlp = cyclenl[ cycleno ] . cnext ; nlp ; nlp = nlp -> cnext ) {
|
||||||
stkp = &cyclestack[0];
|
stkp = &cyclestack[0];
|
||||||
nlp -> flags |= CYCLEHEAD;
|
nlp -> flags |= CYCLEHEAD;
|
||||||
@ -516,15 +524,16 @@ cycleanalyze()
|
|||||||
cyclehead = 0;
|
cyclehead = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & BREAKCYCLE ) {
|
if ( debug & BREAKCYCLE ) {
|
||||||
printf("%s visited %d, viable %d, newcycle %d, oldcycle %d\n",
|
printf("%s visited %d, viable %d, newcycle %d, oldcycle %d\n",
|
||||||
"[doarcs]" , visited , viable , newcycle , oldcycle);
|
"[doarcs]" , visited , viable , newcycle , oldcycle);
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
return( done );
|
return( done );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
descend( node , stkstart , stkp )
|
descend( node , stkstart , stkp )
|
||||||
nltype *node;
|
nltype *node;
|
||||||
arctype **stkstart;
|
arctype **stkstart;
|
||||||
@ -534,16 +543,16 @@ descend( node , stkstart , stkp )
|
|||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
for ( arcp = node -> children ; arcp ; arcp = arcp -> arc_childlist ) {
|
for ( arcp = node -> children ; arcp ; arcp = arcp -> arc_childlist ) {
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
visited++;
|
visited++;
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
if ( arcp -> arc_childp -> cycleno != node -> cycleno
|
if ( arcp -> arc_childp -> cycleno != node -> cycleno
|
||||||
|| ( arcp -> arc_childp -> flags & VISITED )
|
|| ( arcp -> arc_childp -> flags & VISITED )
|
||||||
|| ( arcp -> arc_flags & DEADARC ) )
|
|| ( arcp -> arc_flags & DEADARC ) )
|
||||||
continue;
|
continue;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
viable++;
|
viable++;
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
*stkp = arcp;
|
*stkp = arcp;
|
||||||
if ( arcp -> arc_childp -> flags & CYCLEHEAD ) {
|
if ( arcp -> arc_childp -> flags & CYCLEHEAD ) {
|
||||||
if ( addcycle( stkstart , stkp ) == FALSE )
|
if ( addcycle( stkstart , stkp ) == FALSE )
|
||||||
@ -556,14 +565,16 @@ descend( node , stkstart , stkp )
|
|||||||
if ( ret == FALSE )
|
if ( ret == FALSE )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
addcycle( stkstart , stkend )
|
addcycle( stkstart , stkend )
|
||||||
arctype **stkstart;
|
arctype **stkstart;
|
||||||
arctype **stkend;
|
arctype **stkend;
|
||||||
{
|
{
|
||||||
arctype **arcpp;
|
arctype **arcpp;
|
||||||
arctype **stkloc;
|
arctype **stkloc = NULL;
|
||||||
arctype **stkp;
|
arctype **stkp;
|
||||||
arctype **endlist;
|
arctype **endlist;
|
||||||
arctype *minarc;
|
arctype *minarc;
|
||||||
@ -592,9 +603,9 @@ addcycle( stkstart , stkend )
|
|||||||
stkp = stkstart;
|
stkp = stkstart;
|
||||||
}
|
}
|
||||||
if ( arcpp == endlist ) {
|
if ( arcpp == endlist ) {
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
oldcycle++;
|
oldcycle++;
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -621,18 +632,19 @@ addcycle( stkstart , stkend )
|
|||||||
clp -> size = size;
|
clp -> size = size;
|
||||||
clp -> next = cyclehead;
|
clp -> next = cyclehead;
|
||||||
cyclehead = clp;
|
cyclehead = clp;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
newcycle++;
|
newcycle++;
|
||||||
if ( debug & SUBCYCLELIST ) {
|
if ( debug & SUBCYCLELIST ) {
|
||||||
printsubcycle( clp );
|
printsubcycle( clp );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
cyclecnt++;
|
cyclecnt++;
|
||||||
if ( cyclecnt >= CYCLEMAX )
|
if ( cyclecnt >= CYCLEMAX )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
compresslist()
|
compresslist()
|
||||||
{
|
{
|
||||||
cltype *clp;
|
cltype *clp;
|
||||||
@ -641,13 +653,15 @@ compresslist()
|
|||||||
arctype **endlist;
|
arctype **endlist;
|
||||||
arctype *arcp;
|
arctype *arcp;
|
||||||
arctype *maxarcp;
|
arctype *maxarcp;
|
||||||
arctype *maxexitarcp;
|
arctype *maxexitarcp = NULL;
|
||||||
arctype *maxwithparentarcp;
|
arctype *maxwithparentarcp = NULL;
|
||||||
arctype *maxnoparentarcp;
|
arctype *maxnoparentarcp = NULL;
|
||||||
int maxexitcnt;
|
int maxexitcnt;
|
||||||
int maxwithparentcnt;
|
int maxwithparentcnt;
|
||||||
int maxnoparentcnt;
|
int maxnoparentcnt;
|
||||||
|
#ifdef DEBUG
|
||||||
char *type;
|
char *type;
|
||||||
|
# endif /* DEBUG */
|
||||||
|
|
||||||
maxexitcnt = 0;
|
maxexitcnt = 0;
|
||||||
maxwithparentcnt = 0;
|
maxwithparentcnt = 0;
|
||||||
@ -690,40 +704,40 @@ compresslist()
|
|||||||
* first choice is edge leading to node with out-of-cycle parent
|
* first choice is edge leading to node with out-of-cycle parent
|
||||||
*/
|
*/
|
||||||
maxarcp = maxexitarcp;
|
maxarcp = maxexitarcp;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
type = "exit";
|
type = "exit";
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
} else if ( maxwithparentcnt > 0 ) {
|
} else if ( maxwithparentcnt > 0 ) {
|
||||||
/*
|
/*
|
||||||
* second choice is edge leading to node with at least one
|
* second choice is edge leading to node with at least one
|
||||||
* other in-cycle parent
|
* other in-cycle parent
|
||||||
*/
|
*/
|
||||||
maxarcp = maxwithparentarcp;
|
maxarcp = maxwithparentarcp;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
type = "internal";
|
type = "internal";
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* last choice is edge leading to node with only this arc as
|
* last choice is edge leading to node with only this arc as
|
||||||
* a parent (as it will now be orphaned)
|
* a parent (as it will now be orphaned)
|
||||||
*/
|
*/
|
||||||
maxarcp = maxnoparentarcp;
|
maxarcp = maxnoparentarcp;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
type = "orphan";
|
type = "orphan";
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
maxarcp -> arc_flags |= DEADARC;
|
maxarcp -> arc_flags |= DEADARC;
|
||||||
maxarcp -> arc_childp -> parentcnt -= 1;
|
maxarcp -> arc_childp -> parentcnt -= 1;
|
||||||
maxarcp -> arc_childp -> npropcall -= maxarcp -> arc_count;
|
maxarcp -> arc_childp -> npropcall -= maxarcp -> arc_count;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & BREAKCYCLE ) {
|
if ( debug & BREAKCYCLE ) {
|
||||||
printf( "%s delete %s arc: %s (%d) -> %s from %d cycle(s)\n" ,
|
printf( "%s delete %s arc: %s (%d) -> %s from %d cycle(s)\n" ,
|
||||||
"[compresslist]" , type , maxarcp -> arc_parentp -> name ,
|
"[compresslist]" , type , maxarcp -> arc_parentp -> name ,
|
||||||
maxarcp -> arc_count , maxarcp -> arc_childp -> name ,
|
maxarcp -> arc_count , maxarcp -> arc_childp -> name ,
|
||||||
maxarcp -> arc_cyclecnt );
|
maxarcp -> arc_cyclecnt );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
printf( "\t%s to %s with %d calls\n" , maxarcp -> arc_parentp -> name ,
|
printf( "\t%s to %s with %ld calls\n" , maxarcp -> arc_parentp -> name ,
|
||||||
maxarcp -> arc_childp -> name , maxarcp -> arc_count );
|
maxarcp -> arc_childp -> name , maxarcp -> arc_count );
|
||||||
prev = &cyclehead;
|
prev = &cyclehead;
|
||||||
for ( clp = cyclehead ; clp ; ) {
|
for ( clp = cyclehead ; clp ; ) {
|
||||||
@ -746,6 +760,7 @@ compresslist()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
void
|
||||||
printsubcycle( clp )
|
printsubcycle( clp )
|
||||||
cltype *clp;
|
cltype *clp;
|
||||||
{
|
{
|
||||||
@ -759,8 +774,9 @@ printsubcycle( clp )
|
|||||||
printf( "\t(%d) -> %s\n" , (*arcpp) -> arc_count ,
|
printf( "\t(%d) -> %s\n" , (*arcpp) -> arc_count ,
|
||||||
(*arcpp) -> arc_childp -> name ) ;
|
(*arcpp) -> arc_childp -> name ) ;
|
||||||
}
|
}
|
||||||
#endif DEBUG
|
#endif /* DEBUG */
|
||||||
|
|
||||||
|
void
|
||||||
cycletime()
|
cycletime()
|
||||||
{
|
{
|
||||||
int cycle;
|
int cycle;
|
||||||
@ -790,6 +806,7 @@ cycletime()
|
|||||||
* propfraction as the sum of fractional parents' propfractions
|
* propfraction as the sum of fractional parents' propfractions
|
||||||
* and while we're here, sum time for functions.
|
* and while we're here, sum time for functions.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
doflags()
|
doflags()
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
@ -810,14 +827,14 @@ doflags()
|
|||||||
oldhead = childp -> cyclehead;
|
oldhead = childp -> cyclehead;
|
||||||
inheritflags( childp );
|
inheritflags( childp );
|
||||||
}
|
}
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & PROPDEBUG ) {
|
if ( debug & PROPDEBUG ) {
|
||||||
printf( "[doflags] " );
|
printf( "[doflags] " );
|
||||||
printname( childp );
|
printname( childp );
|
||||||
printf( " inherits printflag %d and propfraction %f\n" ,
|
printf( " inherits printflag %d and propfraction %f\n" ,
|
||||||
childp -> printflag , childp -> propfraction );
|
childp -> printflag , childp -> propfraction );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
if ( ! childp -> printflag ) {
|
if ( ! childp -> printflag ) {
|
||||||
/*
|
/*
|
||||||
* printflag is off
|
* printflag is off
|
||||||
@ -864,7 +881,7 @@ doflags()
|
|||||||
}
|
}
|
||||||
childp -> propself = childp -> time * childp -> propfraction;
|
childp -> propself = childp -> time * childp -> propfraction;
|
||||||
printtime += childp -> propself;
|
printtime += childp -> propself;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & PROPDEBUG ) {
|
if ( debug & PROPDEBUG ) {
|
||||||
printf( "[doflags] " );
|
printf( "[doflags] " );
|
||||||
printname( childp );
|
printname( childp );
|
||||||
@ -873,7 +890,7 @@ doflags()
|
|||||||
printf( "time %f propself %f printtime %f\n" ,
|
printf( "time %f propself %f printtime %f\n" ,
|
||||||
childp -> time , childp -> propself , printtime );
|
childp -> time , childp -> propself , printtime );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -884,6 +901,7 @@ doflags()
|
|||||||
* print flag of the child (cycle) appropriately.
|
* print flag of the child (cycle) appropriately.
|
||||||
* similarly, deal with propagation fractions from parents.
|
* similarly, deal with propagation fractions from parents.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
inheritflags( childp )
|
inheritflags( childp )
|
||||||
nltype *childp;
|
nltype *childp;
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/* $NetBSD: arm32.c,v 1.1 1996/04/01 21:51:22 mark Exp $ */
|
/* $NetBSD: arm32.c,v 1.2 1998/02/22 12:55:44 christos Exp $ */
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: arm32.c,v 1.1 1996/04/01 21:51:22 mark Exp $";
|
__RCSID("$NetBSD: arm32.c,v 1.2 1998/02/22 12:55:44 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "gprof.h"
|
#include "gprof.h"
|
||||||
@ -9,6 +10,7 @@ static char rcsid[] = "$NetBSD: arm32.c,v 1.1 1996/04/01 21:51:22 mark Exp $";
|
|||||||
/*
|
/*
|
||||||
* gprof -c isn't currently supported...
|
* gprof -c isn't currently supported...
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
findcall( parentp , p_lowpc , p_highpc )
|
findcall( parentp , p_lowpc , p_highpc )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
unsigned long p_lowpc;
|
unsigned long p_lowpc;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: dfn.c,v 1.5 1995/04/19 07:15:56 cgd Exp $ */
|
/* $NetBSD: dfn.c,v 1.6 1998/02/22 12:55:44 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@ -33,11 +33,12 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)dfn.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)dfn.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: dfn.c,v 1.5 1995/04/19 07:15:56 cgd Exp $";
|
__RCSID("$NetBSD: dfn.c,v 1.6 1998/02/22 12:55:44 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -56,6 +57,7 @@ int dfn_depth;
|
|||||||
|
|
||||||
int dfn_counter;
|
int dfn_counter;
|
||||||
|
|
||||||
|
void
|
||||||
dfn_init()
|
dfn_init()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -66,18 +68,19 @@ dfn_init()
|
|||||||
/*
|
/*
|
||||||
* given this parent, depth first number its children.
|
* given this parent, depth first number its children.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
dfn( parentp )
|
dfn( parentp )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
{
|
{
|
||||||
arctype *arcp;
|
arctype *arcp;
|
||||||
|
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[dfn] dfn(" );
|
printf( "[dfn] dfn(" );
|
||||||
printname( parentp );
|
printname( parentp );
|
||||||
printf( ")\n" );
|
printf( ")\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
/*
|
/*
|
||||||
* if we're already numbered, no need to look any furthur.
|
* if we're already numbered, no need to look any furthur.
|
||||||
*/
|
*/
|
||||||
@ -112,6 +115,7 @@ dfn( parentp )
|
|||||||
/*
|
/*
|
||||||
* push a parent onto the stack and mark it busy
|
* push a parent onto the stack and mark it busy
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
dfn_pre_visit( parentp )
|
dfn_pre_visit( parentp )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
{
|
{
|
||||||
@ -124,13 +128,13 @@ dfn_pre_visit( parentp )
|
|||||||
dfn_stack[ dfn_depth ].nlentryp = parentp;
|
dfn_stack[ dfn_depth ].nlentryp = parentp;
|
||||||
dfn_stack[ dfn_depth ].cycletop = dfn_depth;
|
dfn_stack[ dfn_depth ].cycletop = dfn_depth;
|
||||||
parentp -> toporder = DFN_BUSY;
|
parentp -> toporder = DFN_BUSY;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[dfn_pre_visit]\t\t%d:" , dfn_depth );
|
printf( "[dfn_pre_visit]\t\t%d:" , dfn_depth );
|
||||||
printname( parentp );
|
printname( parentp );
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -161,6 +165,7 @@ dfn_busy( childp )
|
|||||||
/*
|
/*
|
||||||
* MISSING: an explanation
|
* MISSING: an explanation
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
dfn_findcycle( childp )
|
dfn_findcycle( childp )
|
||||||
nltype *childp;
|
nltype *childp;
|
||||||
{
|
{
|
||||||
@ -183,14 +188,14 @@ dfn_findcycle( childp )
|
|||||||
fprintf( stderr , "[dfn_findcycle] couldn't find head of cycle\n" );
|
fprintf( stderr , "[dfn_findcycle] couldn't find head of cycle\n" );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[dfn_findcycle] dfn_depth %d cycletop %d " ,
|
printf( "[dfn_findcycle] dfn_depth %d cycletop %d " ,
|
||||||
dfn_depth , cycletop );
|
dfn_depth , cycletop );
|
||||||
printname( cycleheadp );
|
printname( cycleheadp );
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
if ( cycletop == dfn_depth ) {
|
if ( cycletop == dfn_depth ) {
|
||||||
/*
|
/*
|
||||||
* this is previous function, e.g. this calls itself
|
* this is previous function, e.g. this calls itself
|
||||||
@ -206,13 +211,13 @@ dfn_findcycle( childp )
|
|||||||
*/
|
*/
|
||||||
for ( tailp = cycleheadp ; tailp -> cnext ; tailp = tailp -> cnext ) {
|
for ( tailp = cycleheadp ; tailp -> cnext ; tailp = tailp -> cnext ) {
|
||||||
/* void: chase down to tail of things already glommed */
|
/* void: chase down to tail of things already glommed */
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[dfn_findcycle] tail " );
|
printf( "[dfn_findcycle] tail " );
|
||||||
printname( tailp );
|
printname( tailp );
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* if what we think is the top of the cycle
|
* if what we think is the top of the cycle
|
||||||
@ -221,13 +226,13 @@ dfn_findcycle( childp )
|
|||||||
*/
|
*/
|
||||||
if ( cycleheadp -> cyclehead != cycleheadp ) {
|
if ( cycleheadp -> cyclehead != cycleheadp ) {
|
||||||
cycleheadp = cycleheadp -> cyclehead;
|
cycleheadp = cycleheadp -> cyclehead;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[dfn_findcycle] new cyclehead " );
|
printf( "[dfn_findcycle] new cyclehead " );
|
||||||
printname( cycleheadp );
|
printname( cycleheadp );
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
for ( index = cycletop + 1 ; index <= dfn_depth ; index += 1 ) {
|
for ( index = cycletop + 1 ; index <= dfn_depth ; index += 1 ) {
|
||||||
childp = dfn_stack[ index ].nlentryp;
|
childp = dfn_stack[ index ].nlentryp;
|
||||||
@ -238,7 +243,7 @@ dfn_findcycle( childp )
|
|||||||
*/
|
*/
|
||||||
tailp -> cnext = childp;
|
tailp -> cnext = childp;
|
||||||
childp -> cyclehead = cycleheadp;
|
childp -> cyclehead = cycleheadp;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[dfn_findcycle] glomming " );
|
printf( "[dfn_findcycle] glomming " );
|
||||||
printname( childp );
|
printname( childp );
|
||||||
@ -246,10 +251,10 @@ dfn_findcycle( childp )
|
|||||||
printname( cycleheadp );
|
printname( cycleheadp );
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
for ( tailp = childp ; tailp->cnext ; tailp = tailp->cnext ) {
|
for ( tailp = childp ; tailp->cnext ; tailp = tailp->cnext ) {
|
||||||
tailp -> cnext -> cyclehead = cycleheadp;
|
tailp -> cnext -> cyclehead = cycleheadp;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[dfn_findcycle] and its tail " );
|
printf( "[dfn_findcycle] and its tail " );
|
||||||
printname( tailp -> cnext );
|
printname( tailp -> cnext );
|
||||||
@ -257,7 +262,7 @@ dfn_findcycle( childp )
|
|||||||
printname( cycleheadp );
|
printname( cycleheadp );
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
} else if ( childp -> cyclehead != cycleheadp /* firewall */ ) {
|
} else if ( childp -> cyclehead != cycleheadp /* firewall */ ) {
|
||||||
fprintf( stderr ,
|
fprintf( stderr ,
|
||||||
@ -271,6 +276,7 @@ dfn_findcycle( childp )
|
|||||||
* deal with self-cycles
|
* deal with self-cycles
|
||||||
* for lint: ARGSUSED
|
* for lint: ARGSUSED
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
dfn_self_cycle( parentp )
|
dfn_self_cycle( parentp )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
{
|
{
|
||||||
@ -278,13 +284,13 @@ dfn_self_cycle( parentp )
|
|||||||
* since we are taking out self-cycles elsewhere
|
* since we are taking out self-cycles elsewhere
|
||||||
* no need for the special case, here.
|
* no need for the special case, here.
|
||||||
*/
|
*/
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[dfn_self_cycle] " );
|
printf( "[dfn_self_cycle] " );
|
||||||
printname( parentp );
|
printname( parentp );
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -292,18 +298,19 @@ dfn_self_cycle( parentp )
|
|||||||
* [MISSING: an explanation]
|
* [MISSING: an explanation]
|
||||||
* and pop it off the stack
|
* and pop it off the stack
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
dfn_post_visit( parentp )
|
dfn_post_visit( parentp )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
{
|
{
|
||||||
nltype *memberp;
|
nltype *memberp;
|
||||||
|
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[dfn_post_visit]\t%d: " , dfn_depth );
|
printf( "[dfn_post_visit]\t%d: " , dfn_depth );
|
||||||
printname( parentp );
|
printname( parentp );
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
/*
|
/*
|
||||||
* number functions and things in their cycles
|
* number functions and things in their cycles
|
||||||
* unless the function is itself part of a cycle
|
* unless the function is itself part of a cycle
|
||||||
@ -312,20 +319,20 @@ dfn_post_visit( parentp )
|
|||||||
dfn_counter += 1;
|
dfn_counter += 1;
|
||||||
for ( memberp = parentp ; memberp ; memberp = memberp -> cnext ) {
|
for ( memberp = parentp ; memberp ; memberp = memberp -> cnext ) {
|
||||||
memberp -> toporder = dfn_counter;
|
memberp -> toporder = dfn_counter;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[dfn_post_visit]\t\tmember " );
|
printf( "[dfn_post_visit]\t\tmember " );
|
||||||
printname( memberp );
|
printname( memberp );
|
||||||
printf( " -> toporder = %d\n" , dfn_counter );
|
printf( " -> toporder = %d\n" , dfn_counter );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "[dfn_post_visit]\t\tis part of a cycle\n" );
|
printf( "[dfn_post_visit]\t\tis part of a cycle\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
dfn_depth -= 1;
|
dfn_depth -= 1;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: gprof.c,v 1.9 1997/01/30 09:20:55 matthias Exp $ */
|
/* $NetBSD: gprof.c,v 1.10 1998/02/22 12:55:44 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@ -33,23 +33,25 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
__COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
|
||||||
"@(#) Copyright (c) 1983, 1993\n\
|
The Regents of the University of California. All rights reserved.\n");
|
||||||
The Regents of the University of California. All rights reserved.\n";
|
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)gprof.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)gprof.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: gprof.c,v 1.9 1997/01/30 09:20:55 matthias Exp $";
|
__RCSID("$NetBSD: gprof.c,v 1.10 1998/02/22 12:55:44 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "gprof.h"
|
#include "gprof.h"
|
||||||
|
|
||||||
char *whoami = "gprof";
|
extern char *__progname;
|
||||||
|
|
||||||
|
char *whoami;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* things which get -E excluded by default.
|
* things which get -E excluded by default.
|
||||||
@ -58,6 +60,9 @@ char *defaultEs[] = { "mcount" , "__mcleanup" , 0 };
|
|||||||
|
|
||||||
static struct gmonhdr gmonhdr;
|
static struct gmonhdr gmonhdr;
|
||||||
|
|
||||||
|
int main __P((int, char **));
|
||||||
|
|
||||||
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
@ -65,6 +70,7 @@ main(argc, argv)
|
|||||||
char **sp;
|
char **sp;
|
||||||
nltype **timesortnlp;
|
nltype **timesortnlp;
|
||||||
|
|
||||||
|
whoami = __progname;
|
||||||
--argc;
|
--argc;
|
||||||
argv++;
|
argv++;
|
||||||
debug = 0;
|
debug = 0;
|
||||||
@ -95,11 +101,11 @@ main(argc, argv)
|
|||||||
setlinebuf(stdout);
|
setlinebuf(stdout);
|
||||||
debug |= atoi( *++argv );
|
debug |= atoi( *++argv );
|
||||||
debug |= ANYDEBUG;
|
debug |= ANYDEBUG;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("[main] debug = %d\n", debug);
|
printf("[main] debug = %d\n", debug);
|
||||||
# else not DEBUG
|
# else not DEBUG
|
||||||
printf("%s: -d ignored\n", whoami);
|
printf("%s: -d ignored\n", whoami);
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
++argv;
|
++argv;
|
||||||
@ -206,6 +212,7 @@ main(argc, argv)
|
|||||||
*/
|
*/
|
||||||
printindex();
|
printindex();
|
||||||
done();
|
done();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -213,10 +220,10 @@ main(argc, argv)
|
|||||||
* and optionally the text space.
|
* and optionally the text space.
|
||||||
* On return symbol table is sorted by value.
|
* On return symbol table is sorted by value.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
getnfile()
|
getnfile()
|
||||||
{
|
{
|
||||||
FILE *nfile;
|
FILE *nfile;
|
||||||
int valcmp();
|
|
||||||
|
|
||||||
nfile = fopen( a_outname ,"r");
|
nfile = fopen( a_outname ,"r");
|
||||||
if (nfile == NULL) {
|
if (nfile == NULL) {
|
||||||
@ -233,7 +240,7 @@ getnfile()
|
|||||||
gettextspace( nfile );
|
gettextspace( nfile );
|
||||||
qsort(nl, nname, sizeof(nltype), valcmp);
|
qsort(nl, nname, sizeof(nltype), valcmp);
|
||||||
fclose(nfile);
|
fclose(nfile);
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & AOUTDEBUG ) {
|
if ( debug & AOUTDEBUG ) {
|
||||||
register int j;
|
register int j;
|
||||||
|
|
||||||
@ -241,9 +248,10 @@ getnfile()
|
|||||||
printf("[getnfile] 0X%08x\t%s\n", nl[j].value, nl[j].name);
|
printf("[getnfile] 0X%08x\t%s\n", nl[j].value, nl[j].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
getstrtab(nfile)
|
getstrtab(nfile)
|
||||||
FILE *nfile;
|
FILE *nfile;
|
||||||
{
|
{
|
||||||
@ -256,7 +264,7 @@ getstrtab(nfile)
|
|||||||
}
|
}
|
||||||
strtab = calloc(ssiz, 1);
|
strtab = calloc(ssiz, 1);
|
||||||
if (strtab == NULL) {
|
if (strtab == NULL) {
|
||||||
fprintf(stderr, "%s: %s: no room for %d bytes of string table\n",
|
fprintf(stderr, "%s: %s: no room for %ld bytes of string table\n",
|
||||||
whoami , a_outname , ssiz);
|
whoami , a_outname , ssiz);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@ -270,6 +278,7 @@ getstrtab(nfile)
|
|||||||
/*
|
/*
|
||||||
* Read in symbol table
|
* Read in symbol table
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
getsymtab(nfile)
|
getsymtab(nfile)
|
||||||
FILE *nfile;
|
FILE *nfile;
|
||||||
{
|
{
|
||||||
@ -306,22 +315,22 @@ getsymtab(nfile)
|
|||||||
for (i = xbuf.a_syms; i > 0; i -= sizeof(struct nlist)) {
|
for (i = xbuf.a_syms; i > 0; i -= sizeof(struct nlist)) {
|
||||||
fread(&nbuf, sizeof(nbuf), 1, nfile);
|
fread(&nbuf, sizeof(nbuf), 1, nfile);
|
||||||
if ( ! funcsymbol( &nbuf ) ) {
|
if ( ! funcsymbol( &nbuf ) ) {
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & AOUTDEBUG ) {
|
if ( debug & AOUTDEBUG ) {
|
||||||
printf( "[getsymtab] rejecting: 0x%x %s\n" ,
|
printf( "[getsymtab] rejecting: 0x%x %s\n" ,
|
||||||
nbuf.n_type , strtab + nbuf.n_un.n_strx );
|
nbuf.n_type , strtab + nbuf.n_un.n_strx );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
npe->value = nbuf.n_value;
|
npe->value = nbuf.n_value;
|
||||||
npe->name = strtab+nbuf.n_un.n_strx;
|
npe->name = strtab+nbuf.n_un.n_strx;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & AOUTDEBUG ) {
|
if ( debug & AOUTDEBUG ) {
|
||||||
printf( "[getsymtab] %d %s 0x%08x\n" ,
|
printf( "[getsymtab] %d %s 0x%08x\n" ,
|
||||||
nname , npe -> name , npe -> value );
|
nname , npe -> name , npe -> value );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
npe++;
|
npe++;
|
||||||
nname++;
|
nname++;
|
||||||
}
|
}
|
||||||
@ -331,6 +340,7 @@ getsymtab(nfile)
|
|||||||
/*
|
/*
|
||||||
* read in the text space of an a.out file
|
* read in the text space of an a.out file
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
gettextspace( nfile )
|
gettextspace( nfile )
|
||||||
FILE *nfile;
|
FILE *nfile;
|
||||||
{
|
{
|
||||||
@ -340,7 +350,7 @@ gettextspace( nfile )
|
|||||||
}
|
}
|
||||||
textspace = (u_char *) malloc( xbuf.a_text );
|
textspace = (u_char *) malloc( xbuf.a_text );
|
||||||
if ( textspace == 0 ) {
|
if ( textspace == 0 ) {
|
||||||
fprintf( stderr , "%s: ran out room for %d bytes of text space: " ,
|
fprintf( stderr , "%s: ran out room for %ld bytes of text space: " ,
|
||||||
whoami , xbuf.a_text );
|
whoami , xbuf.a_text );
|
||||||
fprintf( stderr , "can't do -c\n" );
|
fprintf( stderr , "can't do -c\n" );
|
||||||
return;
|
return;
|
||||||
@ -359,11 +369,11 @@ gettextspace( nfile )
|
|||||||
* an array of sampling hits within pc ranges,
|
* an array of sampling hits within pc ranges,
|
||||||
* and the arcs.
|
* and the arcs.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
getpfile(filename)
|
getpfile(filename)
|
||||||
char *filename;
|
char *filename;
|
||||||
{
|
{
|
||||||
FILE *pfile;
|
FILE *pfile;
|
||||||
FILE *openpfile();
|
|
||||||
struct rawarc arc;
|
struct rawarc arc;
|
||||||
|
|
||||||
pfile = openpfile(filename);
|
pfile = openpfile(filename);
|
||||||
@ -373,12 +383,12 @@ getpfile(filename)
|
|||||||
* a bunch of <from,self,count> tuples.
|
* a bunch of <from,self,count> tuples.
|
||||||
*/
|
*/
|
||||||
while ( fread( &arc , sizeof arc , 1 , pfile ) == 1 ) {
|
while ( fread( &arc , sizeof arc , 1 , pfile ) == 1 ) {
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & SAMPLEDEBUG ) {
|
if ( debug & SAMPLEDEBUG ) {
|
||||||
printf( "[getpfile] frompc 0x%x selfpc 0x%x count %d\n" ,
|
printf( "[getpfile] frompc 0x%x selfpc 0x%x count %d\n" ,
|
||||||
arc.raw_frompc , arc.raw_selfpc , arc.raw_count );
|
arc.raw_frompc , arc.raw_selfpc , arc.raw_count );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
/*
|
/*
|
||||||
* add this arc
|
* add this arc
|
||||||
*/
|
*/
|
||||||
@ -420,7 +430,7 @@ openpfile(filename)
|
|||||||
hz = rate;
|
hz = rate;
|
||||||
} else if (hz != rate) {
|
} else if (hz != rate) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: profile clock rate (%d) %s (%d) in first gmon file\n",
|
"%s: profile clock rate (%d) %s (%ld) in first gmon file\n",
|
||||||
filename, rate, "incompatible with clock rate", hz);
|
filename, rate, "incompatible with clock rate", hz);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@ -430,7 +440,7 @@ openpfile(filename)
|
|||||||
highpc = (unsigned long)gmonhdr.hpc / sizeof(UNIT);
|
highpc = (unsigned long)gmonhdr.hpc / sizeof(UNIT);
|
||||||
sampbytes = gmonhdr.ncnt - size;
|
sampbytes = gmonhdr.ncnt - size;
|
||||||
nsamples = sampbytes / sizeof (UNIT);
|
nsamples = sampbytes / sizeof (UNIT);
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & SAMPLEDEBUG ) {
|
if ( debug & SAMPLEDEBUG ) {
|
||||||
printf( "[openpfile] hdr.lpc 0x%x hdr.hpc 0x%x hdr.ncnt %d\n",
|
printf( "[openpfile] hdr.lpc 0x%x hdr.hpc 0x%x hdr.ncnt %d\n",
|
||||||
gmonhdr.lpc , gmonhdr.hpc , gmonhdr.ncnt );
|
gmonhdr.lpc , gmonhdr.hpc , gmonhdr.ncnt );
|
||||||
@ -442,10 +452,11 @@ openpfile(filename)
|
|||||||
sampbytes , nsamples );
|
sampbytes , nsamples );
|
||||||
printf( "[openpfile] sample rate %d\n" , hz );
|
printf( "[openpfile] sample rate %d\n" , hz );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
return(pfile);
|
return(pfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
tally( rawp )
|
tally( rawp )
|
||||||
struct rawarc *rawp;
|
struct rawarc *rawp;
|
||||||
{
|
{
|
||||||
@ -462,18 +473,19 @@ tally( rawp )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
childp -> ncall += rawp -> raw_count;
|
childp -> ncall += rawp -> raw_count;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & TALLYDEBUG ) {
|
if ( debug & TALLYDEBUG ) {
|
||||||
printf( "[tally] arc from %s to %s traversed %d times\n" ,
|
printf( "[tally] arc from %s to %s traversed %d times\n" ,
|
||||||
parentp -> name , childp -> name , rawp -> raw_count );
|
parentp -> name , childp -> name , rawp -> raw_count );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
addarc( parentp , childp , rawp -> raw_count );
|
addarc( parentp , childp , rawp -> raw_count );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dump out the gmon.sum file
|
* dump out the gmon.sum file
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
dumpsum( sumfile )
|
dumpsum( sumfile )
|
||||||
char *sumfile;
|
char *sumfile;
|
||||||
{
|
{
|
||||||
@ -512,20 +524,22 @@ dumpsum( sumfile )
|
|||||||
perror( sumfile );
|
perror( sumfile );
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & SAMPLEDEBUG ) {
|
if ( debug & SAMPLEDEBUG ) {
|
||||||
printf( "[dumpsum] frompc 0x%x selfpc 0x%x count %d\n" ,
|
printf( "[dumpsum] frompc 0x%x selfpc 0x%x count %d\n" ,
|
||||||
arc.raw_frompc , arc.raw_selfpc , arc.raw_count );
|
arc.raw_frompc , arc.raw_selfpc , arc.raw_count );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose( sfile );
|
fclose( sfile );
|
||||||
}
|
}
|
||||||
|
|
||||||
valcmp(p1, p2)
|
int
|
||||||
nltype *p1, *p2;
|
valcmp(v1, v2)
|
||||||
|
const void *v1, *v2;
|
||||||
{
|
{
|
||||||
|
const nltype *p1 = v1, *p2 = v2;
|
||||||
if ( p1 -> value < p2 -> value ) {
|
if ( p1 -> value < p2 -> value ) {
|
||||||
return LESSTHAN;
|
return LESSTHAN;
|
||||||
}
|
}
|
||||||
@ -535,6 +549,7 @@ valcmp(p1, p2)
|
|||||||
return EQUALTO;
|
return EQUALTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
readsamples(pfile)
|
readsamples(pfile)
|
||||||
FILE *pfile;
|
FILE *pfile;
|
||||||
{
|
{
|
||||||
@ -595,6 +610,7 @@ readsamples(pfile)
|
|||||||
* only one sample for every four bytes of text space and never
|
* only one sample for every four bytes of text space and never
|
||||||
* have any overlap (the two end cases, above).
|
* have any overlap (the two end cases, above).
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
asgnsamples()
|
asgnsamples()
|
||||||
{
|
{
|
||||||
register int j;
|
register int j;
|
||||||
@ -616,12 +632,12 @@ asgnsamples()
|
|||||||
pcl = lowpc + scale * i;
|
pcl = lowpc + scale * i;
|
||||||
pch = lowpc + scale * (i + 1);
|
pch = lowpc + scale * (i + 1);
|
||||||
time = ccnt;
|
time = ccnt;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & SAMPLEDEBUG ) {
|
if ( debug & SAMPLEDEBUG ) {
|
||||||
printf( "[asgnsamples] pcl 0x%x pch 0x%x ccnt %d\n" ,
|
printf( "[asgnsamples] pcl 0x%x pch 0x%x ccnt %d\n" ,
|
||||||
pcl , pch , ccnt );
|
pcl , pch , ccnt );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
totime += time;
|
totime += time;
|
||||||
for (j = j - 1; j < nname; j++) {
|
for (j = j - 1; j < nname; j++) {
|
||||||
svalue0 = nl[j].svalue;
|
svalue0 = nl[j].svalue;
|
||||||
@ -640,25 +656,25 @@ asgnsamples()
|
|||||||
continue;
|
continue;
|
||||||
overlap = min(pch, svalue1) - max(pcl, svalue0);
|
overlap = min(pch, svalue1) - max(pcl, svalue0);
|
||||||
if (overlap > 0) {
|
if (overlap > 0) {
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug & SAMPLEDEBUG) {
|
if (debug & SAMPLEDEBUG) {
|
||||||
printf("[asgnsamples] (0x%x->0x%x-0x%x) %s gets %f ticks %d overlap\n",
|
printf("[asgnsamples] (0x%x->0x%x-0x%x) %s gets %f ticks %d overlap\n",
|
||||||
nl[j].value/sizeof(UNIT), svalue0, svalue1,
|
nl[j].value/sizeof(UNIT), svalue0, svalue1,
|
||||||
nl[j].name,
|
nl[j].name,
|
||||||
overlap * time / scale, overlap);
|
overlap * time / scale, overlap);
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
nl[j].time += overlap * time / scale;
|
nl[j].time += overlap * time / scale;
|
||||||
if ( onlist( Elist , nl[j].name ) )
|
if ( onlist( Elist , nl[j].name ) )
|
||||||
totime -= overlap * time / scale;
|
totime -= overlap * time / scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug & SAMPLEDEBUG) {
|
if (debug & SAMPLEDEBUG) {
|
||||||
printf("[asgnsamples] totime %f\n", totime);
|
printf("[asgnsamples] totime %f\n", totime);
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -686,6 +702,7 @@ max(a, b)
|
|||||||
* if it turns out that the entry point is in one bucket and the code
|
* if it turns out that the entry point is in one bucket and the code
|
||||||
* for a routine is in the next bucket.
|
* for a routine is in the next bucket.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
alignentries()
|
alignentries()
|
||||||
{
|
{
|
||||||
register struct nl *nlp;
|
register struct nl *nlp;
|
||||||
@ -697,12 +714,12 @@ alignentries()
|
|||||||
bucket_of_entry = (nlp->svalue - lowpc) / scale;
|
bucket_of_entry = (nlp->svalue - lowpc) / scale;
|
||||||
bucket_of_code = (nlp->svalue + UNITS_TO_CODE - lowpc) / scale;
|
bucket_of_code = (nlp->svalue + UNITS_TO_CODE - lowpc) / scale;
|
||||||
if (bucket_of_entry < bucket_of_code) {
|
if (bucket_of_entry < bucket_of_code) {
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug & SAMPLEDEBUG) {
|
if (debug & SAMPLEDEBUG) {
|
||||||
printf("[alignentries] pushing svalue 0x%x to 0x%x\n",
|
printf("[alignentries] pushing svalue 0x%x to 0x%x\n",
|
||||||
nlp->svalue, nlp->svalue + UNITS_TO_CODE);
|
nlp->svalue, nlp->svalue + UNITS_TO_CODE);
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
nlp->svalue += UNITS_TO_CODE;
|
nlp->svalue += UNITS_TO_CODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -744,7 +761,7 @@ funcsymbol( nlistp )
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
while ( c = *name++ ) {
|
while ( (c = *name++) != '\0' ) {
|
||||||
if ( c == '.' || c == '$' ) {
|
if ( c == '.' || c == '$' ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -752,6 +769,7 @@ funcsymbol( nlistp )
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
done()
|
done()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: gprof.h,v 1.13 1996/04/01 21:54:06 mark Exp $ */
|
/* $NetBSD: gprof.h,v 1.14 1998/02/22 12:55:45 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@ -268,76 +268,87 @@ struct stringlist *ktolist;
|
|||||||
/*
|
/*
|
||||||
* function declarations
|
* function declarations
|
||||||
*/
|
*/
|
||||||
/*
|
/* ${MACHINE}.c */
|
||||||
addarc();
|
void findcall __P((nltype *, unsigned long, unsigned long));
|
||||||
*/
|
|
||||||
int arccmp();
|
/* arcs.c */
|
||||||
arctype *arclookup();
|
void addarc __P((nltype *, nltype *, long));
|
||||||
/*
|
int topcmp __P((const void *, const void *));
|
||||||
asgnsamples();
|
nltype **doarcs __P((void));
|
||||||
printblurb();
|
void dotime __P((void));
|
||||||
cyclelink();
|
void timepropagate __P((nltype *));
|
||||||
dfn();
|
void cyclelink __P((void));
|
||||||
*/
|
bool cycleanalyze __P((void));
|
||||||
bool dfn_busy();
|
bool descend __P((nltype *, arctype **, arctype **));
|
||||||
/*
|
bool addcycle __P((arctype **, arctype **));
|
||||||
dfn_findcycle();
|
void compresslist __P((void));
|
||||||
*/
|
void printsubcycle __P((cltype *));
|
||||||
bool dfn_numbered();
|
void cycletime __P((void));
|
||||||
/*
|
void doflags __P((void));
|
||||||
dfn_post_visit();
|
void inheritflags __P((nltype *));
|
||||||
dfn_pre_visit();
|
|
||||||
dfn_self_cycle();
|
/* dfn.c */
|
||||||
*/
|
void dfn_init __P((void));
|
||||||
nltype **doarcs();
|
void dfn __P((nltype *));
|
||||||
/*
|
void dfn_pre_visit __P((nltype *));
|
||||||
done();
|
bool dfn_numbered __P((nltype *));
|
||||||
findcalls();
|
bool dfn_busy __P((nltype *));
|
||||||
flatprofheader();
|
void dfn_findcycle __P((nltype *));
|
||||||
flatprofline();
|
void dfn_self_cycle __P((nltype *));
|
||||||
*/
|
void dfn_post_visit __P((nltype *));
|
||||||
bool funcsymbol();
|
|
||||||
/*
|
/* gprof.c */
|
||||||
getnfile();
|
int main __P((int, char **));
|
||||||
getpfile();
|
void getnfile __P((void));
|
||||||
getstrtab();
|
void getstrtab __P((FILE *));
|
||||||
getsymtab();
|
void getsymtab __P((FILE *));
|
||||||
gettextspace();
|
void gettextspace __P((FILE *));
|
||||||
gprofheader();
|
void getpfile __P((char *));
|
||||||
gprofline();
|
FILE *openpfile __P((char *));
|
||||||
main();
|
void tally __P((struct rawarc *));
|
||||||
*/
|
void dumpsum __P((char *));
|
||||||
unsigned long max();
|
int valcmp __P((const void *, const void *));
|
||||||
int membercmp();
|
void readsamples __P((FILE *));
|
||||||
unsigned long min();
|
void asgnsamples __P((void));
|
||||||
nltype *nllookup();
|
unsigned long min __P((unsigned long, unsigned long ));
|
||||||
FILE *openpfile();
|
unsigned long max __P((unsigned long, unsigned long ));
|
||||||
long operandlength();
|
void alignentries __P((void));
|
||||||
operandenum operandmode();
|
bool funcsymbol __P((struct nlist *));
|
||||||
char *operandname();
|
void done __P((void));
|
||||||
/*
|
|
||||||
printchildren();
|
/* hertz.c */
|
||||||
printcycle();
|
int hertz __P((void));
|
||||||
printgprof();
|
|
||||||
printmembers();
|
/* lookup.c */
|
||||||
printname();
|
nltype *nllookup __P((unsigned long));
|
||||||
printparents();
|
arctype *arclookup __P((nltype *, nltype *));
|
||||||
printprof();
|
|
||||||
readsamples();
|
/* printgprof.c */
|
||||||
*/
|
void printprof __P((void));
|
||||||
unsigned long reladdr();
|
int timecmp __P((const void *, const void *));
|
||||||
/*
|
void flatprofheader __P((void));
|
||||||
sortchildren();
|
void flatprofline __P((nltype *));
|
||||||
sortmembers();
|
void gprofheader __P((void));
|
||||||
sortparents();
|
void gprofline __P((nltype *));
|
||||||
tally();
|
void printgprof __P((nltype **));
|
||||||
timecmp();
|
int totalcmp __P((const void *, const void *));
|
||||||
topcmp();
|
void printparents __P((nltype *));
|
||||||
*/
|
void printchildren __P((nltype *));
|
||||||
int totalcmp();
|
void printname __P((nltype *));
|
||||||
/*
|
void sortchildren __P((nltype *));
|
||||||
valcmp();
|
void sortparents __P((nltype *));
|
||||||
*/
|
void printcycle __P((nltype *));
|
||||||
|
void printmembers __P((nltype *));
|
||||||
|
void sortmembers __P((nltype *));
|
||||||
|
int membercmp __P((const void *, const void *));
|
||||||
|
int arccmp __P((const void *, const void *));
|
||||||
|
void printblurb __P((char *));
|
||||||
|
int namecmp __P((const void *, const void *));
|
||||||
|
void printindex __P((void));
|
||||||
|
|
||||||
|
/* printlist.c */
|
||||||
|
void addlist __P((struct stringlist *, char *));
|
||||||
|
bool onlist __P((struct stringlist *, char *));
|
||||||
|
|
||||||
#define LESSTHAN -1
|
#define LESSTHAN -1
|
||||||
#define EQUALTO 0
|
#define EQUALTO 0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: hertz.c,v 1.5 1995/04/19 07:16:03 cgd Exp $ */
|
/* $NetBSD: hertz.c,v 1.6 1998/02/22 12:55:45 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@ -33,15 +33,17 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)hertz.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)hertz.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: hertz.c,v 1.5 1995/04/19 07:16:03 cgd Exp $";
|
__RCSID("$NetBSD: hertz.c,v 1.6 1998/02/22 12:55:45 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include "gprof.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* discover the tick frequency of the machine
|
* discover the tick frequency of the machine
|
||||||
@ -49,6 +51,7 @@ static char rcsid[] = "$NetBSD: hertz.c,v 1.5 1995/04/19 07:16:03 cgd Exp $";
|
|||||||
*/
|
*/
|
||||||
#define HZ_WRONG 0
|
#define HZ_WRONG 0
|
||||||
|
|
||||||
|
int
|
||||||
hertz()
|
hertz()
|
||||||
{
|
{
|
||||||
struct itimerval tim;
|
struct itimerval tim;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/* $NetBSD: i386.c,v 1.5 1995/04/19 07:16:04 cgd Exp $ */
|
/* $NetBSD: i386.c,v 1.6 1998/02/22 12:55:45 christos Exp $ */
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: i386.c,v 1.5 1995/04/19 07:16:04 cgd Exp $";
|
__RCSID("$NetBSD: i386.c,v 1.6 1998/02/22 12:55:45 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "gprof.h"
|
#include "gprof.h"
|
||||||
@ -9,6 +10,7 @@ static char rcsid[] = "$NetBSD: i386.c,v 1.5 1995/04/19 07:16:04 cgd Exp $";
|
|||||||
/*
|
/*
|
||||||
* gprof -c isn't currently supported...
|
* gprof -c isn't currently supported...
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
findcall( parentp , p_lowpc , p_highpc )
|
findcall( parentp , p_lowpc , p_highpc )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
unsigned long p_lowpc;
|
unsigned long p_lowpc;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: lookup.c,v 1.5 1995/04/19 07:16:06 cgd Exp $ */
|
/* $NetBSD: lookup.c,v 1.6 1998/02/22 12:55:45 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@ -33,11 +33,12 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)lookup.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)lookup.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: lookup.c,v 1.5 1995/04/19 07:16:06 cgd Exp $";
|
__RCSID("$NetBSD: lookup.c,v 1.6 1998/02/22 12:55:45 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -55,22 +56,22 @@ nllookup( address )
|
|||||||
register long low;
|
register long low;
|
||||||
register long middle;
|
register long middle;
|
||||||
register long high;
|
register long high;
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
register int probes;
|
register int probes;
|
||||||
|
|
||||||
probes = 0;
|
probes = 0;
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
for ( low = 0 , high = nname - 1 ; low != high ; ) {
|
for ( low = 0 , high = nname - 1 ; low != high ; ) {
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
probes += 1;
|
probes += 1;
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
middle = ( high + low ) >> 1;
|
middle = ( high + low ) >> 1;
|
||||||
if ( nl[ middle ].value <= address && nl[ middle+1 ].value > address ) {
|
if ( nl[ middle ].value <= address && nl[ middle+1 ].value > address ) {
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & LOOKUPDEBUG ) {
|
if ( debug & LOOKUPDEBUG ) {
|
||||||
printf( "[nllookup] %d (%d) probes\n" , probes , nname-1 );
|
printf( "[nllookup] %d (%d) probes\n" , probes , nname-1 );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
return &nl[ middle ];
|
return &nl[ middle ];
|
||||||
}
|
}
|
||||||
if ( nl[ middle ].value > address ) {
|
if ( nl[ middle ].value > address ) {
|
||||||
@ -79,12 +80,12 @@ nllookup( address )
|
|||||||
low = middle + 1;
|
low = middle + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & LOOKUPDEBUG ) {
|
if ( debug & LOOKUPDEBUG ) {
|
||||||
fprintf( stderr , "[nllookup] (%d) binary search fails\n" ,
|
fprintf( stderr , "[nllookup] (%d) binary search fails\n" ,
|
||||||
nname-1 );
|
nname-1 );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,20 +100,20 @@ arclookup( parentp , childp )
|
|||||||
fprintf( stderr, "[arclookup] parentp == 0 || childp == 0\n" );
|
fprintf( stderr, "[arclookup] parentp == 0 || childp == 0\n" );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & LOOKUPDEBUG ) {
|
if ( debug & LOOKUPDEBUG ) {
|
||||||
printf( "[arclookup] parent %s child %s\n" ,
|
printf( "[arclookup] parent %s child %s\n" ,
|
||||||
parentp -> name , childp -> name );
|
parentp -> name , childp -> name );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
for ( arcp = parentp -> children ; arcp ; arcp = arcp -> arc_childlist ) {
|
for ( arcp = parentp -> children ; arcp ; arcp = arcp -> arc_childlist ) {
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & LOOKUPDEBUG ) {
|
if ( debug & LOOKUPDEBUG ) {
|
||||||
printf( "[arclookup]\t arc_parent %s arc_child %s\n" ,
|
printf( "[arclookup]\t arc_parent %s arc_child %s\n" ,
|
||||||
arcp -> arc_parentp -> name ,
|
arcp -> arc_parentp -> name ,
|
||||||
arcp -> arc_childp -> name );
|
arcp -> arc_childp -> name );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
if ( arcp -> arc_childp == childp ) {
|
if ( arcp -> arc_childp == childp ) {
|
||||||
return arcp;
|
return arcp;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/* $NetBSD: m68k.c,v 1.4 1995/04/19 07:16:07 cgd Exp $ */
|
/* $NetBSD: m68k.c,v 1.5 1998/02/22 12:55:45 christos Exp $ */
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: m68k.c,v 1.4 1995/04/19 07:16:07 cgd Exp $";
|
__RCSID("$NetBSD: m68k.c,v 1.5 1998/02/22 12:55:45 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "gprof.h"
|
#include "gprof.h"
|
||||||
@ -9,6 +10,7 @@ static char rcsid[] = "$NetBSD: m68k.c,v 1.4 1995/04/19 07:16:07 cgd Exp $";
|
|||||||
/*
|
/*
|
||||||
* gprof -c isn't currently supported...
|
* gprof -c isn't currently supported...
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
findcall( parentp , p_lowpc , p_highpc )
|
findcall( parentp , p_lowpc , p_highpc )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
unsigned long p_lowpc;
|
unsigned long p_lowpc;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: mips.c,v 1.4 1995/04/19 07:16:11 cgd Exp $ */
|
/* $NetBSD: mips.c,v 1.5 1998/02/22 12:55:45 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -39,11 +39,12 @@
|
|||||||
* From: sparc.c 5.1 (Berkeley) 7/7/92
|
* From: sparc.c 5.1 (Berkeley) 7/7/92
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)mips.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)mips.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: mips.c,v 1.4 1995/04/19 07:16:11 cgd Exp $";
|
__RCSID("$NetBSD: mips.c,v 1.5 1998/02/22 12:55:45 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -76,6 +77,7 @@ nltype indirectchild = {
|
|||||||
(arctype *) 0 /* list of callee arcs */
|
(arctype *) 0 /* list of callee arcs */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
findcall(parentp, p_lowpc, p_highpc)
|
findcall(parentp, p_lowpc, p_highpc)
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
unsigned long p_lowpc;
|
unsigned long p_lowpc;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/* $NetBSD: ns32k.c,v 1.3 1995/04/19 07:16:13 cgd Exp $ */
|
/* $NetBSD: ns32k.c,v 1.4 1998/02/22 12:55:45 christos Exp $ */
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: ns32k.c,v 1.3 1995/04/19 07:16:13 cgd Exp $";
|
__RCSID("$NetBSD: ns32k.c,v 1.4 1998/02/22 12:55:45 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "gprof.h"
|
#include "gprof.h"
|
||||||
@ -9,6 +10,7 @@ static char rcsid[] = "$NetBSD: ns32k.c,v 1.3 1995/04/19 07:16:13 cgd Exp $";
|
|||||||
/*
|
/*
|
||||||
* gprof -c isn't currently supported...
|
* gprof -c isn't currently supported...
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
findcall( parentp , p_lowpc , p_highpc )
|
findcall( parentp , p_lowpc , p_highpc )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
unsigned long p_lowpc;
|
unsigned long p_lowpc;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: pmax.c,v 1.3 1995/04/19 07:16:18 cgd Exp $ */
|
/* $NetBSD: pmax.c,v 1.4 1998/02/22 12:55:45 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -39,11 +39,12 @@
|
|||||||
* From: sparc.c 5.1 (Berkeley) 7/7/92
|
* From: sparc.c 5.1 (Berkeley) 7/7/92
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)mips.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)mips.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: pmax.c,v 1.3 1995/04/19 07:16:18 cgd Exp $";
|
__RCSID("$NetBSD: pmax.c,v 1.4 1998/02/22 12:55:45 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -76,6 +77,7 @@ nltype indirectchild = {
|
|||||||
(arctype *) 0 /* list of callee arcs */
|
(arctype *) 0 /* list of callee arcs */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
findcall(parentp, p_lowpc, p_highpc)
|
findcall(parentp, p_lowpc, p_highpc)
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
unsigned long p_lowpc;
|
unsigned long p_lowpc;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: printgprof.c,v 1.6 1997/01/30 09:20:56 matthias Exp $ */
|
/* $NetBSD: printgprof.c,v 1.7 1998/02/22 12:55:46 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@ -33,22 +33,24 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)printgprof.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)printgprof.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: printgprof.c,v 1.6 1997/01/30 09:20:56 matthias Exp $";
|
__RCSID("$NetBSD: printgprof.c,v 1.7 1998/02/22 12:55:46 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "gprof.h"
|
#include "gprof.h"
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
|
|
||||||
|
void
|
||||||
printprof()
|
printprof()
|
||||||
{
|
{
|
||||||
register nltype *np;
|
register nltype *np;
|
||||||
nltype **sortednlp;
|
nltype **sortednlp;
|
||||||
int index, timecmp();
|
int index;
|
||||||
|
|
||||||
actime = 0.0;
|
actime = 0.0;
|
||||||
printf( "\f\n" );
|
printf( "\f\n" );
|
||||||
@ -72,9 +74,11 @@ printprof()
|
|||||||
free( sortednlp );
|
free( sortednlp );
|
||||||
}
|
}
|
||||||
|
|
||||||
timecmp( npp1 , npp2 )
|
int
|
||||||
nltype **npp1, **npp2;
|
timecmp( v1 , v2 )
|
||||||
|
const void *v1, *v2;
|
||||||
{
|
{
|
||||||
|
const nltype *const *npp1 = v1, *const *npp2 = v2;
|
||||||
double timediff;
|
double timediff;
|
||||||
long calldiff;
|
long calldiff;
|
||||||
|
|
||||||
@ -94,13 +98,14 @@ timecmp( npp1 , npp2 )
|
|||||||
/*
|
/*
|
||||||
* header for flatprofline
|
* header for flatprofline
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
flatprofheader()
|
flatprofheader()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( bflag ) {
|
if ( bflag ) {
|
||||||
printblurb( _PATH_FLAT_BLURB );
|
printblurb( _PATH_FLAT_BLURB );
|
||||||
}
|
}
|
||||||
printf( "\ngranularity: each sample hit covers %d byte(s)" ,
|
printf( "\ngranularity: each sample hit covers %ld byte(s)" ,
|
||||||
(long) scale * sizeof(UNIT) );
|
(long) scale * sizeof(UNIT) );
|
||||||
if ( totime > 0.0 ) {
|
if ( totime > 0.0 ) {
|
||||||
printf( " for %.2f%% of %.2f seconds\n\n" ,
|
printf( " for %.2f%% of %.2f seconds\n\n" ,
|
||||||
@ -119,6 +124,7 @@ flatprofheader()
|
|||||||
"ms/call" , "ms/call" , "name" );
|
"ms/call" , "ms/call" , "name" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
flatprofline( np )
|
flatprofline( np )
|
||||||
register nltype *np;
|
register nltype *np;
|
||||||
{
|
{
|
||||||
@ -132,7 +138,7 @@ flatprofline( np )
|
|||||||
printf( "%5.1f %10.2f %8.2f" ,
|
printf( "%5.1f %10.2f %8.2f" ,
|
||||||
100 * np -> time / totime , actime / hz , np -> time / hz );
|
100 * np -> time / totime , actime / hz , np -> time / hz );
|
||||||
if ( np -> ncall != 0 ) {
|
if ( np -> ncall != 0 ) {
|
||||||
printf( " %8d %8.2f %8.2f " , np -> ncall ,
|
printf( " %8ld %8.2f %8.2f " , np -> ncall ,
|
||||||
1000 * np -> time / hz / np -> ncall ,
|
1000 * np -> time / hz / np -> ncall ,
|
||||||
1000 * ( np -> time + np -> childtime ) / hz / np -> ncall );
|
1000 * ( np -> time + np -> childtime ) / hz / np -> ncall );
|
||||||
} else {
|
} else {
|
||||||
@ -142,13 +148,14 @@ flatprofline( np )
|
|||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
gprofheader()
|
gprofheader()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( bflag ) {
|
if ( bflag ) {
|
||||||
printblurb( _PATH_CALLG_BLURB );
|
printblurb( _PATH_CALLG_BLURB );
|
||||||
}
|
}
|
||||||
printf( "\ngranularity: each sample hit covers %d byte(s)" ,
|
printf( "\ngranularity: each sample hit covers %ld byte(s)" ,
|
||||||
(long) scale * sizeof(UNIT) );
|
(long) scale * sizeof(UNIT) );
|
||||||
if ( printtime > 0.0 ) {
|
if ( printtime > 0.0 ) {
|
||||||
printf( " for %.2f%% of %.2f seconds\n\n" ,
|
printf( " for %.2f%% of %.2f seconds\n\n" ,
|
||||||
@ -170,6 +177,7 @@ gprofheader()
|
|||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
gprofline( np )
|
gprofline( np )
|
||||||
register nltype *np;
|
register nltype *np;
|
||||||
{
|
{
|
||||||
@ -182,9 +190,9 @@ gprofline( np )
|
|||||||
np -> propself / hz ,
|
np -> propself / hz ,
|
||||||
np -> propchild / hz );
|
np -> propchild / hz );
|
||||||
if ( ( np -> ncall + np -> selfcalls ) != 0 ) {
|
if ( ( np -> ncall + np -> selfcalls ) != 0 ) {
|
||||||
printf( " %7d" , np -> npropcall );
|
printf( " %7ld" , np -> npropcall );
|
||||||
if ( np -> selfcalls != 0 ) {
|
if ( np -> selfcalls != 0 ) {
|
||||||
printf( "+%-7d " , np -> selfcalls );
|
printf( "+%-7ld " , np -> selfcalls );
|
||||||
} else {
|
} else {
|
||||||
printf( " %7.7s " , "" );
|
printf( " %7.7s " , "" );
|
||||||
}
|
}
|
||||||
@ -195,6 +203,7 @@ gprofline( np )
|
|||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
printgprof(timesortnlp)
|
printgprof(timesortnlp)
|
||||||
nltype **timesortnlp;
|
nltype **timesortnlp;
|
||||||
{
|
{
|
||||||
@ -244,12 +253,13 @@ printgprof(timesortnlp)
|
|||||||
* all else being equal, sort by names.
|
* all else being equal, sort by names.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
totalcmp( npp1 , npp2 )
|
totalcmp( v1 , v2 )
|
||||||
nltype **npp1;
|
const void *v1, *v2;
|
||||||
nltype **npp2;
|
|
||||||
{
|
{
|
||||||
register nltype *np1 = *npp1;
|
const nltype *const *npp1 = v1;
|
||||||
register nltype *np2 = *npp2;
|
const nltype *const *npp2 = v2;
|
||||||
|
const nltype *np1 = *npp1;
|
||||||
|
const nltype *np2 = *npp2;
|
||||||
double diff;
|
double diff;
|
||||||
|
|
||||||
diff = ( np1 -> propself + np1 -> propchild )
|
diff = ( np1 -> propself + np1 -> propchild )
|
||||||
@ -277,6 +287,7 @@ totalcmp( npp1 , npp2 )
|
|||||||
return strcmp( np1 -> name , np2 -> name );
|
return strcmp( np1 -> name , np2 -> name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
printparents( childp )
|
printparents( childp )
|
||||||
nltype *childp;
|
nltype *childp;
|
||||||
{
|
{
|
||||||
@ -302,7 +313,7 @@ printparents( childp )
|
|||||||
/*
|
/*
|
||||||
* selfcall or call among siblings
|
* selfcall or call among siblings
|
||||||
*/
|
*/
|
||||||
printf( "%6.6s %5.5s %7.7s %11.11s %7d %7.7s " ,
|
printf( "%6.6s %5.5s %7.7s %11.11s %7ld %7.7s " ,
|
||||||
"" , "" , "" , "" ,
|
"" , "" , "" , "" ,
|
||||||
arcp -> arc_count , "" );
|
arcp -> arc_count , "" );
|
||||||
printname( parentp );
|
printname( parentp );
|
||||||
@ -311,7 +322,7 @@ printparents( childp )
|
|||||||
/*
|
/*
|
||||||
* regular parent of child
|
* regular parent of child
|
||||||
*/
|
*/
|
||||||
printf( "%6.6s %5.5s %7.2f %11.2f %7d/%-7d " ,
|
printf( "%6.6s %5.5s %7.2f %11.2f %7ld/%-7ld " ,
|
||||||
"" , "" ,
|
"" , "" ,
|
||||||
arcp -> arc_time / hz , arcp -> arc_childtime / hz ,
|
arcp -> arc_time / hz , arcp -> arc_childtime / hz ,
|
||||||
arcp -> arc_count , cycleheadp -> npropcall );
|
arcp -> arc_count , cycleheadp -> npropcall );
|
||||||
@ -321,6 +332,7 @@ printparents( childp )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
printchildren( parentp )
|
printchildren( parentp )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
{
|
{
|
||||||
@ -336,7 +348,7 @@ printchildren( parentp )
|
|||||||
/*
|
/*
|
||||||
* self call or call to sibling
|
* self call or call to sibling
|
||||||
*/
|
*/
|
||||||
printf( "%6.6s %5.5s %7.7s %11.11s %7d %7.7s " ,
|
printf( "%6.6s %5.5s %7.7s %11.11s %7ld %7.7s " ,
|
||||||
"" , "" , "" , "" , arcp -> arc_count , "" );
|
"" , "" , "" , "" , arcp -> arc_count , "" );
|
||||||
printname( childp );
|
printname( childp );
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
@ -344,7 +356,7 @@ printchildren( parentp )
|
|||||||
/*
|
/*
|
||||||
* regular child of parent
|
* regular child of parent
|
||||||
*/
|
*/
|
||||||
printf( "%6.6s %5.5s %7.2f %11.2f %7d/%-7d " ,
|
printf( "%6.6s %5.5s %7.2f %11.2f %7ld/%-7ld " ,
|
||||||
"" , "" ,
|
"" , "" ,
|
||||||
arcp -> arc_time / hz , arcp -> arc_childtime / hz ,
|
arcp -> arc_time / hz , arcp -> arc_childtime / hz ,
|
||||||
arcp -> arc_count , childp -> cyclehead -> npropcall );
|
arcp -> arc_count , childp -> cyclehead -> npropcall );
|
||||||
@ -354,20 +366,21 @@ printchildren( parentp )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
printname( selfp )
|
printname( selfp )
|
||||||
nltype *selfp;
|
nltype *selfp;
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( selfp -> name != 0 ) {
|
if ( selfp -> name != 0 ) {
|
||||||
printf( "%s" , selfp -> name );
|
printf( "%s" , selfp -> name );
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & DFNDEBUG ) {
|
if ( debug & DFNDEBUG ) {
|
||||||
printf( "{%d} " , selfp -> toporder );
|
printf( "{%d} " , selfp -> toporder );
|
||||||
}
|
}
|
||||||
if ( debug & PROPDEBUG ) {
|
if ( debug & PROPDEBUG ) {
|
||||||
printf( "%5.2f%% " , selfp -> propfraction );
|
printf( "%5.2f%% " , selfp -> propfraction );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
if ( selfp -> cycleno != 0 ) {
|
if ( selfp -> cycleno != 0 ) {
|
||||||
printf( " <cycle %d>" , selfp -> cycleno );
|
printf( " <cycle %d>" , selfp -> cycleno );
|
||||||
@ -381,6 +394,7 @@ printname( selfp )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
sortchildren( parentp )
|
sortchildren( parentp )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
{
|
{
|
||||||
@ -398,9 +412,10 @@ sortchildren( parentp )
|
|||||||
* *prevp arc before the arc you are comparing.
|
* *prevp arc before the arc you are comparing.
|
||||||
*/
|
*/
|
||||||
sorted.arc_childlist = 0;
|
sorted.arc_childlist = 0;
|
||||||
for ( (arcp = parentp -> children)&&(detachedp = arcp -> arc_childlist);
|
for ((void) ((arcp = parentp->children) &&
|
||||||
arcp ;
|
(detachedp = arcp->arc_childlist));
|
||||||
(arcp = detachedp)&&(detachedp = detachedp -> arc_childlist)) {
|
arcp ;
|
||||||
|
(void) ((arcp = detachedp) && (detachedp = detachedp->arc_childlist))) {
|
||||||
/*
|
/*
|
||||||
* consider *arcp as disconnected
|
* consider *arcp as disconnected
|
||||||
* insert it into sorted
|
* insert it into sorted
|
||||||
@ -421,6 +436,7 @@ sortchildren( parentp )
|
|||||||
parentp -> children = sorted.arc_childlist;
|
parentp -> children = sorted.arc_childlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
sortparents( childp )
|
sortparents( childp )
|
||||||
nltype *childp;
|
nltype *childp;
|
||||||
{
|
{
|
||||||
@ -438,9 +454,10 @@ sortparents( childp )
|
|||||||
* *prevp arc before the arc you are comparing.
|
* *prevp arc before the arc you are comparing.
|
||||||
*/
|
*/
|
||||||
sorted.arc_parentlist = 0;
|
sorted.arc_parentlist = 0;
|
||||||
for ( (arcp = childp -> parents)&&(detachedp = arcp -> arc_parentlist);
|
for ((void) ((arcp = childp->parents) &&
|
||||||
arcp ;
|
(detachedp = arcp->arc_parentlist));
|
||||||
(arcp = detachedp)&&(detachedp = detachedp -> arc_parentlist)) {
|
arcp ;
|
||||||
|
(void) ((arcp = detachedp) && (detachedp = detachedp->arc_parentlist))){
|
||||||
/*
|
/*
|
||||||
* consider *arcp as disconnected
|
* consider *arcp as disconnected
|
||||||
* insert it into sorted
|
* insert it into sorted
|
||||||
@ -464,20 +481,21 @@ sortparents( childp )
|
|||||||
/*
|
/*
|
||||||
* print a cycle header
|
* print a cycle header
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
printcycle( cyclep )
|
printcycle( cyclep )
|
||||||
nltype *cyclep;
|
nltype *cyclep;
|
||||||
{
|
{
|
||||||
char kirkbuffer[ BUFSIZ ];
|
char kirkbuffer[ BUFSIZ ];
|
||||||
|
|
||||||
sprintf( kirkbuffer , "[%d]" , cyclep -> index );
|
sprintf( kirkbuffer , "[%d]" , cyclep -> index );
|
||||||
printf( "%-6.6s %5.1f %7.2f %11.2f %7d" ,
|
printf( "%-6.6s %5.1f %7.2f %11.2f %7ld" ,
|
||||||
kirkbuffer ,
|
kirkbuffer ,
|
||||||
100 * ( cyclep -> propself + cyclep -> propchild ) / printtime ,
|
100 * ( cyclep -> propself + cyclep -> propchild ) / printtime ,
|
||||||
cyclep -> propself / hz ,
|
cyclep -> propself / hz ,
|
||||||
cyclep -> propchild / hz ,
|
cyclep -> propchild / hz ,
|
||||||
cyclep -> npropcall );
|
cyclep -> npropcall );
|
||||||
if ( cyclep -> selfcalls != 0 ) {
|
if ( cyclep -> selfcalls != 0 ) {
|
||||||
printf( "+%-7d" , cyclep -> selfcalls );
|
printf( "+%-7ld" , cyclep -> selfcalls );
|
||||||
} else {
|
} else {
|
||||||
printf( " %7.7s" , "" );
|
printf( " %7.7s" , "" );
|
||||||
}
|
}
|
||||||
@ -488,6 +506,7 @@ printcycle( cyclep )
|
|||||||
/*
|
/*
|
||||||
* print the members of a cycle
|
* print the members of a cycle
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
printmembers( cyclep )
|
printmembers( cyclep )
|
||||||
nltype *cyclep;
|
nltype *cyclep;
|
||||||
{
|
{
|
||||||
@ -495,11 +514,11 @@ printmembers( cyclep )
|
|||||||
|
|
||||||
sortmembers( cyclep );
|
sortmembers( cyclep );
|
||||||
for ( memberp = cyclep -> cnext ; memberp ; memberp = memberp -> cnext ) {
|
for ( memberp = cyclep -> cnext ; memberp ; memberp = memberp -> cnext ) {
|
||||||
printf( "%6.6s %5.5s %7.2f %11.2f %7d" ,
|
printf( "%6.6s %5.5s %7.2f %11.2f %7ld" ,
|
||||||
"" , "" , memberp -> propself / hz , memberp -> propchild / hz ,
|
"" , "" , memberp -> propself / hz , memberp -> propchild / hz ,
|
||||||
memberp -> npropcall );
|
memberp -> npropcall );
|
||||||
if ( memberp -> selfcalls != 0 ) {
|
if ( memberp -> selfcalls != 0 ) {
|
||||||
printf( "+%-7d" , memberp -> selfcalls );
|
printf( "+%-7ld" , memberp -> selfcalls );
|
||||||
} else {
|
} else {
|
||||||
printf( " %7.7s" , "" );
|
printf( " %7.7s" , "" );
|
||||||
}
|
}
|
||||||
@ -512,6 +531,7 @@ printmembers( cyclep )
|
|||||||
/*
|
/*
|
||||||
* sort members of a cycle
|
* sort members of a cycle
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
sortmembers( cyclep )
|
sortmembers( cyclep )
|
||||||
nltype *cyclep;
|
nltype *cyclep;
|
||||||
{
|
{
|
||||||
@ -525,9 +545,9 @@ sortmembers( cyclep )
|
|||||||
*/
|
*/
|
||||||
todo = cyclep -> cnext;
|
todo = cyclep -> cnext;
|
||||||
cyclep -> cnext = 0;
|
cyclep -> cnext = 0;
|
||||||
for ( (doing = todo)&&(todo = doing -> cnext);
|
for ((void) ((doing = todo) && (todo = doing->cnext));
|
||||||
doing ;
|
doing;
|
||||||
(doing = todo )&&(todo = doing -> cnext )){
|
(void) ((doing = todo ) && (todo = doing->cnext))) {
|
||||||
for ( prev = cyclep ; prev -> cnext ; prev = prev -> cnext ) {
|
for ( prev = cyclep ; prev -> cnext ; prev = prev -> cnext ) {
|
||||||
if ( membercmp( doing , prev -> cnext ) == GREATERTHAN ) {
|
if ( membercmp( doing , prev -> cnext ) == GREATERTHAN ) {
|
||||||
break;
|
break;
|
||||||
@ -543,10 +563,11 @@ sortmembers( cyclep )
|
|||||||
* next is sort on ncalls + selfcalls.
|
* next is sort on ncalls + selfcalls.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
membercmp( this , that )
|
membercmp( v1 , v2 )
|
||||||
nltype *this;
|
const void *v1, *v2;
|
||||||
nltype *that;
|
|
||||||
{
|
{
|
||||||
|
const nltype *this = v1;
|
||||||
|
const nltype *that = v2;
|
||||||
double thistime = this -> propself + this -> propchild;
|
double thistime = this -> propself + this -> propchild;
|
||||||
double thattime = that -> propself + that -> propchild;
|
double thattime = that -> propself + that -> propchild;
|
||||||
long thiscalls = this -> ncall + this -> selfcalls;
|
long thiscalls = this -> ncall + this -> selfcalls;
|
||||||
@ -576,10 +597,11 @@ membercmp( this , that )
|
|||||||
* arc count as minor key
|
* arc count as minor key
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
arccmp( thisp , thatp )
|
arccmp( v1 , v2 )
|
||||||
arctype *thisp;
|
const void *v1, *v2;
|
||||||
arctype *thatp;
|
|
||||||
{
|
{
|
||||||
|
const arctype *thisp = v1;
|
||||||
|
const arctype *thatp = v2;
|
||||||
nltype *thisparentp = thisp -> arc_parentp;
|
nltype *thisparentp = thisp -> arc_parentp;
|
||||||
nltype *thischildp = thisp -> arc_childp;
|
nltype *thischildp = thisp -> arc_childp;
|
||||||
nltype *thatparentp = thatp -> arc_parentp;
|
nltype *thatparentp = thatp -> arc_parentp;
|
||||||
@ -587,7 +609,7 @@ arccmp( thisp , thatp )
|
|||||||
double thistime;
|
double thistime;
|
||||||
double thattime;
|
double thattime;
|
||||||
|
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & TIMEDEBUG ) {
|
if ( debug & TIMEDEBUG ) {
|
||||||
printf( "[arccmp] " );
|
printf( "[arccmp] " );
|
||||||
printname( thisparentp );
|
printname( thisparentp );
|
||||||
@ -605,7 +627,7 @@ arccmp( thisp , thatp )
|
|||||||
thatp -> arc_count , thatchildp -> ncall );
|
thatp -> arc_count , thatchildp -> ncall );
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
if ( thisparentp == thischildp ) {
|
if ( thisparentp == thischildp ) {
|
||||||
/* this is a self call */
|
/* this is a self call */
|
||||||
return LESSTHAN;
|
return LESSTHAN;
|
||||||
@ -654,6 +676,7 @@ arccmp( thisp , thatp )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
printblurb( blurbname )
|
printblurb( blurbname )
|
||||||
char *blurbname;
|
char *blurbname;
|
||||||
{
|
{
|
||||||
@ -672,12 +695,14 @@ printblurb( blurbname )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
namecmp( npp1 , npp2 )
|
namecmp( v1 , v2 )
|
||||||
nltype **npp1, **npp2;
|
const void *v1, *v2;
|
||||||
{
|
{
|
||||||
|
const nltype *const *npp1 = v1, *const *npp2 = v2;
|
||||||
return( strcmp( (*npp1) -> name , (*npp2) -> name ) );
|
return( strcmp( (*npp1) -> name , (*npp2) -> name ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
printindex()
|
printindex()
|
||||||
{
|
{
|
||||||
nltype **namesortnlp;
|
nltype **namesortnlp;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: printlist.c,v 1.5 1995/04/19 07:16:23 cgd Exp $ */
|
/* $NetBSD: printlist.c,v 1.6 1998/02/22 12:55:46 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@ -33,11 +33,12 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)printlist.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)printlist.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: printlist.c,v 1.5 1995/04/19 07:16:23 cgd Exp $";
|
__RCSID("$NetBSD: printlist.c,v 1.6 1998/02/22 12:55:46 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -62,6 +63,7 @@ struct stringlist *elist = &ehead;
|
|||||||
struct stringlist Ehead = { 0 , 0 };
|
struct stringlist Ehead = { 0 , 0 };
|
||||||
struct stringlist *Elist = &Ehead;
|
struct stringlist *Elist = &Ehead;
|
||||||
|
|
||||||
|
void
|
||||||
addlist( listp , funcname )
|
addlist( listp , funcname )
|
||||||
struct stringlist *listp;
|
struct stringlist *listp;
|
||||||
char *funcname;
|
char *funcname;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: sparc.c,v 1.4 1995/04/19 07:16:24 cgd Exp $ */
|
/* $NetBSD: sparc.c,v 1.5 1998/02/22 12:55:46 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
@ -37,11 +37,12 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)sparc.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)sparc.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: sparc.c,v 1.4 1995/04/19 07:16:24 cgd Exp $";
|
__RCSID("$NetBSD: sparc.c,v 1.5 1998/02/22 12:55:46 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -74,6 +75,7 @@ nltype indirectchild = {
|
|||||||
(arctype *) 0 /* list of callee arcs */
|
(arctype *) 0 /* list of callee arcs */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
findcall(parentp, p_lowpc, p_highpc)
|
findcall(parentp, p_lowpc, p_highpc)
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
unsigned long p_lowpc;
|
unsigned long p_lowpc;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: tahoe.c,v 1.5 1995/04/19 07:16:27 cgd Exp $ */
|
/* $NetBSD: tahoe.c,v 1.6 1998/02/22 12:55:46 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@ -33,11 +33,12 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)tahoe.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)tahoe.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: tahoe.c,v 1.5 1995/04/19 07:16:27 cgd Exp $";
|
__RCSID("$NetBSD: tahoe.c,v 1.6 1998/02/22 12:55:46 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -67,6 +68,12 @@ nltype indirectchild = {
|
|||||||
(arctype *) 0 /* list of callee arcs */
|
(arctype *) 0 /* list of callee arcs */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
operandenum operandmode __P((unsigned char *));
|
||||||
|
char *operandname __P((operandenum));
|
||||||
|
long operandlength __P((unsigned char *));
|
||||||
|
unsigned long reladdr __P((char *));
|
||||||
|
|
||||||
operandenum
|
operandenum
|
||||||
operandmode( modep )
|
operandmode( modep )
|
||||||
unsigned char *modep;
|
unsigned char *modep;
|
||||||
@ -225,6 +232,7 @@ reladdr( modep )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
findcall( parentp , p_lowpc , p_highpc )
|
findcall( parentp , p_lowpc , p_highpc )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
unsigned long p_lowpc;
|
unsigned long p_lowpc;
|
||||||
@ -246,12 +254,12 @@ findcall( parentp , p_lowpc , p_highpc )
|
|||||||
if ( p_highpc > s_highpc ) {
|
if ( p_highpc > s_highpc ) {
|
||||||
p_highpc = s_highpc;
|
p_highpc = s_highpc;
|
||||||
}
|
}
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & CALLDEBUG ) {
|
if ( debug & CALLDEBUG ) {
|
||||||
printf( "[findcall] %s: 0x%x to 0x%x\n" ,
|
printf( "[findcall] %s: 0x%x to 0x%x\n" ,
|
||||||
parentp -> name , p_lowpc , p_highpc );
|
parentp -> name , p_lowpc , p_highpc );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
for ( instructp = textspace + p_lowpc ;
|
for ( instructp = textspace + p_lowpc ;
|
||||||
instructp < textspace + p_highpc ;
|
instructp < textspace + p_highpc ;
|
||||||
instructp += length ) {
|
instructp += length ) {
|
||||||
@ -261,11 +269,11 @@ findcall( parentp , p_lowpc , p_highpc )
|
|||||||
* maybe a callf, better check it out.
|
* maybe a callf, better check it out.
|
||||||
* skip the count of the number of arguments.
|
* skip the count of the number of arguments.
|
||||||
*/
|
*/
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & CALLDEBUG ) {
|
if ( debug & CALLDEBUG ) {
|
||||||
printf( "[findcall]\t0x%x:callf" , instructp - textspace );
|
printf( "[findcall]\t0x%x:callf" , instructp - textspace );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
firstmode = operandmode( instructp+length );
|
firstmode = operandmode( instructp+length );
|
||||||
switch ( firstmode ) {
|
switch ( firstmode ) {
|
||||||
case literal:
|
case literal:
|
||||||
@ -276,12 +284,12 @@ findcall( parentp , p_lowpc , p_highpc )
|
|||||||
}
|
}
|
||||||
length += operandlength( instructp+length );
|
length += operandlength( instructp+length );
|
||||||
mode = operandmode( instructp + length );
|
mode = operandmode( instructp + length );
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & CALLDEBUG ) {
|
if ( debug & CALLDEBUG ) {
|
||||||
printf( "\tfirst operand is %s", operandname( firstmode ) );
|
printf( "\tfirst operand is %s", operandname( firstmode ) );
|
||||||
printf( "\tsecond operand is %s\n" , operandname( mode ) );
|
printf( "\tsecond operand is %s\n" , operandname( mode ) );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
switch ( mode ) {
|
switch ( mode ) {
|
||||||
case regdef:
|
case regdef:
|
||||||
case bytedispdef:
|
case bytedispdef:
|
||||||
@ -313,14 +321,14 @@ findcall( parentp , p_lowpc , p_highpc )
|
|||||||
- (unsigned long) textspace;
|
- (unsigned long) textspace;
|
||||||
if ( destpc >= s_lowpc && destpc <= s_highpc ) {
|
if ( destpc >= s_lowpc && destpc <= s_highpc ) {
|
||||||
childp = nllookup( destpc );
|
childp = nllookup( destpc );
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & CALLDEBUG ) {
|
if ( debug & CALLDEBUG ) {
|
||||||
printf( "[findcall]\tdestpc 0x%x" , destpc );
|
printf( "[findcall]\tdestpc 0x%x" , destpc );
|
||||||
printf( " childp->name %s" , childp -> name );
|
printf( " childp->name %s" , childp -> name );
|
||||||
printf( " childp->value 0x%x\n" ,
|
printf( " childp->value 0x%x\n" ,
|
||||||
childp -> value );
|
childp -> value );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
if ( childp -> value == destpc ) {
|
if ( childp -> value == destpc ) {
|
||||||
/*
|
/*
|
||||||
* a hit
|
* a hit
|
||||||
@ -342,11 +350,11 @@ findcall( parentp , p_lowpc , p_highpc )
|
|||||||
/*
|
/*
|
||||||
* something funny going on.
|
* something funny going on.
|
||||||
*/
|
*/
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & CALLDEBUG ) {
|
if ( debug & CALLDEBUG ) {
|
||||||
printf( "[findcall]\tbut it's a botch\n" );
|
printf( "[findcall]\tbut it's a botch\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
length = 1;
|
length = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: vax.c,v 1.6 1996/04/20 14:56:37 ragge Exp $ */
|
/* $NetBSD: vax.c,v 1.7 1998/02/22 12:55:46 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@ -33,11 +33,12 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)vax.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)vax.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: vax.c,v 1.6 1996/04/20 14:56:37 ragge Exp $";
|
__RCSID("$NetBSD: vax.c,v 1.7 1998/02/22 12:55:46 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -70,6 +71,12 @@ nltype indirectchild = {
|
|||||||
(arctype *) 0 /* list of callee arcs */
|
(arctype *) 0 /* list of callee arcs */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
operandenum operandmode __P((unsigned char *));
|
||||||
|
char *operandname __P((operandenum));
|
||||||
|
long operandlength __P((unsigned char *));
|
||||||
|
unsigned long reladdr __P((char *));
|
||||||
|
|
||||||
operandenum
|
operandenum
|
||||||
operandmode( modep )
|
operandmode( modep )
|
||||||
struct modebyte *modep;
|
struct modebyte *modep;
|
||||||
@ -224,6 +231,7 @@ reladdr( modep )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
findcall( parentp , p_lowpc , p_highpc )
|
findcall( parentp , p_lowpc , p_highpc )
|
||||||
nltype *parentp;
|
nltype *parentp;
|
||||||
unsigned long p_lowpc;
|
unsigned long p_lowpc;
|
||||||
@ -245,12 +253,12 @@ findcall( parentp , p_lowpc , p_highpc )
|
|||||||
if ( p_highpc > s_highpc ) {
|
if ( p_highpc > s_highpc ) {
|
||||||
p_highpc = s_highpc;
|
p_highpc = s_highpc;
|
||||||
}
|
}
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & CALLDEBUG ) {
|
if ( debug & CALLDEBUG ) {
|
||||||
printf( "[findcall] %s: 0x%x to 0x%x\n" ,
|
printf( "[findcall] %s: 0x%x to 0x%x\n" ,
|
||||||
parentp -> name , p_lowpc , p_highpc );
|
parentp -> name , p_lowpc , p_highpc );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
for ( instructp = textspace + p_lowpc ;
|
for ( instructp = textspace + p_lowpc ;
|
||||||
instructp < textspace + p_highpc ;
|
instructp < textspace + p_highpc ;
|
||||||
instructp += length ) {
|
instructp += length ) {
|
||||||
@ -260,11 +268,11 @@ findcall( parentp , p_lowpc , p_highpc )
|
|||||||
* maybe a calls, better check it out.
|
* maybe a calls, better check it out.
|
||||||
* skip the count of the number of arguments.
|
* skip the count of the number of arguments.
|
||||||
*/
|
*/
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & CALLDEBUG ) {
|
if ( debug & CALLDEBUG ) {
|
||||||
printf( "[findcall]\t0x%x:calls" , instructp - textspace );
|
printf( "[findcall]\t0x%x:calls" , instructp - textspace );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
firstmode = operandmode( (struct modebyte *) (instructp+length) );
|
firstmode = operandmode( (struct modebyte *) (instructp+length) );
|
||||||
switch ( firstmode ) {
|
switch ( firstmode ) {
|
||||||
case literal:
|
case literal:
|
||||||
@ -275,12 +283,12 @@ findcall( parentp , p_lowpc , p_highpc )
|
|||||||
}
|
}
|
||||||
length += operandlength( (struct modebyte *) (instructp+length) );
|
length += operandlength( (struct modebyte *) (instructp+length) );
|
||||||
mode = operandmode( (struct modebyte *) ( instructp + length ) );
|
mode = operandmode( (struct modebyte *) ( instructp + length ) );
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & CALLDEBUG ) {
|
if ( debug & CALLDEBUG ) {
|
||||||
printf( "\tfirst operand is %s", operandname( firstmode ) );
|
printf( "\tfirst operand is %s", operandname( firstmode ) );
|
||||||
printf( "\tsecond operand is %s\n" , operandname( mode ) );
|
printf( "\tsecond operand is %s\n" , operandname( mode ) );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
switch ( mode ) {
|
switch ( mode ) {
|
||||||
case regdef:
|
case regdef:
|
||||||
case bytedispdef:
|
case bytedispdef:
|
||||||
@ -313,14 +321,14 @@ findcall( parentp , p_lowpc , p_highpc )
|
|||||||
- (unsigned long) textspace;
|
- (unsigned long) textspace;
|
||||||
if ( destpc >= s_lowpc && destpc <= s_highpc ) {
|
if ( destpc >= s_lowpc && destpc <= s_highpc ) {
|
||||||
childp = nllookup( destpc );
|
childp = nllookup( destpc );
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & CALLDEBUG ) {
|
if ( debug & CALLDEBUG ) {
|
||||||
printf( "[findcall]\tdestpc 0x%x" , destpc );
|
printf( "[findcall]\tdestpc 0x%x" , destpc );
|
||||||
printf( " childp->name %s" , childp -> name );
|
printf( " childp->name %s" , childp -> name );
|
||||||
printf( " childp->value 0x%x\n" ,
|
printf( " childp->value 0x%x\n" ,
|
||||||
childp -> value );
|
childp -> value );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
if ( childp -> value == destpc ) {
|
if ( childp -> value == destpc ) {
|
||||||
/*
|
/*
|
||||||
* a hit
|
* a hit
|
||||||
@ -343,11 +351,11 @@ findcall( parentp , p_lowpc , p_highpc )
|
|||||||
/*
|
/*
|
||||||
* something funny going on.
|
* something funny going on.
|
||||||
*/
|
*/
|
||||||
# ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( debug & CALLDEBUG ) {
|
if ( debug & CALLDEBUG ) {
|
||||||
printf( "[findcall]\tbut it's a botch\n" );
|
printf( "[findcall]\tbut it's a botch\n" );
|
||||||
}
|
}
|
||||||
# endif DEBUG
|
#endif /* DEBUG */
|
||||||
length = 1;
|
length = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# $NetBSD: Makefile,v 1.4 1997/10/19 14:05:48 lukem Exp $
|
# $NetBSD: Makefile,v 1.5 1998/02/22 13:33:48 christos Exp $
|
||||||
|
|
||||||
WARNS= 0
|
|
||||||
PROG= patch
|
PROG= patch
|
||||||
SRCS= patch.c pch.c inp.c version.c util.c backupfile.c
|
SRCS= patch.c pch.c inp.c version.c util.c backupfile.c
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: backupfile.c,v 1.4 1996/09/19 06:27:07 thorpej Exp $ */
|
/* $NetBSD: backupfile.c,v 1.5 1998/02/22 13:33:48 christos Exp $ */
|
||||||
|
|
||||||
/* backupfile.c -- make Emacs style backup file names
|
/* backupfile.c -- make Emacs style backup file names
|
||||||
Copyright (C) 1990 Free Software Foundation, Inc.
|
Copyright (C) 1990 Free Software Foundation, Inc.
|
||||||
@ -13,8 +13,9 @@
|
|||||||
/* David MacKenzie <djm@ai.mit.edu>.
|
/* David MacKenzie <djm@ai.mit.edu>.
|
||||||
Some algorithms adapted from GNU Emacs. */
|
Some algorithms adapted from GNU Emacs. */
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: backupfile.c,v 1.4 1996/09/19 06:27:07 thorpej Exp $";
|
__RCSID("$NetBSD: backupfile.c,v 1.5 1998/02/22 13:33:48 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -72,13 +73,17 @@ enum backup_type backup_type = none;
|
|||||||
to numbered) backup file name. */
|
to numbered) backup file name. */
|
||||||
char *simple_backup_suffix = "~";
|
char *simple_backup_suffix = "~";
|
||||||
|
|
||||||
char *basename ();
|
/* backupfile.c */
|
||||||
char *dirname ();
|
char *find_backup_file_name __P((char *));
|
||||||
static char *concat ();
|
static int max_backup_version __P((char *, char *));
|
||||||
char *find_backup_file_name ();
|
static char *make_version_name __P((char *, int));
|
||||||
static char *make_version_name ();
|
static int version_number __P((char *, char *, int));
|
||||||
static int max_backup_version ();
|
static char *concat __P((char *, char *));
|
||||||
static int version_number ();
|
char *basename __P((char *));
|
||||||
|
char *dirname __P((char *));
|
||||||
|
int argmatch __P((char *, char **));
|
||||||
|
void invalid_arg __P((char *, char *, int));
|
||||||
|
enum backup_type get_version __P((char *));
|
||||||
|
|
||||||
#ifndef NODIR
|
#ifndef NODIR
|
||||||
/* Return the name of the new backup file for file FILE,
|
/* Return the name of the new backup file for file FILE,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: common.h,v 1.7 1997/11/22 22:27:12 augustss Exp $ */
|
/* $NetBSD: common.h,v 1.8 1998/02/22 13:33:48 christos Exp $ */
|
||||||
|
|
||||||
#define DEBUGGING
|
#define DEBUGGING
|
||||||
|
|
||||||
@ -158,6 +158,7 @@ EXT char *revision INIT(Nullch); /* prerequisite revision, if any */
|
|||||||
extern int errno;
|
extern int errno;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __STDC__
|
||||||
FILE *popen();
|
FILE *popen();
|
||||||
char *malloc();
|
char *malloc();
|
||||||
char *realloc();
|
char *realloc();
|
||||||
@ -173,6 +174,7 @@ char *sprintf();
|
|||||||
int sprintf();
|
int sprintf();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(S_ISDIR) && defined(S_IFDIR)
|
#if !defined(S_ISDIR) && defined(S_IFDIR)
|
||||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||||
@ -180,3 +182,6 @@ int sprintf();
|
|||||||
#if !defined(S_ISREG) && defined(S_IFREG)
|
#if !defined(S_ISREG) && defined(S_IFREG)
|
||||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void my_exit __P((int)) __attribute__((__noreturn__));
|
||||||
|
char *basename __P((char *));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: config.h,v 1.3 1996/09/19 06:27:09 thorpej Exp $ */
|
/* $NetBSD: config.h,v 1.4 1998/02/22 13:33:49 christos Exp $ */
|
||||||
|
|
||||||
/* config.h
|
/* config.h
|
||||||
* This file was produced by running the config.h.SH script, which
|
* This file was produced by running the config.h.SH script, which
|
||||||
@ -22,8 +22,8 @@
|
|||||||
* This symbol, if defined, indicates that the program is running under
|
* This symbol, if defined, indicates that the program is running under
|
||||||
* VMS. It is currently only set in conjunction with the EUNICE symbol.
|
* VMS. It is currently only set in conjunction with the EUNICE symbol.
|
||||||
*/
|
*/
|
||||||
#/*undef EUNICE /**/
|
#undef EUNICE
|
||||||
#/*undef VMS /**/
|
#undef VMS
|
||||||
|
|
||||||
/* CPPSTDIN:
|
/* CPPSTDIN:
|
||||||
* This symbol contains the first part of the string which will invoke
|
* This symbol contains the first part of the string which will invoke
|
||||||
@ -45,13 +45,13 @@
|
|||||||
* is up to the package author to declare sprintf correctly based on the
|
* is up to the package author to declare sprintf correctly based on the
|
||||||
* symbol.
|
* symbol.
|
||||||
*/
|
*/
|
||||||
/* # CHARSPRINTF /**/
|
#undef CHARSPRINTF
|
||||||
|
|
||||||
/* FLEXFILENAMES:
|
/* FLEXFILENAMES:
|
||||||
* This symbol, if defined, indicates that the system supports filenames
|
* This symbol, if defined, indicates that the system supports filenames
|
||||||
* longer than 14 characters.
|
* longer than 14 characters.
|
||||||
*/
|
*/
|
||||||
#define FLEXFILENAMES /**/
|
#define FLEXFILENAMES
|
||||||
|
|
||||||
/* index:
|
/* index:
|
||||||
* This preprocessor symbol is defined, along with rindex, if the system
|
* This preprocessor symbol is defined, along with rindex, if the system
|
||||||
@ -61,8 +61,10 @@
|
|||||||
* This preprocessor symbol is defined, along with index, if the system
|
* This preprocessor symbol is defined, along with index, if the system
|
||||||
* uses the strchr and strrchr routines instead.
|
* uses the strchr and strrchr routines instead.
|
||||||
*/
|
*/
|
||||||
#/*undef index strchr /* cultural */
|
#if 0
|
||||||
#/*undef rindex strrchr /* differences? */
|
#define index strchr /* cultural */
|
||||||
|
#define rindex strrchr /* differences? */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* VOIDSIG:
|
/* VOIDSIG:
|
||||||
* This symbol is defined if this system declares "void (*signal())()" in
|
* This symbol is defined if this system declares "void (*signal())()" in
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
/* $NetBSD: inp.c,v 1.4 1998/02/22 13:33:49 christos Exp $ */
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: inp.c,v 1.3 1996/09/19 06:27:10 thorpej Exp $";
|
__RCSID("$NetBSD: inp.c,v 1.4 1998/02/22 13:33:49 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "EXTERN.h"
|
#include "EXTERN.h"
|
||||||
@ -9,6 +11,10 @@ static char rcsid[] = "$NetBSD: inp.c,v 1.3 1996/09/19 06:27:10 thorpej Exp $";
|
|||||||
#include "INTERN.h"
|
#include "INTERN.h"
|
||||||
#include "inp.h"
|
#include "inp.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
/* Input-file-with-indexable-lines abstract type */
|
/* Input-file-with-indexable-lines abstract type */
|
||||||
|
|
||||||
static long i_size; /* size of the input file */
|
static long i_size; /* size of the input file */
|
||||||
@ -102,8 +108,9 @@ char *filename;
|
|||||||
strncpy(s, filename, pathlen);
|
strncpy(s, filename, pathlen);
|
||||||
|
|
||||||
#define try(f, a1, a2) (Sprintf(s + pathlen, f, a1, a2), stat(s, &cstat) == 0)
|
#define try(f, a1, a2) (Sprintf(s + pathlen, f, a1, a2), stat(s, &cstat) == 0)
|
||||||
|
#define try1(f, a1) (Sprintf(s + pathlen, f, a1), stat(s, &cstat) == 0)
|
||||||
if ( try("RCS/%s%s", filebase, RCSSUFFIX)
|
if ( try("RCS/%s%s", filebase, RCSSUFFIX)
|
||||||
|| try("RCS/%s" , filebase, 0)
|
|| try1("RCS/%s" , filebase)
|
||||||
|| try( "%s%s", filebase, RCSSUFFIX)) {
|
|| try( "%s%s", filebase, RCSSUFFIX)) {
|
||||||
Sprintf(buf, CHECKOUT, filename);
|
Sprintf(buf, CHECKOUT, filename);
|
||||||
Sprintf(lbuf, RCSDIFF, filename);
|
Sprintf(lbuf, RCSDIFF, filename);
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
/* $NetBSD: inp.h,v 1.3 1996/09/19 06:27:10 thorpej Exp $ */
|
/* $NetBSD: inp.h,v 1.4 1998/02/22 13:33:49 christos Exp $ */
|
||||||
|
|
||||||
EXT LINENUM input_lines INIT(0); /* how long is input file in lines */
|
EXT LINENUM input_lines INIT(0); /* how long is input file in lines */
|
||||||
EXT LINENUM last_frozen_line INIT(0); /* how many input lines have been */
|
EXT LINENUM last_frozen_line INIT(0); /* how many input lines have been */
|
||||||
/* irretractibly output */
|
/* irretractibly output */
|
||||||
|
void re_input __P((void));
|
||||||
bool rev_in_string();
|
void scan_input __P((char *));
|
||||||
void scan_input();
|
bool plan_a __P((char *));
|
||||||
bool plan_a(); /* returns false if insufficient memory */
|
void plan_b __P((char *));
|
||||||
void plan_b();
|
char *ifetch __P((Reg1 LINENUM, int));
|
||||||
char *ifetch();
|
bool rev_in_string __P((char *));
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: patch.c,v 1.5 1997/03/22 03:38:06 lukem Exp $ */
|
/* $NetBSD: patch.c,v 1.6 1998/02/22 13:33:49 christos Exp $ */
|
||||||
|
|
||||||
/* patch - a program to apply diffs to original files
|
/* patch - a program to apply diffs to original files
|
||||||
*
|
*
|
||||||
@ -8,8 +8,9 @@
|
|||||||
* money off of it, or pretend that you wrote it.
|
* money off of it, or pretend that you wrote it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: patch.c,v 1.5 1997/03/22 03:38:06 lukem Exp $";
|
__RCSID("$NetBSD: patch.c,v 1.6 1998/02/22 13:33:49 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "INTERN.h"
|
#include "INTERN.h"
|
||||||
@ -22,23 +23,27 @@ static char rcsid[] = "$NetBSD: patch.c,v 1.5 1997/03/22 03:38:06 lukem Exp $";
|
|||||||
#include "backupfile.h"
|
#include "backupfile.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int main __P((int, char **));
|
||||||
|
|
||||||
/* procedures */
|
/* procedures */
|
||||||
|
static void reinitialize_almost_everything __P((void));
|
||||||
void reinitialize_almost_everything();
|
static char *nextarg __P((void));
|
||||||
void get_some_switches();
|
struct option;
|
||||||
LINENUM locate_hunk();
|
static int optcmp __P((const void *, const void *));
|
||||||
void abort_hunk();
|
static char decode_long_option __P((char *));
|
||||||
void apply_hunk();
|
static void get_some_switches __P((void));
|
||||||
void init_output();
|
static LINENUM locate_hunk __P((LINENUM));
|
||||||
void init_reject();
|
static void abort_hunk __P((void));
|
||||||
void copy_till();
|
static void apply_hunk __P((LINENUM));
|
||||||
void spew_output();
|
static void init_output __P((char *));
|
||||||
void dump_line();
|
static void init_reject __P((char *));
|
||||||
bool patch_match();
|
static void copy_till __P((Reg1 LINENUM));
|
||||||
bool similar();
|
static void spew_output __P((void));
|
||||||
void re_input();
|
static void dump_line __P((LINENUM));
|
||||||
void my_exit();
|
static bool patch_match __P((LINENUM, LINENUM, LINENUM));
|
||||||
|
static bool similar __P((Reg1 char *, Reg2 char *, Reg3 int));
|
||||||
|
|
||||||
/* TRUE if -E was specified on command line. */
|
/* TRUE if -E was specified on command line. */
|
||||||
static int remove_empty_files = FALSE;
|
static int remove_empty_files = FALSE;
|
||||||
@ -53,7 +58,7 @@ main(argc,argv)
|
|||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
LINENUM where;
|
LINENUM where = 0;
|
||||||
LINENUM newwhere;
|
LINENUM newwhere;
|
||||||
LINENUM fuzz;
|
LINENUM fuzz;
|
||||||
LINENUM mymaxfuzz;
|
LINENUM mymaxfuzz;
|
||||||
@ -333,7 +338,7 @@ char **argv;
|
|||||||
|
|
||||||
/* Prepare to find the next patch to do in the patch file. */
|
/* Prepare to find the next patch to do in the patch file. */
|
||||||
|
|
||||||
void
|
static void
|
||||||
reinitialize_almost_everything()
|
reinitialize_almost_everything()
|
||||||
{
|
{
|
||||||
re_patch();
|
re_patch();
|
||||||
@ -386,16 +391,17 @@ struct option {
|
|||||||
char short_opt;
|
char short_opt;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
static int
|
||||||
optcmp(a, b)
|
optcmp(va, vb)
|
||||||
struct option *a, *b;
|
const void *va, *vb;
|
||||||
{
|
{
|
||||||
|
const struct option *a = va, *b = vb;
|
||||||
return strcmp (a->long_opt, b->long_opt);
|
return strcmp (a->long_opt, b->long_opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decode Long options beginning with "--" to their short equivalents. */
|
/* Decode Long options beginning with "--" to their short equivalents. */
|
||||||
|
|
||||||
char
|
static char
|
||||||
decode_long_option(opt)
|
decode_long_option(opt)
|
||||||
char *opt;
|
char *opt;
|
||||||
{
|
{
|
||||||
@ -442,7 +448,7 @@ decode_long_option(opt)
|
|||||||
|
|
||||||
/* Process switches and filenames up to next '+' or end of list. */
|
/* Process switches and filenames up to next '+' or end of list. */
|
||||||
|
|
||||||
void
|
static void
|
||||||
get_some_switches()
|
get_some_switches()
|
||||||
{
|
{
|
||||||
Reg1 char *s;
|
Reg1 char *s;
|
||||||
@ -577,7 +583,7 @@ Options:\n\
|
|||||||
|
|
||||||
/* Attempt to find the right place to apply this hunk of patch. */
|
/* Attempt to find the right place to apply this hunk of patch. */
|
||||||
|
|
||||||
LINENUM
|
static LINENUM
|
||||||
locate_hunk(fuzz)
|
locate_hunk(fuzz)
|
||||||
LINENUM fuzz;
|
LINENUM fuzz;
|
||||||
{
|
{
|
||||||
@ -622,7 +628,7 @@ LINENUM fuzz;
|
|||||||
|
|
||||||
/* We did not find the pattern, dump out the hunk so they can handle it. */
|
/* We did not find the pattern, dump out the hunk so they can handle it. */
|
||||||
|
|
||||||
void
|
static void
|
||||||
abort_hunk()
|
abort_hunk()
|
||||||
{
|
{
|
||||||
Reg1 LINENUM i;
|
Reg1 LINENUM i;
|
||||||
@ -668,7 +674,7 @@ abort_hunk()
|
|||||||
|
|
||||||
/* We found where to apply it (we hope), so do it. */
|
/* We found where to apply it (we hope), so do it. */
|
||||||
|
|
||||||
void
|
static void
|
||||||
apply_hunk(where)
|
apply_hunk(where)
|
||||||
LINENUM where;
|
LINENUM where;
|
||||||
{
|
{
|
||||||
@ -788,7 +794,7 @@ LINENUM where;
|
|||||||
|
|
||||||
/* Open the new file. */
|
/* Open the new file. */
|
||||||
|
|
||||||
void
|
static void
|
||||||
init_output(name)
|
init_output(name)
|
||||||
char *name;
|
char *name;
|
||||||
{
|
{
|
||||||
@ -799,7 +805,7 @@ char *name;
|
|||||||
|
|
||||||
/* Open a file to put hunks we can't locate. */
|
/* Open a file to put hunks we can't locate. */
|
||||||
|
|
||||||
void
|
static void
|
||||||
init_reject(name)
|
init_reject(name)
|
||||||
char *name;
|
char *name;
|
||||||
{
|
{
|
||||||
@ -810,7 +816,7 @@ char *name;
|
|||||||
|
|
||||||
/* Copy input file to output, up to wherever hunk is to be applied. */
|
/* Copy input file to output, up to wherever hunk is to be applied. */
|
||||||
|
|
||||||
void
|
static void
|
||||||
copy_till(lastline)
|
copy_till(lastline)
|
||||||
Reg1 LINENUM lastline;
|
Reg1 LINENUM lastline;
|
||||||
{
|
{
|
||||||
@ -826,7 +832,7 @@ Reg1 LINENUM lastline;
|
|||||||
|
|
||||||
/* Finish copying the input file to the output file. */
|
/* Finish copying the input file to the output file. */
|
||||||
|
|
||||||
void
|
static void
|
||||||
spew_output()
|
spew_output()
|
||||||
{
|
{
|
||||||
#ifdef DEBUGGING
|
#ifdef DEBUGGING
|
||||||
@ -841,7 +847,7 @@ spew_output()
|
|||||||
|
|
||||||
/* Copy one line from input to output. */
|
/* Copy one line from input to output. */
|
||||||
|
|
||||||
void
|
static void
|
||||||
dump_line(line)
|
dump_line(line)
|
||||||
LINENUM line;
|
LINENUM line;
|
||||||
{
|
{
|
||||||
@ -854,7 +860,7 @@ LINENUM line;
|
|||||||
|
|
||||||
/* Does the patch pattern match at line base+offset? */
|
/* Does the patch pattern match at line base+offset? */
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
patch_match(base, offset, fuzz)
|
patch_match(base, offset, fuzz)
|
||||||
LINENUM base;
|
LINENUM base;
|
||||||
LINENUM offset;
|
LINENUM offset;
|
||||||
@ -881,7 +887,7 @@ LINENUM fuzz;
|
|||||||
|
|
||||||
/* Do two lines match with canonicalized white space? */
|
/* Do two lines match with canonicalized white space? */
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
similar(a,b,len)
|
similar(a,b,len)
|
||||||
Reg1 char *a;
|
Reg1 char *a;
|
||||||
Reg2 char *b;
|
Reg2 char *b;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
/* $NetBSD: pch.c,v 1.5 1998/02/22 13:33:50 christos Exp $ */
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: pch.c,v 1.4 1997/07/29 19:49:35 phil Exp $";
|
__RCSID("$NetBSD: pch.c,v 1.5 1998/02/22 13:33:50 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "EXTERN.h"
|
#include "EXTERN.h"
|
||||||
@ -8,6 +10,9 @@ static char rcsid[] = "$NetBSD: pch.c,v 1.4 1997/07/29 19:49:35 phil Exp $";
|
|||||||
#include "INTERN.h"
|
#include "INTERN.h"
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
/* Patch (diff listing) abstract type. */
|
/* Patch (diff listing) abstract type. */
|
||||||
|
|
||||||
static long p_filesize; /* size of the patch file */
|
static long p_filesize; /* size of the patch file */
|
||||||
@ -33,6 +38,7 @@ static LINENUM p_efake = -1; /* end of faked up lines--don't free */
|
|||||||
static LINENUM p_bfake = -1; /* beg of faked up lines */
|
static LINENUM p_bfake = -1; /* beg of faked up lines */
|
||||||
|
|
||||||
/* Prepare to look for the next patch in the patch file. */
|
/* Prepare to look for the next patch in the patch file. */
|
||||||
|
static void malformed __P((void));
|
||||||
|
|
||||||
void
|
void
|
||||||
re_patch()
|
re_patch()
|
||||||
@ -180,7 +186,7 @@ intuit_diff_type()
|
|||||||
Reg4 long this_line = 0;
|
Reg4 long this_line = 0;
|
||||||
Reg5 long previous_line;
|
Reg5 long previous_line;
|
||||||
Reg6 long first_command_line = -1;
|
Reg6 long first_command_line = -1;
|
||||||
long fcl_line;
|
long fcl_line = -1;
|
||||||
Reg7 bool last_line_was_command = FALSE;
|
Reg7 bool last_line_was_command = FALSE;
|
||||||
Reg8 bool this_is_a_command = FALSE;
|
Reg8 bool this_is_a_command = FALSE;
|
||||||
Reg9 bool stars_last_line = FALSE;
|
Reg9 bool stars_last_line = FALSE;
|
||||||
@ -426,15 +432,15 @@ another_hunk()
|
|||||||
/* file pos of the current line */
|
/* file pos of the current line */
|
||||||
LINENUM repl_beginning = 0; /* index of --- line */
|
LINENUM repl_beginning = 0; /* index of --- line */
|
||||||
Reg4 LINENUM fillcnt = 0; /* #lines of missing ptrn or repl */
|
Reg4 LINENUM fillcnt = 0; /* #lines of missing ptrn or repl */
|
||||||
Reg5 LINENUM fillsrc; /* index of first line to copy */
|
Reg5 LINENUM fillsrc = 0; /* index of first line to copy */
|
||||||
Reg6 LINENUM filldst; /* index of first missing line */
|
Reg6 LINENUM filldst = 0; /* index of first missing line */
|
||||||
bool ptrn_spaces_eaten = FALSE; /* ptrn was slightly misformed */
|
bool ptrn_spaces_eaten = FALSE; /* ptrn was slightly misformed */
|
||||||
Reg9 bool repl_could_be_missing = TRUE;
|
Reg9 bool repl_could_be_missing = TRUE;
|
||||||
/* no + or ! lines in this hunk */
|
/* no + or ! lines in this hunk */
|
||||||
bool repl_missing = FALSE; /* we are now backtracking */
|
bool repl_missing = FALSE; /* we are now backtracking */
|
||||||
long repl_backtrack_position = 0;
|
long repl_backtrack_position = 0;
|
||||||
/* file pos of first repl line */
|
/* file pos of first repl line */
|
||||||
LINENUM repl_patch_line; /* input line number for same */
|
LINENUM repl_patch_line = 0; /* input line number for same */
|
||||||
Reg7 LINENUM ptrn_copiable = 0;
|
Reg7 LINENUM ptrn_copiable = 0;
|
||||||
/* # of copiable lines in ptrn */
|
/* # of copiable lines in ptrn */
|
||||||
|
|
||||||
@ -1220,7 +1226,7 @@ do_ed_script()
|
|||||||
Reg1 char *t;
|
Reg1 char *t;
|
||||||
Reg2 long beginning_of_this_line;
|
Reg2 long beginning_of_this_line;
|
||||||
Reg3 bool this_line_is_command = FALSE;
|
Reg3 bool this_line_is_command = FALSE;
|
||||||
Reg4 FILE *pipefp;
|
Reg4 FILE *pipefp = NULL;
|
||||||
|
|
||||||
if (!skip_rest_of_patch) {
|
if (!skip_rest_of_patch) {
|
||||||
Unlink(TMPOUTNAME);
|
Unlink(TMPOUTNAME);
|
||||||
|
@ -1,27 +1,26 @@
|
|||||||
/* $NetBSD: pch.h,v 1.3 1996/09/19 06:27:15 thorpej Exp $ */
|
/* $NetBSD: pch.h,v 1.4 1998/02/22 13:33:50 christos Exp $ */
|
||||||
|
|
||||||
EXT FILE *pfp INIT(Nullfp); /* patch file pointer */
|
EXT FILE *pfp INIT(Nullfp); /* patch file pointer */
|
||||||
|
|
||||||
void re_patch();
|
void re_patch __P((void));
|
||||||
void open_patch_file();
|
void open_patch_file __P((char *));
|
||||||
void set_hunkmax();
|
void set_hunkmax __P((void));
|
||||||
void grow_hunkmax();
|
void grow_hunkmax __P((void));
|
||||||
bool there_is_another_patch();
|
bool there_is_another_patch __P((void));
|
||||||
int intuit_diff_type();
|
int intuit_diff_type __P((void));
|
||||||
void next_intuit_at();
|
void next_intuit_at __P((long, long));
|
||||||
void skip_to();
|
void skip_to __P((long, long));
|
||||||
bool another_hunk();
|
bool another_hunk __P((void));
|
||||||
bool pch_swap();
|
char *pgets __P((char *, int, FILE *));
|
||||||
char *pfetch();
|
bool pch_swap __P((void));
|
||||||
short pch_line_len();
|
LINENUM pch_first __P((void));
|
||||||
LINENUM pch_first();
|
LINENUM pch_ptrn_lines __P((void));
|
||||||
LINENUM pch_ptrn_lines();
|
LINENUM pch_newfirst __P((void));
|
||||||
LINENUM pch_newfirst();
|
LINENUM pch_repl_lines __P((void));
|
||||||
LINENUM pch_repl_lines();
|
LINENUM pch_end __P((void));
|
||||||
LINENUM pch_end();
|
LINENUM pch_context __P((void));
|
||||||
LINENUM pch_context();
|
short pch_line_len __P((LINENUM));
|
||||||
LINENUM pch_hunk_beg();
|
char pch_char __P((LINENUM));
|
||||||
char pch_char();
|
char *pfetch __P((LINENUM));
|
||||||
char *pfetch();
|
LINENUM pch_hunk_beg __P((void));
|
||||||
char *pgets();
|
void do_ed_script __P((void));
|
||||||
void do_ed_script();
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
/* $NetBSD: util.c,v 1.5 1998/02/22 13:33:50 christos Exp $ */
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: util.c,v 1.4 1996/09/19 06:27:16 thorpej Exp $";
|
__RCSID("$NetBSD: util.c,v 1.5 1998/02/22 13:33:50 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "EXTERN.h"
|
#include "EXTERN.h"
|
||||||
@ -7,8 +9,15 @@ static char rcsid[] = "$NetBSD: util.c,v 1.4 1996/09/19 06:27:16 thorpej Exp $";
|
|||||||
#include "INTERN.h"
|
#include "INTERN.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "backupfile.h"
|
#include "backupfile.h"
|
||||||
|
#ifdef __STDC__
|
||||||
|
#include <stdarg.h>
|
||||||
|
#else
|
||||||
|
#include <varargs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
void my_exit();
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
/* Rename a file, copying it if necessary. */
|
/* Rename a file, copying it if necessary. */
|
||||||
|
|
||||||
@ -175,7 +184,7 @@ Reg1 char *s;
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
t = rv;
|
t = rv;
|
||||||
while (*t++ = *s++);
|
while ((*t++ = *s++) != '\0');
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -196,53 +205,106 @@ ask(pat) char *pat; { ; }
|
|||||||
/* Vanilla terminal output (buffered). */
|
/* Vanilla terminal output (buffered). */
|
||||||
|
|
||||||
void
|
void
|
||||||
say(pat,arg1,arg2,arg3)
|
#ifdef __STDC__
|
||||||
char *pat;
|
say(const char *pat, ...)
|
||||||
long arg1,arg2,arg3;
|
#else
|
||||||
|
say(va_alist)
|
||||||
|
va_dcl
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(stderr, pat, arg1, arg2, arg3);
|
va_list ap;
|
||||||
|
#ifdef __STDC__
|
||||||
|
va_start(ap, pat);
|
||||||
|
#else
|
||||||
|
const char *pat;
|
||||||
|
|
||||||
|
va_start(ap);
|
||||||
|
pat = va_arg(ap, const char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vfprintf(stderr, pat, ap);
|
||||||
|
va_end(ap);
|
||||||
Fflush(stderr);
|
Fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminal output, pun intended. */
|
/* Terminal output, pun intended. */
|
||||||
|
|
||||||
void /* very void */
|
void /* very void */
|
||||||
fatal(pat,arg1,arg2,arg3)
|
#ifdef __STDC__
|
||||||
char *pat;
|
fatal(const char *pat, ...)
|
||||||
long arg1,arg2,arg3;
|
#else
|
||||||
|
fatal(va_alist)
|
||||||
|
va_dcl
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
va_list ap;
|
||||||
|
#ifdef __STDC__
|
||||||
|
va_start(ap, pat);
|
||||||
|
#else
|
||||||
|
const char *pat;
|
||||||
|
|
||||||
|
va_start(ap);
|
||||||
|
pat = va_arg(ap, const char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
fprintf(stderr, "patch: **** ");
|
fprintf(stderr, "patch: **** ");
|
||||||
fprintf(stderr, pat, arg1, arg2, arg3);
|
vfprintf(stderr, pat, ap);
|
||||||
|
va_end(ap);
|
||||||
my_exit(1);
|
my_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Say something from patch, something from the system, then silence . . . */
|
/* Say something from patch, something from the system, then silence . . . */
|
||||||
|
|
||||||
void /* very void */
|
void /* very void */
|
||||||
pfatal(pat,arg1,arg2,arg3)
|
#ifdef __STDC__
|
||||||
char *pat;
|
pfatal(const char *pat, ...)
|
||||||
long arg1,arg2,arg3;
|
#else
|
||||||
|
pfatal(va_alist)
|
||||||
|
va_dcl
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
va_list ap;
|
||||||
int errnum = errno;
|
int errnum = errno;
|
||||||
|
#ifdef __STDC__
|
||||||
|
va_start(ap, pat);
|
||||||
|
#else
|
||||||
|
const char *pat;
|
||||||
|
|
||||||
|
va_start(ap);
|
||||||
|
pat = va_arg(ap, const char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
fprintf(stderr, "patch: **** ");
|
fprintf(stderr, "patch: **** ");
|
||||||
fprintf(stderr, pat, arg1, arg2, arg3);
|
vfprintf(stderr, pat, ap);
|
||||||
fprintf(stderr, ": %s\n", strerror(errnum));
|
fprintf(stderr, ": %s\n", strerror(errnum));
|
||||||
|
va_end(ap);
|
||||||
my_exit(1);
|
my_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get a response from the user, somehow or other. */
|
/* Get a response from the user, somehow or other. */
|
||||||
|
|
||||||
void
|
void
|
||||||
ask(pat,arg1,arg2,arg3)
|
#ifdef __STDC__
|
||||||
char *pat;
|
ask(const char *pat, ...)
|
||||||
long arg1,arg2,arg3;
|
#else
|
||||||
|
ask(va_alist)
|
||||||
|
va_dcl
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
int ttyfd;
|
int ttyfd;
|
||||||
int r;
|
int r;
|
||||||
bool tty2 = isatty(2);
|
bool tty2 = isatty(2);
|
||||||
|
va_list ap;
|
||||||
|
#ifdef __STDC__
|
||||||
|
va_start(ap, pat);
|
||||||
|
#else
|
||||||
|
const char *pat;
|
||||||
|
|
||||||
Sprintf(buf, pat, arg1, arg2, arg3);
|
va_start(ap);
|
||||||
|
pat = va_arg(ap, const char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
(void) vsprintf(buf, pat, ap);
|
||||||
|
va_end(ap);
|
||||||
Fflush(stderr);
|
Fflush(stderr);
|
||||||
write(2, buf, strlen(buf));
|
write(2, buf, strlen(buf));
|
||||||
if (tty2) { /* might be redirected to a file */
|
if (tty2) { /* might be redirected to a file */
|
||||||
@ -285,9 +347,9 @@ int reset;
|
|||||||
{
|
{
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#ifdef VOIDSIG
|
#ifdef VOIDSIG
|
||||||
static void (*hupval)(),(*intval)();
|
static void (*hupval) __P((int)),(*intval) __P((int));
|
||||||
#else
|
#else
|
||||||
static int (*hupval)(),(*intval)();
|
static int (*hupval) __P((int)),(*intval)__P((int));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!reset) {
|
if (!reset) {
|
||||||
@ -296,14 +358,14 @@ int reset;
|
|||||||
#ifdef VOIDSIG
|
#ifdef VOIDSIG
|
||||||
hupval = my_exit;
|
hupval = my_exit;
|
||||||
#else
|
#else
|
||||||
hupval = (int(*)())my_exit;
|
hupval = (int(*) __P((int)))my_exit;
|
||||||
#endif
|
#endif
|
||||||
intval = signal(SIGINT, SIG_IGN);
|
intval = signal(SIGINT, SIG_IGN);
|
||||||
if (intval != SIG_IGN)
|
if (intval != SIG_IGN)
|
||||||
#ifdef VOIDSIG
|
#ifdef VOIDSIG
|
||||||
intval = my_exit;
|
intval = my_exit;
|
||||||
#else
|
#else
|
||||||
intval = (int(*)())my_exit;
|
intval = (int(*) __P((int)))my_exit;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Signal(SIGHUP, hupval);
|
Signal(SIGHUP, hupval);
|
||||||
@ -427,8 +489,9 @@ int assume_exists;
|
|||||||
strncpy(tmpbuf, name, pathlen);
|
strncpy(tmpbuf, name, pathlen);
|
||||||
|
|
||||||
#define try(f, a1, a2) (Sprintf(tmpbuf + pathlen, f, a1, a2), stat(tmpbuf, &filestat) == 0)
|
#define try(f, a1, a2) (Sprintf(tmpbuf + pathlen, f, a1, a2), stat(tmpbuf, &filestat) == 0)
|
||||||
|
#define try1(f, a1) (Sprintf(tmpbuf + pathlen, f, a1), stat(tmpbuf, &filestat) == 0)
|
||||||
if ( try("RCS/%s%s", filebase, RCSSUFFIX)
|
if ( try("RCS/%s%s", filebase, RCSSUFFIX)
|
||||||
|| try("RCS/%s" , filebase, 0)
|
|| try1("RCS/%s" , filebase)
|
||||||
|| try( "%s%s", filebase, RCSSUFFIX)
|
|| try( "%s%s", filebase, RCSSUFFIX)
|
||||||
|| try("SCCS/%s%s", SCCSPREFIX, filebase)
|
|| try("SCCS/%s%s", SCCSPREFIX, filebase)
|
||||||
|| try( "%s%s", SCCSPREFIX, filebase))
|
|| try( "%s%s", SCCSPREFIX, filebase))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: util.h,v 1.3 1996/09/19 06:27:17 thorpej Exp $ */
|
/* $NetBSD: util.h,v 1.4 1998/02/22 13:33:50 christos Exp $ */
|
||||||
|
|
||||||
/* and for those machine that can't handle a variable argument list */
|
/* and for those machine that can't handle a variable argument list */
|
||||||
|
|
||||||
@ -68,15 +68,14 @@
|
|||||||
|
|
||||||
EXT char serrbuf[BUFSIZ]; /* buffer for stderr */
|
EXT char serrbuf[BUFSIZ]; /* buffer for stderr */
|
||||||
|
|
||||||
char *fetchname();
|
int move_file __P((char *, char *));
|
||||||
int move_file();
|
void copy_file __P((char *, char *));
|
||||||
void copy_file();
|
char *savestr __P((Reg1 char *));
|
||||||
void say();
|
void say __P((const char *, ...));
|
||||||
void fatal();
|
void fatal __P((const char *, ...));
|
||||||
void pfatal();
|
void pfatal __P((const char *, ...));
|
||||||
void ask();
|
void ask __P((const char *, ...));
|
||||||
char *savestr();
|
void set_signals __P((int));
|
||||||
void set_signals();
|
void ignore_signals __P((void));
|
||||||
void ignore_signals();
|
void makedirs __P((Reg1 char *, bool));
|
||||||
void makedirs();
|
char *fetchname __P((char *, int, int));
|
||||||
char *basename();
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
/* $NetBSD: version.c,v 1.4 1998/02/22 13:33:51 christos Exp $ */
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "$NetBSD: version.c,v 1.3 1996/09/19 06:27:18 thorpej Exp $";
|
__RCSID("$NetBSD: version.c,v 1.4 1998/02/22 13:33:51 christos Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "EXTERN.h"
|
#include "EXTERN.h"
|
||||||
@ -9,8 +11,6 @@ static char rcsid[] = "$NetBSD: version.c,v 1.3 1996/09/19 06:27:18 thorpej Exp
|
|||||||
#include "patchlevel.h"
|
#include "patchlevel.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
void my_exit();
|
|
||||||
|
|
||||||
/* Print out the version number and die. */
|
/* Print out the version number and die. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
/* $NetBSD: version.h,v 1.3 1996/09/19 06:27:18 thorpej Exp $ */
|
/* $NetBSD: version.h,v 1.4 1998/02/22 13:33:51 christos Exp $ */
|
||||||
|
|
||||||
void version();
|
void version __P((void));
|
||||||
|
Loading…
Reference in New Issue
Block a user