From 01ce98f2746be837a64f5f9ed2c36eeaabae7462 Mon Sep 17 00:00:00 2001 From: w00t Date: Sat, 15 Aug 2009 11:32:49 +0000 Subject: win: Last part of support required for VS2010: 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 | 6 +++--- include/dns.h | 6 +++--- include/hash_map.h | 56 ++++++++++++++++++++++++++++++++---------------------- include/hashcomp.h | 10 +++++----- include/typedefs.h | 10 ++++------ 5 files changed, 48 insertions(+), 40 deletions(-) (limited to 'include') 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 > BanCacheHash; -#else +#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED) typedef nspace::hash_map > > BanCacheHash; +#else +typedef nspace::hash_map > 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 > dnscache; -#else +#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED) typedef nspace::hash_map > dnscache; +#else +typedef nspace::hash_map > 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 - /** 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 + #define HAS_TR1_UNORDERED + #else + #include + /** 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 - /** 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 + #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 - #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 > { 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 + CoreExport template<> struct hash #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 > > user_hash; + typedef nspace::hash_map > > chan_hash; +#else #ifdef HASHMAP_DEPRECATED typedef nspace::hash_map user_hash; typedef nspace::hash_map chan_hash; @@ -23,10 +25,6 @@ typedef nspace::hash_map, irc::StrHashComp> user_hash; typedef nspace::hash_map, irc::StrHashComp> chan_hash; #endif -#else - - typedef nspace::hash_map > > user_hash; - typedef nspace::hash_map > > chan_hash; #endif /** Server name cache -- cgit v1.2.3