]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
win: Last part of support required for VS2010:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 15 Aug 2009 11:32:49 +0000 (11:32 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 15 Aug 2009 11:32:49 +0000 (11:32 +0000)
NEEDS COMPILE TESTING ON: gcc3 (if possible), gcc4, vs2008.
 - Check for vs2010 in hash_map.h
   - use unordered_map if it exists
 - change all map creations to:
    #if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED)
       // old windows crap
    #else
       #if HASHMAP_DEPRECATED
           // tr1/gcc crap
       #endif
    #endif

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11524 e03df62e-2008-0410-955e-edbf42e46eb7

include/bancache.h
include/dns.h
include/hash_map.h
include/hashcomp.h
include/typedefs.h
src/hashcomp.cpp
src/modules/m_spanningtree/utils.h
src/modules/m_watch.cpp

index 9266149fc1507dbb7e5f8bcd499a4ad1b6b99143..5bfa2fa3f10b63eafafe3891668f3d5485897b67 100644 (file)
@@ -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.
index 4f577366bae4fb4bbe042c418f4028f3bd9e7812..fa42952965afae652a4c33bd7b241885f165bc94 100644 (file)
@@ -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
 
 /**
index dad08aa934e649f4e906749e853eb99370c8fad2..6e47d292b8199930734d9a0ed66d5b072da6b0c8 100644 (file)
  * ---------------------------------------------------
  */
 
-#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
index 94c836c6f0b39585836d0f3c4ea5ac5e4704a6a0..536c42937d2493f1649c7cc2c1e510598ce3ef9b 100644 (file)
@@ -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
index ca3efcc7018405dcc2f59f0d088482089eed9c03..a40e6cfc246e81b10a69274c6282f01ea6659b3f 100644 (file)
 #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;
                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
index a2b1eab0bbea81254959cd44faa0d893d0266ca9..6c0ce82b852a62cecb7bf304fdf37bf4eba31de5 100644 (file)
@@ -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;
index 7f95ad8c8d9ac5956dbcba2ee4f51ba2758fbaef..a32b5a445f69b7d3062d065307aa65733787715c 100644 (file)
@@ -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
index eda1b74a397d7080a9c8af5d235f54d92fa06b87..e70270424978a17b0a7aad85ed83f8394ba0784a 100644 (file)
  * 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;