gprofng: Remove public hz and whoami variables

Remove public hz and whoami variables. This fixes the errors when
building with --enable-shared.
diff --git a/gprofng/src/basic_blocks.h b/gprofng/src/basic_blocks.h
index 97c5283..25152a9 100644
--- a/gprofng/src/basic_blocks.h
+++ b/gprofng/src/basic_blocks.h
@@ -25,6 +25,6 @@
 
 /* Read a basic-block record from file IFP.  FILENAME is the name of
    file IFP and is provided for formatting error-messages only.  */
-extern void bb_read_rec (FILE *, const char *, bool);
+extern void bb_read_rec (FILE *, const char *, bool, const char *);
 
 #endif /* basic_blocks_h */
diff --git a/gprofng/src/call_graph.h b/gprofng/src/call_graph.h
index 5555bf3..48e2faf 100644
--- a/gprofng/src/call_graph.h
+++ b/gprofng/src/call_graph.h
@@ -22,12 +22,12 @@
 #ifndef call_graph_h
 #define call_graph_h
 
-extern void cg_tally (bfd_vma, bfd_vma, unsigned long);
+extern void cg_tally (bfd_vma, bfd_vma, unsigned long, const char *);
 
 /* Read a record from file IFP describing an arc in the function
    call-graph and the count of how many times the arc has been
    traversed.  FILENAME is the name of file IFP and is provided for
    formatting error-messages only.  */
-extern void cg_read_rec (FILE *, const char *);
+extern void cg_read_rec (FILE *, const char *, const char *);
 
 #endif /* call_graph_h */
diff --git a/gprofng/src/corefile.h b/gprofng/src/corefile.h
index 3db1a40..89270d1 100644
--- a/gprofng/src/corefile.h
+++ b/gprofng/src/corefile.h
@@ -35,7 +35,7 @@
 extern int offset_to_code;        /* Offset (in bytes) of code from entry
                                      address of routine.  */
 
-extern int core_init (const char *);
-extern void symtab_init (void);
+extern int core_init (const char *, const char *);
+extern void symtab_init (const char *);
 
 #endif /* corefile_h */
diff --git a/gprofng/src/gmon_basic_blocks.cc b/gprofng/src/gmon_basic_blocks.cc
index cc37b27..2b38e71 100644
--- a/gprofng/src/gmon_basic_blocks.cc
+++ b/gprofng/src/gmon_basic_blocks.cc
@@ -51,7 +51,8 @@
    of file IFP and is provided for formatting error-messages only.  */
 
 void
-bb_read_rec (FILE *ifp, const char *filename, bool line_granularity)
+bb_read_rec (FILE *ifp, const char *filename,
+	     bool line_granularity, const char *whoami)
 {
   unsigned int nblocks, b;
   bfd_vma addr, ncalls;
@@ -65,7 +66,7 @@
       done (1);
     }
 
-  symtab = get_symtab ();
+  symtab = get_symtab (whoami);
 
   nblocks = bfd_get_32 (core_bfd, (bfd_byte *) & nblocks);
   if (gmon_file_version == 0)
@@ -89,8 +90,8 @@
 	      done (1);
 	    }
 	}
-      else if (gmon_io_read_vma (ifp, &addr)
-	       || gmon_io_read_vma (ifp, &ncalls))
+      else if (gmon_io_read_vma (ifp, &addr, whoami)
+	       || gmon_io_read_vma (ifp, &ncalls, whoami))
 	{
 	  perror (filename);
 	  done (1);
diff --git a/gprofng/src/gmon_call_graph.cc b/gprofng/src/gmon_call_graph.cc
index 433c3a9..f068442 100644
--- a/gprofng/src/gmon_call_graph.cc
+++ b/gprofng/src/gmon_call_graph.cc
@@ -31,11 +31,12 @@
 #include "gmon_out.h"
 
 void
-cg_tally (bfd_vma from_pc, bfd_vma self_pc, unsigned long count)
+cg_tally (bfd_vma from_pc, bfd_vma self_pc,
+	  unsigned long count, const char *whoami)
 {
   Sym *parent;
   Sym *child;
-  Sym_Table *symtab = get_symtab ();
+  Sym_Table *symtab = get_symtab (whoami);
 
   parent = sym_lookup (symtab, from_pc);
   child = sym_lookup (symtab, self_pc);
@@ -68,13 +69,13 @@
    formatting error-messages only.  */
 
 void
-cg_read_rec (FILE *ifp, const char *filename)
+cg_read_rec (FILE *ifp, const char *filename, const char *whoami)
 {
   bfd_vma from_pc, self_pc;
   unsigned int count;
 
-  if (gmon_io_read_vma (ifp, &from_pc)
-      || gmon_io_read_vma (ifp, &self_pc)
+  if (gmon_io_read_vma (ifp, &from_pc, whoami)
+      || gmon_io_read_vma (ifp, &self_pc, whoami)
       || gmon_io_read_32 (ifp, &count))
     {
       fprintf (stderr, "%s: %s: unexpected end of file\n",
@@ -87,5 +88,5 @@
 	       (unsigned long) from_pc, (unsigned long) self_pc,
 	       (unsigned long) count));
   /* Add this arc:  */
-  cg_tally (from_pc, self_pc, count);
+  cg_tally (from_pc, self_pc, count, whoami);
 }
diff --git a/gprofng/src/gmon_corefile.cc b/gprofng/src/gmon_corefile.cc
index 93abb91..07bab11 100644
--- a/gprofng/src/gmon_corefile.cc
+++ b/gprofng/src/gmon_corefile.cc
@@ -63,7 +63,7 @@
 
 
 int
-core_init (const char * aout_name)
+core_init (const char * aout_name, const char *whoami)
 {
   int core_sym_bytes;
   asymbol *synthsyms;
@@ -331,7 +331,7 @@
    One symbol per function is entered.  */
 
 static void
-core_create_function_syms (void)
+core_create_function_syms (const char *whoami)
 {
   int cxxclass;
   long i;
@@ -486,7 +486,7 @@
 /* Initialize the symbol table.  */
 
 void
-symtab_init (void)
+symtab_init (const char *whoami)
 {
-  core_create_function_syms ();
+  core_create_function_syms (whoami);
 }
diff --git a/gprofng/src/gmon_hist.cc b/gprofng/src/gmon_hist.cc
index e3c7fd8..38035e3 100644
--- a/gprofng/src/gmon_hist.cc
+++ b/gprofng/src/gmon_hist.cc
@@ -38,7 +38,7 @@
 typedef unsigned char UNIT[2];	/* unit of profiling */
 #define UNITS_TO_CODE (offset_to_code / sizeof(UNIT))
 
-static void scale_and_align_entries (void);
+static long hz = 0;
 
 /* Given a range of addresses for a symbol, find a histogram record
    that intersects with this range, and clips the range to that
@@ -47,7 +47,8 @@
    If no intersection is found, *P_LOWPC and *P_HIGHPC will be set to
    one unspecified value.  If more that one intersection is found,
    an error is emitted.  */
-static void hist_clip_symbol_address (bfd_vma *p_lowpc, bfd_vma *p_highpc);
+static void hist_clip_symbol_address (bfd_vma *p_lowpc,
+				      bfd_vma *p_highpc, const char *whoami);
 
 
 /* Declarations of automatically generated functions to output blurbs.  */
@@ -100,15 +101,15 @@
 static void
 read_histogram_header (histogram *record,
 		       FILE *ifp, const char *filename,
-		       int first)
+		       int first, const char *whoami)
 {
   unsigned int profrate;
   char n_hist_dimension[15];
   char n_hist_dimension_abbrev;
   double n_hist_scale;
 
-  if (gmon_io_read_vma (ifp, &record->lowpc)
-      || gmon_io_read_vma (ifp, &record->highpc)
+  if (gmon_io_read_vma (ifp, &record->lowpc, whoami)
+      || gmon_io_read_vma (ifp, &record->highpc, whoami)
       || gmon_io_read_32 (ifp, &record->num_bins)
       || gmon_io_read_32 (ifp, &profrate)
       || gmon_io_read (ifp, n_hist_dimension, 15)
@@ -177,7 +178,7 @@
    is provided for formatting error messages only.  */
 
 void
-hist_read_rec (FILE * ifp, const char *filename)
+hist_read_rec (FILE * ifp, const char *filename, const char *whoami)
 {
   bfd_vma lowpc, highpc;
   histogram n_record;
@@ -186,7 +187,7 @@
 
   /* 1. Read the header and see if there's existing record for the
      same address range and that there are no overlapping records.  */
-  read_histogram_header (&n_record, ifp, filename, num_histograms == 0);
+  read_histogram_header (&n_record, ifp, filename, num_histograms == 0, whoami);
 
   existing_record = find_histogram (n_record.lowpc, n_record.highpc);
   if (existing_record)
@@ -199,7 +200,7 @@
 	 record, it's an error.  */
       lowpc = n_record.lowpc;
       highpc = n_record.highpc;
-      hist_clip_symbol_address (&lowpc, &highpc);
+      hist_clip_symbol_address (&lowpc, &highpc, whoami);
       if (lowpc != highpc)
 	{
 	  fprintf (stderr,
@@ -259,12 +260,12 @@
    next bin.  */
 
 static void
-scale_and_align_entries (void)
+scale_and_align_entries (const char *whoami)
 {
   Sym *sym;
   bfd_vma bin_of_entry;
   bfd_vma bin_of_code;
-  Sym_Table *symtab = get_symtab ();
+  Sym_Table *symtab = get_symtab (whoami);
 
   for (sym = symtab->base; sym < symtab->limit; sym++)
     {
@@ -329,7 +330,7 @@
    cases, above).  */
 
 static void
-hist_assign_samples_1 (histogram *r)
+hist_assign_samples_1 (histogram *r, const char *whoami)
 {
   bfd_vma bin_low_pc, bin_high_pc;
   bfd_vma sym_low_pc, sym_high_pc;
@@ -337,7 +338,7 @@
   unsigned int bin_count;
   unsigned int i, j, k;
   double count_time, credit;
-  Sym_Table *symtab = get_symtab ();
+  Sym_Table *symtab = get_symtab (whoami);
 
   bfd_vma lowpc = r->lowpc / sizeof (UNIT);
 
@@ -403,14 +404,14 @@
 
 /* Calls 'hist_assign_samples_1' for all histogram records read so far. */
 void
-hist_assign_samples (void)
+hist_assign_samples (const char *whoami)
 {
   unsigned i;
 
-  scale_and_align_entries ();
+  scale_and_align_entries (whoami);
 
   for (i = 0; i < num_histograms; ++i)
-    hist_assign_samples_1 (&histograms[i]);
+    hist_assign_samples_1 (&histograms[i], whoami);
 
 }
 
@@ -421,8 +422,9 @@
 #define max(a,b) (((a)>(b)) ? (a) : (b))
 #endif
 
-void
-hist_clip_symbol_address (bfd_vma *p_lowpc, bfd_vma *p_highpc)
+static void
+hist_clip_symbol_address (bfd_vma *p_lowpc,
+			  bfd_vma *p_highpc, const char *whoami)
 {
   unsigned i;
   int found = 0;
@@ -488,3 +490,10 @@
     }
   return 0;
 }
+
+/* Return the profile rate in hz. */
+long
+hist_get_hz (void)
+{
+  return hz;
+}
diff --git a/gprofng/src/gmon_io.cc b/gprofng/src/gmon_io.cc
index 6860d2e..82e6cee 100644
--- a/gprofng/src/gmon_io.cc
+++ b/gprofng/src/gmon_io.cc
@@ -54,7 +54,6 @@
   ptr_unsigned
 };
 
-static enum gmon_ptr_size gmon_get_ptr_size (void);
 static enum gmon_ptr_signedness gmon_get_ptr_signedness (void);
 
 static int gmon_io_read_64 (FILE *, uint64_t *);
@@ -63,7 +62,7 @@
 int gmon_file_version = 0;	/* 0 == old (non-versioned) file format.  */
 
 static enum gmon_ptr_size
-gmon_get_ptr_size (void)
+gmon_get_ptr_size (const char *whoami)
 {
   int size;
 
@@ -124,12 +123,12 @@
 }
 
 int
-gmon_io_read_vma (FILE *ifp, bfd_vma *valp)
+gmon_io_read_vma (FILE *ifp, bfd_vma *valp, const char *whoami)
 {
   unsigned int val32;
   uint64_t val64;
 
-  switch (gmon_get_ptr_size ())
+  switch (gmon_get_ptr_size (whoami))
     {
     case ptr_32bit:
       if (gmon_io_read_32 (ifp, &val32))
@@ -161,7 +160,8 @@
 }
 
 int
-gmon_out_read (const char *filename, File_Format file_format)
+gmon_out_read (const char *filename,
+	       File_Format file_format, const char *whoami)
 {
   FILE *ifp;
   struct gmon_hdr ghdr;
@@ -221,19 +221,19 @@
 	    case GMON_TAG_TIME_HIST:
 	      ++nhist;
 	      gmon_input |= INPUT_HISTOGRAM;
-	      hist_read_rec (ifp, filename);
+	      hist_read_rec (ifp, filename, whoami);
 	      break;
 
 	    case GMON_TAG_CG_ARC:
 	      ++narcs;
 	      gmon_input |= INPUT_CALL_GRAPH;
-	      cg_read_rec (ifp, filename);
+	      cg_read_rec (ifp, filename, whoami);
 	      break;
 
 	    case GMON_TAG_BB_COUNT:
 	      ++nbbs;
 	      gmon_input |= INPUT_BB_COUNTS;
-	      bb_read_rec (ifp, filename, false);
+	      bb_read_rec (ifp, filename, false, whoami);
 	      break;
 
 	    default:
diff --git a/gprofng/src/gmon_io.h b/gprofng/src/gmon_io.h
index d2fe854..de5c678 100644
--- a/gprofng/src/gmon_io.h
+++ b/gprofng/src/gmon_io.h
@@ -37,10 +37,10 @@
 extern int gmon_input;          /* What input did we see?  */
 extern int gmon_file_version;   /* File version are we dealing with.  */
 
-extern int gmon_io_read_vma (FILE *ifp, bfd_vma *valp);
+extern int gmon_io_read_vma (FILE *ifp, bfd_vma *valp, const char *whoami);
 extern int gmon_io_read_32 (FILE *ifp, unsigned int *valp);
 extern int gmon_io_read (FILE *ifp, char *buf, size_t n);
 
-extern int gmon_out_read   (const char *, File_Format);
+extern int gmon_out_read (const char *, File_Format, const char *);
 
 #endif /* gmon_io_h */
diff --git a/gprofng/src/gmon_symtab.cc b/gprofng/src/gmon_symtab.cc
index edf82de..68c8a0b 100644
--- a/gprofng/src/gmon_symtab.cc
+++ b/gprofng/src/gmon_symtab.cc
@@ -44,12 +44,12 @@
    initialized yet.  */
 
 Sym_Table *
-get_symtab (void)
+get_symtab (const char *whoami)
 {
   static Sym_Table *symtab_p;
   if (!symtab_p)
     {
-      symtab_init ();
+      symtab_init (whoami);
 
       symtab_p = &symtab;
     }
diff --git a/gprofng/src/gp-gmon.cc b/gprofng/src/gp-gmon.cc
index 07739b7..353839d 100644
--- a/gprofng/src/gp-gmon.cc
+++ b/gprofng/src/gp-gmon.cc
@@ -105,9 +105,6 @@
   int       nticks;     /* number of ticks in that state */
 } ClockPacket;
 
-const char *whoami;
-long hz = HZ_WRONG;
-
 static unsigned long *pc_array = NULL;
 static char *base_folder;
 static DFN_Stack *dfn_stack = NULL;
@@ -226,10 +223,10 @@
    Mimimc a stack trace using a DF algorithm.  */
 
 static int
-cg_traverse_arcs (void)
+cg_traverse_arcs (const char *whoami)
 {
   Sym *sym;
-  Sym_Table *symtab = get_symtab ();
+  Sym_Table *symtab = get_symtab (whoami);
 
   for (sym = symtab->base; sym < symtab->limit; sym++)
     {
@@ -451,6 +448,7 @@
 
   logx = fopen (new_file_path, "w");
 
+  long hz = hist_get_hz ();
   int gmon_interval = (hz == HZ_WRONG ? 1000 : hz * 100);
 
   fprintf (logx, "<profile name=\"%s\" ptimer=\"%d\" numstates=\"%d\">\n",
@@ -658,20 +656,20 @@
     }
 
   /* Read the elf syms and the gmon file.  */
-  if (core_init (a_out_name) < 0)
+  if (core_init (a_out_name, whoami) < 0)
     {
       cc->remove_exp_dir ();
       exit (1);
     }
-  if (gmon_out_read (gmon_name, FF_AUTO) < 0)
+  if (gmon_out_read (gmon_name, FF_AUTO, whoami) < 0)
     {
       cc->remove_exp_dir ();
       exit (1);
     }
 
   /* Process the gmon file, and output the gprofng project files.  */
-  hist_assign_samples ();
-  cg_traverse_arcs ();
+  hist_assign_samples (whoami);
+  cg_traverse_arcs (whoami);
   gen_gmon_map (a_out_name);
   gen_gmon_log ();
 }
diff --git a/gprofng/src/gp-gmon.h b/gprofng/src/gp-gmon.h
index bb8697c..d423198 100644
--- a/gprofng/src/gp-gmon.h
+++ b/gprofng/src/gp-gmon.h
@@ -18,5 +18,4 @@
 #define MAX(a,b)        ((a) > (b) ? (a) : (b))
 #endif
 
-extern const char *whoami;
 #endif /* gp_gmon_h */
diff --git a/gprofng/src/hist.h b/gprofng/src/hist.h
index 8844388..22fc56c 100644
--- a/gprofng/src/hist.h
+++ b/gprofng/src/hist.h
@@ -30,9 +30,8 @@
   int *sample;           /* Histogram samples (shorts in the file!).  */
 } histogram;
 
-extern long hz;
-
-extern void hist_read_rec        (FILE *, const char *);
-extern void hist_assign_samples  (void);
+extern void hist_read_rec        (FILE *, const char *, const char *);
+extern void hist_assign_samples  (const char *);
+extern long hist_get_hz  (void);
 
 #endif /* hist_h */
diff --git a/gprofng/src/symtab.h b/gprofng/src/symtab.h
index f7b612d..9f7a8dd 100644
--- a/gprofng/src/symtab.h
+++ b/gprofng/src/symtab.h
@@ -112,7 +112,7 @@
   }
 Sym_Table;
 
-extern Sym_Table *get_symtab (void);
+extern Sym_Table *get_symtab (const char *);
 extern Sym_Table *get_symtab_direct (void);
 
 extern void sym_init        (Sym *);