From 5d07573cd62643d34a8430760bcddc826635a627 Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 27 Jan 2021 07:18:41 +0000 Subject: [PATCH] fix -fno-common issues; ok mortimer --- usr.bin/gprof/gprof.c | 39 +++++++++++++++++++- usr.bin/gprof/gprof.h | 86 +++++++++++++++++++++---------------------- 2 files changed, 81 insertions(+), 44 deletions(-) diff --git a/usr.bin/gprof/gprof.c b/usr.bin/gprof/gprof.c index 950c6555368..cbef100bb53 100644 --- a/usr.bin/gprof/gprof.c +++ b/usr.bin/gprof/gprof.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -37,6 +37,43 @@ int valcmp(const void *, const void *); 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[]) { diff --git a/usr.bin/gprof/gprof.h b/usr.bin/gprof/gprof.h index 39a2334abaa..0598056520b 100644 --- a/usr.bin/gprof/gprof.h +++ b/usr.bin/gprof/gprof.h @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -54,13 +54,13 @@ typedef int bool; /* * 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" @@ -121,9 +121,9 @@ struct nl { }; 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 */ @@ -142,9 +142,9 @@ struct cl { }; 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 */ /* @@ -158,8 +158,8 @@ int cyclecnt; /* the number of cycles found */ * 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. @@ -175,42 +175,42 @@ struct ophdr { 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 @@ -219,12 +219,12 @@ struct stringlist { 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 -- 2.20.1