summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/bancache.h6
-rw-r--r--include/dns.h6
-rw-r--r--include/hash_map.h56
-rw-r--r--include/hashcomp.h10
-rw-r--r--include/typedefs.h10
-rw-r--r--src/hashcomp.cpp14
-rw-r--r--src/modules/m_spanningtree/utils.h2
-rw-r--r--src/modules/m_watch.cpp6
8 files changed, 59 insertions, 51 deletions
diff --git a/include/bancache.h b/include/bancache.h
index 9266149fc..5bfa2fa3f 100644
--- a/include/bancache.h
+++ b/include/bancache.h
@@ -62,10 +62,10 @@ class CoreExport BanCacheHit : public classbase
/* A container of ban cache items.
* must be defined after class BanCacheHit.
*/
-#ifndef WIN32
-typedef nspace::hash_map<std::string, BanCacheHit*, nspace::hash<std::string> > BanCacheHash;
-#else
+#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED)
typedef nspace::hash_map<std::string, BanCacheHit*, nspace::hash_compare<std::string, std::less<std::string> > > BanCacheHash;
+#else
+typedef nspace::hash_map<std::string, BanCacheHit*, nspace::hash<std::string> > BanCacheHash;
#endif
/** A manager for ban cache, which allocates and deallocates and checks cached bans.
diff --git a/include/dns.h b/include/dns.h
index 4f577366b..fa4295296 100644
--- a/include/dns.h
+++ b/include/dns.h
@@ -103,10 +103,10 @@ class CoreExport CachedQuery : public classbase
/** DNS cache information. Holds IPs mapped to hostnames, and hostnames mapped to IPs.
*/
-#ifndef WIN32
-typedef nspace::hash_map<irc::string, CachedQuery, nspace::hash<irc::string> > dnscache;
-#else
+#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED)
typedef nspace::hash_map<irc::string, CachedQuery, nspace::hash_compare<irc::string> > dnscache;
+#else
+typedef nspace::hash_map<irc::string, CachedQuery, nspace::hash<irc::string> > dnscache;
#endif
/**
diff --git a/include/hash_map.h b/include/hash_map.h
index dad08aa93..6e47d292b 100644
--- a/include/hash_map.h
+++ b/include/hash_map.h
@@ -11,35 +11,45 @@
* ---------------------------------------------------
*/
-#ifndef INSPIRCD_HASHMAP_H
-#define INSPIRCD_HASHMAP_H
+ #ifndef INSPIRCD_HASHMAP_H
+ #define INSPIRCD_HASHMAP_H
-/** Where hash_map is varies from compiler to compiler
- * as it is not standard unless we have tr1.
- */
-#ifndef WIN32
- #ifndef HASHMAP_DEPRECATED
- #include <ext/hash_map>
- /** Oddball linux namespace for hash_map */
- #define nspace __gnu_cxx
- #define BEGIN_HASHMAP_NAMESPACE namespace nspace {
- #define END_HASHMAP_NAMESPACE }
+ /** Where hash_map is varies from compiler to compiler
+ * as it is not standard unless we have tr1.
+ */
+ #ifndef WIN32
+ #ifdef HASHMAP_DEPRECATED
+ // GCC4+ has deprecated hash_map and uses tr1. But of course, uses a different include to MSVC. FOR FUCKS SAKE.
+ #include <tr1/unordered_map>
+ #define HAS_TR1_UNORDERED
+ #else
+ #include <ext/hash_map>
+ /** Oddball linux namespace for hash_map */
+ #define nspace __gnu_cxx
+ #define BEGIN_HASHMAP_NAMESPACE namespace nspace {
+ #define END_HASHMAP_NAMESPACE }
+ #endif
#else
- /** Yay, we have tr1! */
- #include <tr1/unordered_map>
- /** Not so oddball linux namespace for hash_map with gcc 4.0 and above */
+ #if _MSC_VER >= 1600
+ // New MSVC has tr1. Just to make things fucked up, though, MSVC and GCC use different includes! FFS.
+ #include <unordered_map>
+ #define HAS_TR1_UNORDERED
+ #define HASHMAP_DEPRECATED
+ #else
+ #define nspace stdext
+ /** Oddball windows namespace for hash_map */
+ using stdext::hash_map;
+ #define BEGIN_HASHMAP_NAMESPACE namespace nspace {
+ #define END_HASHMAP_NAMESPACE }
+ #endif
+ #endif
+
+ // tr1: restoring sanity to our headers. now if only compiler vendors could agree on a FUCKING INCLUDE FILE.
+ #ifdef HAS_TR1_UNORDERED
#define hash_map unordered_map
#define nspace std::tr1
#define BEGIN_HASHMAP_NAMESPACE namespace std { namespace tr1 {
#define END_HASHMAP_NAMESPACE } }
#endif
-#else
- #include <hash_map>
- #define nspace stdext
- /** Oddball windows namespace for hash_map */
- using stdext::hash_map;
- #define BEGIN_HASHMAP_NAMESPACE namespace nspace {
- #define END_HASHMAP_NAMESPACE }
-#endif
#endif
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 94c836c6f..536c42937 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -627,13 +627,13 @@ inline std::string& trim(std::string &str)
}
/** Hashing stuff is totally different on vc++'s hash_map implementation, so to save a buttload of
- * #ifdefs we'll just do it all at once
+ * #ifdefs we'll just do it all at once. Except, of course, with TR1, when it's the same as GCC.
*/
BEGIN_HASHMAP_NAMESPACE
/** Hashing function to hash irc::string
*/
-#ifdef WINDOWS
+#if defined(WINDOWS) && !defined(HAS_TR1_UNORDERED)
template<> class CoreExport hash_compare<irc::string, std::less<irc::string> >
{
public:
@@ -679,7 +679,7 @@ BEGIN_HASHMAP_NAMESPACE
* @param s A string to hash
* @return The hash value
*/
- size_t operator()(const irc::string &s) const;
+ size_t CoreExport operator()(const irc::string &s) const;
};
/* XXX FIXME: Implement a hash function overriding std::string's that works with TR1! */
@@ -687,10 +687,10 @@ BEGIN_HASHMAP_NAMESPACE
#ifdef HASHMAP_DEPRECATED
struct insensitive
#else
- template<> struct hash<std::string>
+ CoreExport template<> struct hash<std::string>
#endif
{
- size_t operator()(const std::string &s) const;
+ size_t CoreExport operator()(const std::string &s) const;
};
#endif
diff --git a/include/typedefs.h b/include/typedefs.h
index ca3efcc70..a40e6cfc2 100644
--- a/include/typedefs.h
+++ b/include/typedefs.h
@@ -14,8 +14,10 @@
#ifndef __TYPEDEF_H__
#define __TYPEDEF_H__
-#ifndef WIN32
-
+#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED)
+ typedef nspace::hash_map<std::string, User*, nspace::hash_compare<std::string, std::less<std::string> > > user_hash;
+ typedef nspace::hash_map<std::string, Channel*, nspace::hash_compare<std::string, std::less<std::string> > > chan_hash;
+#else
#ifdef HASHMAP_DEPRECATED
typedef nspace::hash_map<std::string, User*, nspace::insensitive, irc::StrHashComp> user_hash;
typedef nspace::hash_map<std::string, Channel*, nspace::insensitive, irc::StrHashComp> chan_hash;
@@ -23,10 +25,6 @@
typedef nspace::hash_map<std::string, User*, nspace::hash<std::string>, irc::StrHashComp> user_hash;
typedef nspace::hash_map<std::string, Channel*, nspace::hash<std::string>, irc::StrHashComp> chan_hash;
#endif
-#else
-
- typedef nspace::hash_map<std::string, User*, nspace::hash_compare<std::string, std::less<std::string> > > user_hash;
- typedef nspace::hash_map<std::string, Channel*, nspace::hash_compare<std::string, std::less<std::string> > > chan_hash;
#endif
/** Server name cache
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index a2b1eab0b..6c0ce82b8 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -60,14 +60,14 @@ void nspace::strlower(char *n)
}
}
-#ifndef WIN32
+#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED)
+ size_t nspace::hash_compare<std::string, std::less<std::string> >::operator()(const std::string &s) const
+#else
#ifdef HASHMAP_DEPRECATED
- size_t nspace::insensitive::operator()(const std::string &s) const
+ size_t CoreExport nspace::insensitive::operator()(const std::string &s) const
#else
size_t nspace::hash<std::string>::operator()(const std::string &s) const
#endif
-#else
- size_t nspace::hash_compare<std::string, std::less<std::string> >::operator()(const std::string &s) const
#endif
{
/* XXX: NO DATA COPIES! :)
@@ -83,10 +83,10 @@ void nspace::strlower(char *n)
}
-#ifndef WIN32
-size_t nspace::hash<irc::string>::operator()(const irc::string &s) const
+#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED)
+ size_t nspace::hash_compare<irc::string, std::less<irc::string> >::operator()(const irc::string &s) const
#else
-size_t nspace::hash_compare<irc::string, std::less<irc::string> >::operator()(const irc::string &s) const
+ size_t CoreExport nspace::hash<irc::string>::operator()(const irc::string &s) const
#endif
{
register size_t t = 0;
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index 7f95ad8c8..a32b5a445 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -26,7 +26,7 @@ class SpanningTreeUtilities;
/* This hash_map holds the hash equivalent of the server
* tree, used for rapid linear lookups.
*/
-#ifdef WINDOWS
+#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED)
typedef nspace::hash_map<std::string, TreeServer*, nspace::hash_compare<std::string, std::less<std::string> > > server_hash;
#else
#ifdef HASHCOMP_DEPRECATED
diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp
index eda1b74a3..e70270424 100644
--- a/src/modules/m_watch.cpp
+++ b/src/modules/m_watch.cpp
@@ -87,10 +87,10 @@
* Before you start screaming, this definition is only used here, so moving it to a header is pointless.
* Yes, it's horrid. Blame cl for being different. -- w00t
*/
-#ifdef WINDOWS
-typedef nspace::hash_map<irc::string, std::deque<User*>, nspace::hash_compare<irc::string, std::less<irc::string> > > watchentries;
+#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED)
+ typedef nspace::hash_map<irc::string, std::deque<User*>, nspace::hash_compare<irc::string, std::less<irc::string> > > watchentries;
#else
-typedef nspace::hash_map<irc::string, std::deque<User*>, nspace::hash<irc::string> > watchentries;
+ typedef nspace::hash_map<irc::string, std::deque<User*>, nspace::hash<irc::string> > watchentries;
#endif
typedef std::map<irc::string, std::string> watchlist;