]> sourceware.org Git - systemtap.git/commitdiff
build compatibility: gcc 4.7 with -std=c++11, std::hash collision
authorFrank Ch. Eigler <fche@redhat.com>
Thu, 16 Aug 2012 00:58:59 +0000 (20:58 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Thu, 16 Aug 2012 00:59:38 +0000 (20:59 -0400)
* hash.cxx (struct hash): Rename to stap_hash to avoid conflict with
  std::hash template.
* session.h: Corresponding changes.

Reported-By: Doug Evans <dje@google.com>
hash.cxx
session.h

index ceeaebf67a807bcc40115475b3b0ba0959f07371..3b035735316fad419081b1b1d93a2a741a8cf670 100644 (file)
--- a/hash.cxx
+++ b/hash.cxx
@@ -36,15 +36,15 @@ extern "C" {
 using namespace std;
 
 
-class hash
+class stap_hash
 {
 private:
   struct mdfour md4;
   std::ostringstream parm_stream;
 
 public:
-  hash() { start(); }
-  hash(const hash &base) { md4 = base.md4; parm_stream << base.parm_stream.str(); }
+  stap_hash() { start(); }
+  stap_hash(const stap_hash &base) { md4 = base.md4; parm_stream << base.parm_stream.str(); }
 
   void start();
 
@@ -61,14 +61,14 @@ public:
 
 
 void
-hash::start()
+stap_hash::start()
 {
   mdfour_begin(&md4);
 }
 
 
 void
-hash::add(const std::string& description, const unsigned char *buffer, size_t size)
+stap_hash::add(const std::string& description, const unsigned char *buffer, size_t size)
 {
   parm_stream << description << buffer << endl;
   mdfour_update(&md4, buffer, size);
@@ -76,7 +76,7 @@ hash::add(const std::string& description, const unsigned char *buffer, size_t si
 
 
 template <typename T> void
-hash::add(const std::string& d, const T& x)
+stap_hash::add(const std::string& d, const T& x)
 {
   parm_stream << d << x << endl;
   mdfour_update(&md4, (const unsigned char *)&x, sizeof(x));
@@ -84,7 +84,7 @@ hash::add(const std::string& d, const T& x)
 
 
 void
-hash::add_path(const std::string& description, const std::string& path)
+stap_hash::add_path(const std::string& description, const std::string& path)
 {
   struct stat st;
   memset (&st, 0, sizeof(st));
@@ -99,7 +99,7 @@ hash::add_path(const std::string& description, const std::string& path)
 
 
 void
-hash::result(string& r)
+stap_hash::result(string& r)
 {
   ostringstream rstream;
   unsigned char sum[16];
@@ -130,15 +130,15 @@ void create_hash_log(const string &type_str, const string &parms, const string &
   log_file.close();
 }
 
-static const hash&
+static const stap_hash&
 get_base_hash (systemtap_session& s)
 {
   map<string, string> dummy;
   if (s.base_hash)
     return *s.base_hash;
 
-  s.base_hash = new hash();
-  hash& h = *s.base_hash;
+  s.base_hash = new stap_hash();
+  stap_hash& h = *s.base_hash;
 
   // Hash kernel release and arch.
   h.add("Kernel Release: ", s.kernel_release);
@@ -207,7 +207,7 @@ create_hashdir (systemtap_session& s, const string& result, string& hashdir)
 void
 find_script_hash (systemtap_session& s, const string& script)
 {
-  hash h(get_base_hash(s));
+  stap_hash h(get_base_hash(s));
   struct stat st;
 
   // Hash getuid.  This really shouldn't be necessary (since who you
@@ -301,7 +301,7 @@ find_script_hash (systemtap_session& s, const string& script)
 void
 find_stapconf_hash (systemtap_session& s)
 {
-  hash h(get_base_hash(s));
+  stap_hash h(get_base_hash(s));
 
   // Add any custom kbuild flags
   for (unsigned i = 0; i < s.kbuildflags.size(); i++)
@@ -323,7 +323,7 @@ find_stapconf_hash (systemtap_session& s)
 string
 find_tracequery_hash (systemtap_session& s, const string& header)
 {
-  hash h(get_base_hash(s));
+  stap_hash h(get_base_hash(s));
 
   // Add the tracepoint header to the computed hash
   h.add_path("Header ", header);
@@ -347,7 +347,7 @@ find_tracequery_hash (systemtap_session& s, const string& header)
 string
 find_typequery_hash (systemtap_session& s, const string& name)
 {
-  hash h(get_base_hash(s));
+  stap_hash h(get_base_hash(s));
 
   // Add the typequery name to distinguish the hash
   h.add("Typequery Name: ", name);
@@ -373,7 +373,7 @@ find_typequery_hash (systemtap_session& s, const string& name)
 string
 find_uprobes_hash (systemtap_session& s)
 {
-  hash h(get_base_hash(s));
+  stap_hash h(get_base_hash(s));
 
   // Hash runtime uprobes paths
   h.add_path("Uprobes Runtime Path /uprobes ", s.runtime_path + "/uprobes");
index f8ae584d7bcb6e8dbb42e66c4931fd619258afba..a6807ae20e402990b6ef90bc0b36c6d781da5d5b 100644 (file)
--- a/session.h
+++ b/session.h
@@ -31,7 +31,7 @@ extern "C" {
 #include "util.h"
 
 // forward decls for all referenced systemtap types
-class hash;
+class stap_hash;
 class match_node;
 struct stapfile;
 struct vardecl;
@@ -244,7 +244,7 @@ public:
   std::string cache_path;       // usually ~/.systemtap/cache
   std::string hash_path;        // path to the cached script module
   std::string stapconf_path;    // path to the cached stapconf
-  hash *base_hash;              // hash common to all caching
+  stap_hash *base_hash;         // hash common to all caching
 
   // dwarfless operation
   bool consult_symtab;
This page took 0.035937 seconds and 5 git commands to generate.