diff options
author | Andy Schwerin <schwerin@10gen.com> | 2012-04-11 16:04:22 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@10gen.com> | 2012-04-12 12:22:05 -0400 |
commit | 6ae3906856e44147061a7fe7d60a1e73445ee40a (patch) | |
tree | 415c872041ca66e6f4033ca73a2a6c7080a04cf1 /src/mongo/util | |
parent | e819261720e48699679c511c69f2f82c2c6a94ab (diff) | |
download | mongo-6ae3906856e44147061a7fe7d60a1e73445ee40a.tar.gz |
Introduce mongo/platform/compiler.h.
Get rid of most uses of __attribute__ and __declspec outside of the
platform/compiler headers.
Diffstat (limited to 'src/mongo/util')
-rw-r--r-- | src/mongo/util/assert_util.h | 25 | ||||
-rw-r--r-- | src/mongo/util/scopeguard.h | 13 |
2 files changed, 15 insertions, 23 deletions
diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h index a5e2b358c2f..9d1c173de33 100644 --- a/src/mongo/util/assert_util.h +++ b/src/mongo/util/assert_util.h @@ -21,13 +21,7 @@ #include <typeinfo> #include "mongo/bson/inline_decls.h" - -// MONGO_NORETURN undefed at end of file -#ifdef __GNUC__ -# define MONGO_NORETURN __attribute__((__noreturn__)) -#else -# define MONGO_NORETURN -#endif +#include "mongo/platform/compiler.h" namespace mongo { @@ -153,15 +147,15 @@ namespace mongo { virtual void appendPrefix( std::stringstream& ss ) const; }; - void asserted(const char *msg, const char *file, unsigned line) MONGO_NORETURN; + MONGO_COMPILER_NORETURN void asserted(const char *msg, const char *file, unsigned line); void wasserted(const char *msg, const char *file, unsigned line); - void fassertFailed( int msgid ); + MONGO_COMPILER_NORETURN void fassertFailed( int msgid ); /** a "user assertion". throws UserAssertion. logs. typically used for errors that a user could cause, such as duplicate key, disk full, etc. */ - void uasserted(int msgid, const char *msg) MONGO_NORETURN; - void uasserted(int msgid , const std::string &msg); + MONGO_COMPILER_NORETURN void uasserted(int msgid, const char *msg); + MONGO_COMPILER_NORETURN void uasserted(int msgid , const std::string &msg); /** reported via lasterror, but don't throw exception */ void uassert_nothrow(const char *msg); @@ -169,10 +163,10 @@ namespace mongo { /** msgassert and massert are for errors that are internal but have a well defined error text std::string. a stack trace is logged. */ - void msgassertedNoTrace(int msgid, const char *msg) MONGO_NORETURN; + MONGO_COMPILER_NORETURN void msgassertedNoTrace(int msgid, const char *msg); inline void msgassertedNoTrace(int msgid, const std::string& msg) { msgassertedNoTrace( msgid , msg.c_str() ); } - void msgasserted(int msgid, const char *msg) MONGO_NORETURN; - void msgasserted(int msgid, const std::string &msg); + MONGO_COMPILER_NORETURN void msgasserted(int msgid, const char *msg); + MONGO_COMPILER_NORETURN void msgasserted(int msgid, const std::string &msg); /* convert various types of exceptions to strings */ inline std::string causedBy( const char* e ){ return (std::string)" :: caused by :: " + e; } @@ -225,7 +219,7 @@ namespace mongo { enum { ASSERT_ID_DUPKEY = 11000 }; /* throws a uassertion with an appropriate msg */ - void streamNotGood( int code , std::string msg , std::ios& myios ) MONGO_NORETURN; + MONGO_COMPILER_NORETURN void streamNotGood( int code , std::string msg , std::ios& myios ); inline void assertStreamGood(unsigned msgid, std::string msg, std::ios& myios) { if( !myios.good() ) streamNotGood(msgid, msg, myios); @@ -267,4 +261,3 @@ namespace mongo { problem() << "caught unknown exception in destructor (" << __FUNCTION__ << ")" << endl; \ } -#undef MONGO_NORETURN diff --git a/src/mongo/util/scopeguard.h b/src/mongo/util/scopeguard.h index 8ced04f47fc..9147e0fc72e 100644 --- a/src/mongo/util/scopeguard.h +++ b/src/mongo/util/scopeguard.h @@ -15,6 +15,8 @@ #ifndef LOKI_SCOPEGUARD_H_ #define LOKI_SCOPEGUARD_H_ +#include "mongo/platform/compiler.h" + namespace mongo { @@ -421,12 +423,9 @@ namespace mongo #define LOKI_CONCATENATE(s1, s2) LOKI_CONCATENATE_DIRECT(s1, s2) #define LOKI_ANONYMOUS_VARIABLE(str) LOKI_CONCATENATE(str, __LINE__) -#ifdef __GNUC__ -#define ON_BLOCK_EXIT ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) __attribute__ ((unused)) = MakeGuard -#define ON_BLOCK_EXIT_OBJ ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) __attribute__ ((unused)) = MakeObjGuard -#else -#define ON_BLOCK_EXIT ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = MakeGuard -#define ON_BLOCK_EXIT_OBJ ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = MakeObjGuard -#endif +#define ON_BLOCK_EXIT \ + MONGO_COMPILER_VARIABLE_UNUSED ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = MakeGuard +#define ON_BLOCK_EXIT_OBJ \ + MONGO_COMPILER_VARIABLE_UNUSED ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = MakeObjGuard #endif //LOKI_SCOPEGUARD_H_ |