From a86ddfe8c760be83b1322fe8ba3a3568421adb1f Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Mon, 6 Apr 2020 23:28:24 +0000 Subject: mail/gprof/tip: tap with the ugly stick The ugly stick here is this bit in the respective headers: #ifndef EXTERN #define EXTERN extern #endif with a follow-up #define EXTERN in a single .c file to push all of their definitions into one spot. A pass should be made over these three later to push these definitions into the correct files instead, but this will suffice for now and at a more leisurely pace. MFC after: 3 days --- usr.bin/gprof/gprof.c | 1 + usr.bin/gprof/gprof.h | 97 +++++++++++++++++++++++++++------------------------ 2 files changed, 53 insertions(+), 45 deletions(-) (limited to 'usr.bin/gprof') diff --git a/usr.bin/gprof/gprof.c b/usr.bin/gprof/gprof.c index 4970792f0502..8e1b0709229a 100644 --- a/usr.bin/gprof/gprof.c +++ b/usr.bin/gprof/gprof.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include +#define EXTERN #include "gprof.h" static int valcmp(const void *, const void *); diff --git a/usr.bin/gprof/gprof.h b/usr.bin/gprof/gprof.h index f687ad82bad3..1677b3f7a8fb 100644 --- a/usr.bin/gprof/gprof.h +++ b/usr.bin/gprof/gprof.h @@ -75,18 +75,22 @@ typedef int bool; */ #define HISTORICAL_SCALE_2 2 +#ifndef EXTERN +#define EXTERN extern +#endif + /* * ticks per second */ -long hz; +EXTERN long hz; -size_t histcounter_size; -int histcounter_type; +EXTERN size_t histcounter_size; +EXTERN int histcounter_type; -char *a_outname; +EXTERN char *a_outname; #define A_OUTNAME "a.out" -char *gmonname; +EXTERN char *gmonname; #define GMONSUM "gmon.sum" /* @@ -146,9 +150,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 */ @@ -167,9 +171,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 */ /* @@ -183,8 +187,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. @@ -200,43 +204,46 @@ struct ophdr { int ncnt; }; -int debug; +EXTERN int debug; /* * Each discretized pc sample has * a count of the number of samples in its range */ -double *samples; +EXTERN double *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 historical units */ -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 */ +/* range profiled, in historical units */ +EXTERN unsigned long lowpc, highpc; +EXTERN unsigned sampbytes; /* number of bytes of samples */ +EXTERN int nsamples; /* number of samples */ +/* accumulated time thus far for putprofline */ +EXTERN double actime; +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 */ +/* with -C, minimum cycle size to ignore */ +EXTERN int cyclethreshold; /* * option flags, from a to z. */ -bool aflag; /* suppress static functions */ -bool bflag; /* blurbs, 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 Kflag; /* use the running kernel for symbols */ -bool sflag; /* sum multiple gmon.out files */ -bool uflag; /* suppress symbols hidden from C */ -bool zflag; /* zero time/called functions, too */ +EXTERN bool aflag; /* suppress static functions */ +EXTERN bool bflag; /* blurbs, 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 Kflag; /* use the running kernel for symbols */ +EXTERN bool sflag; /* sum multiple gmon.out files */ +EXTERN bool uflag; /* suppress symbols hidden from C */ +EXTERN bool zflag; /* zero time/called functions, too */ /* * structure for various string lists @@ -245,12 +252,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 -- cgit v1.2.3