-/* $OpenBSD: gprof.c,v 1.26 2016/10/08 19:55:39 guenther Exp $ */
+/* $OpenBSD: gprof.c,v 1.27 2021/01/27 07:18:41 deraadt Exp $ */
/* $NetBSD: gprof.c,v 1.8 1995/04/19 07:15:59 cgd Exp $ */
/*
static struct gmonhdr gmonhdr;
extern char *__progname;
+long hz;
+char *a_outname;
+char *gmonname;
+nltype *nl; /* the whole namelist */
+nltype *npe; /* the virtual end of the namelist */
+int nname; /* the number of function names */
+arctype *archead; /* the head of arcs in current cycle list */
+cltype *cyclehead; /* the head of the list */
+int cyclecnt; /* the number of cycles found */
+nltype *cyclenl; /* cycle header namelist */
+int ncycle; /* number of cycles discovered */
+int debug;
+UNIT *samples;
+unsigned long s_lowpc; /* lowpc from the profile file */
+unsigned long s_highpc; /* highpc from the profile file */
+unsigned long lowpc, highpc; /* range profiled, in UNIT's */
+unsigned sampbytes; /* number of bytes of samples */
+int nsamples; /* number of samples */
+double actime; /* accumulated time thus far for putprofline */
+double totime; /* total time for all routines */
+double printtime; /* total of time being printed */
+double scale; /* scale factor converting samples to pc */
+unsigned char *textspace; /* text space of a.out in core */
+int cyclethreshold; /* with -C, minimum cycle size to ignore */
+bool aflag; /* suppress static functions */
+bool bflag; /* blurbs, too */
+bool cflag; /* discovered call graph, too */
+bool Cflag; /* find cut-set to eliminate cycles */
+bool dflag; /* debugging options */
+bool eflag; /* specific functions excluded */
+bool Eflag; /* functions excluded with time */
+bool fflag; /* specific functions requested */
+bool Fflag; /* functions requested with time */
+bool kflag; /* arcs to be deleted */
+bool sflag; /* sum multiple gmon.out files */
+bool zflag; /* zero time/called functions, too */
+
int
main(int argc, char *argv[])
{
-/* $OpenBSD: gprof.h,v 1.16 2015/12/06 23:22:51 guenther Exp $ */
+/* $OpenBSD: gprof.h,v 1.17 2021/01/27 07:18:41 deraadt Exp $ */
/* $NetBSD: gprof.h,v 1.13 1996/04/01 21:54:06 mark Exp $ */
/*
/*
* ticks per second
*/
-long hz;
+extern long hz;
typedef u_short UNIT; /* unit of profiling */
-char *a_outname;
+extern char *a_outname;
#define A_OUTNAME "a.out"
-char *gmonname;
+extern char *gmonname;
#define GMONNAME "gmon.out"
#define GMONSUM "gmon.sum"
};
typedef struct nl nltype;
-nltype *nl; /* the whole namelist */
-nltype *npe; /* the virtual end of the namelist */
-int nname; /* the number of function names */
+extern nltype *nl; /* the whole namelist */
+extern nltype *npe; /* the virtual end of the namelist */
+extern int nname; /* the number of function names */
#define HASCYCLEXIT 0x08 /* node has arc exiting from cycle */
#define CYCLEHEAD 0x10 /* node marked as head of a cycle */
};
typedef struct cl cltype;
-arctype *archead; /* the head of arcs in current cycle list */
-cltype *cyclehead; /* the head of the list */
-int cyclecnt; /* the number of cycles found */
+extern arctype *archead; /* the head of arcs in current cycle list */
+extern cltype *cyclehead; /* the head of the list */
+extern int cyclecnt; /* the number of cycles found */
#define CYCLEMAX 100 /* maximum cycles before cutting one of them */
/*
* namelist entries for cycle headers.
* the number of discovered cycles.
*/
-nltype *cyclenl; /* cycle header namelist */
-int ncycle; /* number of cycles discovered */
+extern nltype *cyclenl; /* cycle header namelist */
+extern int ncycle; /* number of cycles discovered */
/*
* The header on the gmon.out file.
int ncnt;
};
-int debug;
+extern int debug;
/*
* Each discretized pc sample has
* a count of the number of samples in its range
*/
-UNIT *samples;
+extern UNIT *samples;
-unsigned long s_lowpc; /* lowpc from the profile file */
-unsigned long s_highpc; /* highpc from the profile file */
-unsigned long lowpc, highpc; /* range profiled, in UNIT's */
-unsigned sampbytes; /* number of bytes of samples */
-int nsamples; /* number of samples */
-double actime; /* accumulated time thus far for putprofline */
-double totime; /* total time for all routines */
-double printtime; /* total of time being printed */
-double scale; /* scale factor converting samples to pc
+extern unsigned long s_lowpc; /* lowpc from the profile file */
+extern unsigned long s_highpc; /* highpc from the profile file */
+extern unsigned long lowpc, highpc; /* range profiled, in UNIT's */
+extern unsigned sampbytes; /* number of bytes of samples */
+extern int nsamples; /* number of samples */
+extern double actime; /* accumulated time thus far for putprofline */
+extern double totime; /* total time for all routines */
+extern double printtime; /* total of time being printed */
+extern double scale; /* scale factor converting samples to pc
values: each sample covers scale bytes */
-unsigned char *textspace; /* text space of a.out in core */
-int cyclethreshold; /* with -C, minimum cycle size to ignore */
+extern unsigned char *textspace; /* text space of a.out in core */
+extern int cyclethreshold; /* with -C, minimum cycle size to ignore */
/*
* option flags, from a to z.
*/
-bool aflag; /* suppress static functions */
-bool bflag; /* blurbs, too */
-bool cflag; /* discovered call graph, too */
-bool Cflag; /* find cut-set to eliminate cycles */
-bool dflag; /* debugging options */
-bool eflag; /* specific functions excluded */
-bool Eflag; /* functions excluded with time */
-bool fflag; /* specific functions requested */
-bool Fflag; /* functions requested with time */
-bool kflag; /* arcs to be deleted */
-bool sflag; /* sum multiple gmon.out files */
-bool zflag; /* zero time/called functions, too */
+extern bool aflag; /* suppress static functions */
+extern bool bflag; /* blurbs, too */
+extern bool cflag; /* discovered call graph, too */
+extern bool Cflag; /* find cut-set to eliminate cycles */
+extern bool dflag; /* debugging options */
+extern bool eflag; /* specific functions excluded */
+extern bool Eflag; /* functions excluded with time */
+extern bool fflag; /* specific functions requested */
+extern bool Fflag; /* functions requested with time */
+extern bool kflag; /* arcs to be deleted */
+extern bool sflag; /* sum multiple gmon.out files */
+extern bool zflag; /* zero time/called functions, too */
/*
* structure for various string lists
struct stringlist *next;
char *string;
};
-struct stringlist *elist;
-struct stringlist *Elist;
-struct stringlist *flist;
-struct stringlist *Flist;
-struct stringlist *kfromlist;
-struct stringlist *ktolist;
+extern struct stringlist *elist;
+extern struct stringlist *Elist;
+extern struct stringlist *flist;
+extern struct stringlist *Flist;
+extern struct stringlist *kfromlist;
+extern struct stringlist *ktolist;
/*
* function declarations