summaryrefslogtreecommitdiffstats
path: root/unordered.h
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2009-09-03 19:53:24 -0400
committerDave Brolley <brolley@redhat.com>2009-09-03 19:53:24 -0400
commita5d268f35032292b8f85cc75a316930ed0b95aab (patch)
treedd78d073ab80624478e77eebab3c5e9767524faa /unordered.h
parent8402bcf68e5321b3459cbbbd27d5111bb184922e (diff)
parentdf56da84549816b15a1f7aea3c9f71de2b2001ad (diff)
downloadsystemtap-steved-a5d268f35032292b8f85cc75a316930ed0b95aab.tar.gz
systemtap-steved-a5d268f35032292b8f85cc75a316930ed0b95aab.tar.xz
systemtap-steved-a5d268f35032292b8f85cc75a316930ed0b95aab.zip
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
Diffstat (limited to 'unordered.h')
-rw-r--r--unordered.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/unordered.h b/unordered.h
new file mode 100644
index 00000000..6204dbfb
--- /dev/null
+++ b/unordered.h
@@ -0,0 +1,56 @@
+// backward-compatible unordered containers
+// Copyright (C) 2009 Red Hat Inc.
+//
+// This file is part of systemtap, and is free software. You can
+// redistribute it and/or modify it under the terms of the GNU General
+// Public License (GPL); either version 2, or (at your option) any
+// later version.
+
+#ifndef UNORDERED_H
+#define UNORDERED_H
+
+#include "config.h"
+
+#if 0 // uncomment to force the old mode
+#undef HAVE_TR1_UNORDERED_MAP
+#define _BACKWARD_BACKWARD_WARNING_H 1 // defeat deprecation warning
+#endif
+
+#ifdef HAVE_TR1_UNORDERED_MAP
+
+#include <tr1/unordered_map>
+using std::tr1::unordered_map;
+using std::tr1::unordered_multimap;
+
+#include <tr1/unordered_set>
+using std::tr1::unordered_set;
+using std::tr1::unordered_multiset;
+
+#else
+
+#include <ext/hash_map>
+#define unordered_map __gnu_cxx::hash_map
+#define unordered_multimap __gnu_cxx::hash_multimap
+
+#include <ext/hash_set>
+#define unordered_set __gnu_cxx::hash_set
+#define unordered_multiset __gnu_cxx::hash_multiset
+
+// Hack in common hash functions for strings and raw pointers
+namespace __gnu_cxx
+{
+ template<class T> struct hash<T*> {
+ size_t operator() (T* p) const
+ { hash<long> h; return h(reinterpret_cast<long>(p)); }
+ };
+ template<> struct hash<std::string> {
+ size_t operator() (std::string const& s) const
+ { hash<const char*> h; return h(s.c_str()); }
+ };
+}
+
+#endif
+
+#endif // UNORDERED_H
+
+/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */