diff options
author | Jonathan Reams <jbreams@mongodb.com> | 2015-03-26 18:00:00 -0400 |
---|---|---|
committer | Jonathan Reams <jbreams@mongodb.com> | 2015-03-26 18:30:00 -0400 |
commit | ef7f17be8085488ba965286fb97927a7ce3600e7 (patch) | |
tree | 48caef5aaf331f1035c02489a78feab2ccaef789 /src/mongo | |
parent | 66c14dd70dd4427fef0d424b9675570614e13ca7 (diff) | |
download | mongo-ef7f17be8085488ba965286fb97927a7ce3600e7.tar.gz |
SERVER-9563 Add support for config.h header
Diffstat (limited to 'src/mongo')
50 files changed, 308 insertions, 243 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript index 713fabfb598..6cac8800221 100644 --- a/src/mongo/SConscript +++ b/src/mongo/SConscript @@ -367,6 +367,33 @@ buildInfo = env.Substfile( ]) env.NoCache(buildInfo) +config_header_substs = ( + ('@mongo_config_byte_order@', 'MONGO_CONFIG_BYTE_ORDER'), + ('@mongo_config_have___declspec_thread@', 'MONGO_CONFIG_HAVE___DECLSPEC_THREAD'), + ('@mongo_config_have___thread@', 'MONGO_CONFIG_HAVE___THREAD'), + ('@mongo_config_have_execinfo_backtrace@', 'MONGO_CONFIG_HAVE_EXECINFO_BACKTRACE'), + ('@mongo_config_have_header_unistd_h@', 'MONGO_CONFIG_HAVE_HEADER_UNISTD_H'), + ('@mongo_config_have_posix_monotonic_clock@', 'MONGO_CONFIG_HAVE_POSIX_MONOTONIC_CLOCK'), + ('@mongo_config_have_std_is_trivially_copyable@', 'MONGO_CONFIG_HAVE_STD_IS_TRIVIALLY_COPYABLE'), + ('@mongo_config_have_std_make_unique@', 'MONGO_CONFIG_HAVE_STD_MAKE_UNIQUE'), + ('@mongo_config_optimized_build@', 'MONGO_CONFIG_OPTIMIZED_BUILD'), + ('@mongo_config_ssl@', 'MONGO_CONFIG_SSL'), + ('@mongo_config_ssl_fips@', 'MONGO_CONFIG_SSL_FIPS'), + ('@mongo_config_use_gdbserver@', 'MONGO_CONFIG_USE_GDBSERVER'), +) + +def makeConfigHeaderDefine(self, key): + val = "// #undef {0}".format(key) + if key in self['CONFIG_HEADER_DEFINES']: + val = "#define {0} {1}".format(key, self['CONFIG_HEADER_DEFINES'][key]) + return val +env.AddMethod(makeConfigHeaderDefine) + +configHeaderFile = env.Substfile( + 'config.h.in', + SUBST_DICT=[(k, env.makeConfigHeaderDefine(v)) for (k, v) in config_header_substs] +) + versionFile = env.Substfile( 'util/version.cpp.in', SUBST_DICT=[ @@ -827,7 +854,10 @@ env.Library('stacktrace', 'version', '$BUILD_DIR/mongo/base/base']) -env.Library(target='quick_exit', +quick_exit_env = env.Clone() +if has_option('gcov'): + quick_exit_env.Append(CPPDEFINES=['MONGO_GCOV']) +quick_exit_env.Library(target='quick_exit', source=[ 'util/quick_exit.cpp', ]) @@ -1284,7 +1314,10 @@ env.JSHeader( ]) if not has_option('noshell') and usev8: - env.Library("shell_core", + shell_core_env = env.Clone() + if has_option("safeshell"): + shell_core_env.Append(CPPDEFINES=["MONGO_SAFE_SHELL"]) + shell_core_env.Library("shell_core", source=[ "shell/bench.cpp", "shell/clientAndShell.cpp", @@ -1306,7 +1339,7 @@ if not has_option('noshell') and usev8: ]) # mongo shell options - env.Library("shell_options", ["shell/shell_options.cpp"], + shell_core_env.Library("shell_options", ["shell/shell_options.cpp"], LIBDEPS=['$BUILD_DIR/mongo/util/options_parser/options_parser_init']) shellEnv = env.Clone() diff --git a/src/mongo/base/data_view.h b/src/mongo/base/data_view.h index abc6b57f4c6..5801ca26635 100644 --- a/src/mongo/base/data_view.h +++ b/src/mongo/base/data_view.h @@ -27,6 +27,8 @@ #pragma once +#include "mongo/config.h" + #include <cstring> #include <type_traits> @@ -49,7 +51,7 @@ namespace mongo { template<typename T> const ConstDataView& readNative(T* t, size_t offset = 0) const { -#if MONGO_HAVE_STD_IS_TRIVIALLY_COPYABLE +#if MONGO_CONFIG_HAVE_STD_IS_TRIVIALLY_COPYABLE static_assert(std::is_trivially_copyable<T>::value, "Type for DataView::readNative must be trivially copyable"); #endif @@ -95,7 +97,7 @@ namespace mongo { template<typename T> DataView& writeNative(const T& value, std::size_t offset = 0) { -#if MONGO_HAVE_STD_IS_TRIVIALLY_COPYABLE +#if MONGO_CONFIG_HAVE_STD_IS_TRIVIALLY_COPYABLE static_assert(std::is_trivially_copyable<T>::value, "Type for DataView::writeNative must be trivially copyable"); #endif diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp index fcbdd90e0c0..b8e1f555dc5 100644 --- a/src/mongo/client/dbclient.cpp +++ b/src/mongo/client/dbclient.cpp @@ -29,6 +29,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/bson/util/bson_extract.h" @@ -631,7 +633,7 @@ namespace mongo { result.toString(), _authMongoCR(db, user, password, &result, digestPassword)); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL else if (mechanism == StringData("MONGODB-X509", StringData::LiteralTag())){ std::string db; if (params.hasField(saslCommandUserSourceFieldName)) { @@ -1073,7 +1075,7 @@ namespace mongo { LOG( 1 ) << "connected to server " << toString() << endl; } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL int sslModeVal = sslGlobalParams.sslMode.load(); if (sslModeVal == SSLGlobalParams::SSLMode_preferSSL || sslModeVal == SSLGlobalParams::SSLMode_requireSSL) { @@ -1653,7 +1655,7 @@ namespace mongo { say(m); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL static SimpleMutex s_mtx("SSLManager"); static SSLManagerInterface* s_sslMgr(NULL); diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h index dd44199d930..a5873454d79 100644 --- a/src/mongo/client/dbclientinterface.h +++ b/src/mongo/client/dbclientinterface.h @@ -32,6 +32,8 @@ #pragma once +#include "mongo/config.h" + #include <boost/noncopyable.hpp> #include <boost/scoped_ptr.hpp> @@ -1377,7 +1379,7 @@ namespace mongo { static AtomicInt32 _numConnections; static bool _lazyKillCursor; // lazy means we piggy back kill cursors on next op -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL SSLManagerInterface* sslManager(); #endif }; diff --git a/src/mongo/config.h.in b/src/mongo/config.h.in new file mode 100644 index 00000000000..cac96ae4b25 --- /dev/null +++ b/src/mongo/config.h.in @@ -0,0 +1,66 @@ +/** +* Copyright (C) 2015 MongoDB Inc. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License, version 3, +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +* As a special exception, the copyright holders give permission to link the +* code of portions of this program with the OpenSSL library under certain +* conditions as described in each individual source file and distribute +* linked combinations including the program with the OpenSSL library. You +* must comply with the GNU Affero General Public License in all respects for +* all of the code used other than as permitted herein. If you modify file(s) +* with this exception, you may extend this exception to your version of the +* file(s), but you are not obligated to do so. If you do not wish to do so, +* delete this exception statement from your version. If you delete this +* exception statement from all source files in the program, then also delete +* it in the license file. +*/ + +#pragma once + +// Define to target byte order (1234 vs 4321) +@mongo_config_byte_order@ + +// Defined if __declspec(thread) is available +@mongo_config_have___declspec_thread@ + +// Defined if GCC thread-local storage is available +@mongo_config_have___thread@ + +// Defined if execinfo.h and backtrace are available +@mongo_config_have_execinfo_backtrace@ + +// Defined if unitstd.h is available +@mongo_config_have_header_unistd_h@ + +// Defined if a POSIX monotonic clock is available +@mongo_config_have_posix_monotonic_clock@ + +// Defined if std::is_trivially_copyable is available +@mongo_config_have_std_is_trivially_copyable@ + +// Defined if std::make_unique is available +@mongo_config_have_std_make_unique@ + +// Defined if building an optimized build +@mongo_config_optimized_build@ + +// Defined if SSL support is enabled +@mongo_config_ssl@ + +// Defined if SSL FIPS mode is enabled +@mongo_config_ssl_fips@ + +// Defined if gdbserver support is enabled +@mongo_config_use_gdbserver@ + diff --git a/src/mongo/crypto/crypto_openssl.cpp b/src/mongo/crypto/crypto_openssl.cpp index 576adf9d54e..3d22ad406a6 100644 --- a/src/mongo/crypto/crypto_openssl.cpp +++ b/src/mongo/crypto/crypto_openssl.cpp @@ -26,12 +26,14 @@ * it in the license file. */ -#ifndef MONGO_SSL -#error This file should only be included in SSL-enabled builds -#endif +#include "mongo/config.h" #include "mongo/platform/basic.h" +#ifndef MONGO_CONFIG_SSL +#error This file should only be included in SSL-enabled builds +#endif + #include <openssl/sha.h> #include <openssl/evp.h> #include <openssl/hmac.h> diff --git a/src/mongo/crypto/crypto_tom.cpp b/src/mongo/crypto/crypto_tom.cpp index 9051d647f2c..85cc8387bb3 100644 --- a/src/mongo/crypto/crypto_tom.cpp +++ b/src/mongo/crypto/crypto_tom.cpp @@ -26,12 +26,14 @@ * it in the license file. */ -#ifdef MONGO_SSL -#error This file should not be included if compiling with SSL support -#endif +#include "mongo/config.h" #include "mongo/platform/basic.h" +#ifdef MONGO_CONFIG_SSL +#error This file should not be included if compiling with SSL support +#endif + #include "mongo/crypto/tom/tomcrypt.h" namespace mongo { diff --git a/src/mongo/db/commands/authentication_commands.cpp b/src/mongo/db/commands/authentication_commands.cpp index 3ab8b0852ce..b260fd483cd 100644 --- a/src/mongo/db/commands/authentication_commands.cpp +++ b/src/mongo/db/commands/authentication_commands.cpp @@ -28,6 +28,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kAccessControl +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/db/commands/authentication_commands.h" @@ -206,7 +208,7 @@ namespace mongo { if (mechanism == "MONGODB-CR") { return _authenticateCR(txn, user, cmdObj); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL if (mechanism == "MONGODB-X509") { return _authenticateX509(txn, user, cmdObj); } @@ -304,7 +306,7 @@ namespace mongo { return Status::OK(); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL void canonicalizeClusterDN(std::vector<std::string>* dn) { // remove all RDNs we don't care about for (size_t i=0; i<dn->size(); i++) { diff --git a/src/mongo/db/commands/parameters.cpp b/src/mongo/db/commands/parameters.cpp index adaa3b0bda4..048175dd109 100644 --- a/src/mongo/db/commands/parameters.cpp +++ b/src/mongo/db/commands/parameters.cpp @@ -28,6 +28,8 @@ * it in the license file. */ +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include <set> @@ -454,7 +456,7 @@ namespace mongo { } virtual Status setFromString(const std::string& str) { -#ifndef MONGO_SSL +#ifndef MONGO_CONFIG_SSL return Status(ErrorCodes::IllegalOperation, mongoutils::str::stream() << "Unable to set sslMode, SSL support is not compiled into server"); #endif @@ -522,7 +524,7 @@ namespace mongo { } virtual Status setFromString(const std::string& str) { -#ifndef MONGO_SSL +#ifndef MONGO_CONFIG_SSL return Status(ErrorCodes::IllegalOperation, mongoutils::str::stream() << "Unable to set clusterAuthMode, " << "SSL support is not compiled into server"); @@ -546,7 +548,7 @@ namespace mongo { } serverGlobalParams.clusterAuthMode.store (ServerGlobalParams::ClusterAuthMode_sendX509); -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL setInternalUserAuthParams(BSON(saslCommandMechanismFieldName << "MONGODB-X509" << saslCommandUserDBFieldName << "$external" << diff --git a/src/mongo/db/commands/server_status.cpp b/src/mongo/db/commands/server_status.cpp index 709142973f7..37084cc2e28 100644 --- a/src/mongo/db/commands/server_status.cpp +++ b/src/mongo/db/commands/server_status.cpp @@ -30,6 +30,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kCommand +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/db/auth/action_set.h" @@ -276,7 +278,7 @@ namespace mongo { } network; -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL class Security : public ServerStatusSection { public: Security() : ServerStatusSection( "security" ) {} diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp index 1d192b0095e..47b6cc43cf5 100644 --- a/src/mongo/db/commands/user_management_commands.cpp +++ b/src/mongo/db/commands/user_management_commands.cpp @@ -28,6 +28,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kAccessControl +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include <string> @@ -399,7 +401,7 @@ namespace mongo { "\"createUser\" command requires a \"roles\" array")); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL if (args.userName.getDB() == "$external" && getSSLManager() && getSSLManager()->getSSLConfiguration() diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index dcdc03b2537..56d502b99b5 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -30,6 +30,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include <boost/thread/thread.hpp> @@ -820,7 +822,7 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(CreateReplicationManager, ("SetGlobalEnviro return Status::OK(); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL MONGO_INITIALIZER_GENERAL(setSSLManagerType, MONGO_NO_PREREQUISITES, ("SSLManager"))(InitializerContext* context) { diff --git a/src/mongo/db/initialize_server_global_state.cpp b/src/mongo/db/initialize_server_global_state.cpp index 91927792857..3f2b8444edb 100644 --- a/src/mongo/db/initialize_server_global_state.cpp +++ b/src/mongo/db/initialize_server_global_state.cpp @@ -28,6 +28,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kControl +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/db/initialize_server_global_state.h" @@ -364,7 +366,7 @@ namespace mongo { getGlobalAuthorizationManager()->setAuthEnabled(true); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL if (clusterAuthMode == ServerGlobalParams::ClusterAuthMode_x509 || clusterAuthMode == ServerGlobalParams::ClusterAuthMode_sendX509) { diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 242a81db415..26af00cad16 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -89,7 +89,6 @@ #include "mongo/scripting/engine.h" #include "mongo/util/exit.h" #include "mongo/util/fail_point_service.h" -#include "mongo/util/gcov.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" #include "mongo/util/quick_exit.h" @@ -1277,8 +1276,6 @@ namespace { } NOINLINE_DECL void dbexit( ExitCode rc, const char *why ) { - flushForGcov(); - audit::logShutdown(currentClient.get()); log(LogComponent::kControl) << "dbexit: " << why << " rc: " << rc; diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index 9a7a8780851..7a14ebbfc3d 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -28,6 +28,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kControl +#include "mongo/config.h" + #include "mongo/db/mongod_options.h" #include <boost/filesystem.hpp> @@ -82,7 +84,7 @@ namespace mongo { } #endif -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL moe::OptionSection ssl_options("SSL options"); ret = addSSLServerOptions(&ssl_options); @@ -418,7 +420,7 @@ namespace mongo { options->addSection(ms_options); options->addSection(rs_options); options->addSection(sharding_options); -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL options->addSection(ssl_options); #endif options->addSection(storage_options); @@ -628,7 +630,7 @@ namespace mongo { return ret; } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL ret = canonicalizeSSLServerOptions(params); if (!ret.isOK()) { return ret; diff --git a/src/mongo/db/server_options_helpers.cpp b/src/mongo/db/server_options_helpers.cpp index 38b7d87ee74..1a66900842d 100644 --- a/src/mongo/db/server_options_helpers.cpp +++ b/src/mongo/db/server_options_helpers.cpp @@ -28,6 +28,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kControl +#include "mongo/config.h" + #include "mongo/db/server_options_helpers.h" #ifdef _WIN32 @@ -471,7 +473,7 @@ namespace { } #endif -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL Status ret = validateSSLServerOptions(params); if (!ret.isOK()) { return ret; @@ -942,7 +944,7 @@ namespace { (ServerGlobalParams::ClusterAuthMode_keyFile); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL ret = storeSSLServerOptions(params); if (!ret.isOK()) { return ret; diff --git a/src/mongo/db/storage/key_string_test.cpp b/src/mongo/db/storage/key_string_test.cpp index 55acef635ae..161e0d6f2cc 100644 --- a/src/mongo/db/storage/key_string_test.cpp +++ b/src/mongo/db/storage/key_string_test.cpp @@ -30,6 +30,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage +#include "mongo/config.h" + #include <cmath> #include "mongo/platform/basic.h" @@ -619,7 +621,7 @@ TEST(KeyStringTest, AllPermCompare) { TEST(KeyStringTest, AllPerm2Compare) { // This test can take over a minute without optimizations. Re-enable if you need to debug it. -#if !defined(MONGO_OPTIMIZED_BUILD) +#if !defined(MONGO_CONFIG_OPTIMIZED_BUILD) log() << "\t\t\tskipping test on non-optimized build"; return; #endif diff --git a/src/mongo/db/storage/mmap_v1/record_access_tracker.cpp b/src/mongo/db/storage/mmap_v1/record_access_tracker.cpp index 7d9f60ca308..0ad32346977 100644 --- a/src/mongo/db/storage/mmap_v1/record_access_tracker.cpp +++ b/src/mongo/db/storage/mmap_v1/record_access_tracker.cpp @@ -26,6 +26,8 @@ * it in the license file. */ +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/db/storage/mmap_v1/record_access_tracker.h" @@ -275,12 +277,12 @@ namespace mongo { } // These need to be outside the ps namespace due to the way they are defined -#if defined(MONGO_HAVE___THREAD) +#if defined(MONGO_CONFIG_HAVE___THREAD) __thread PointerTable::Data _pointerTableData; PointerTable::Data* PointerTable::getData() { return &_pointerTableData; } -#elif defined(MONGO_HAVE___DECLSPEC_THREAD) +#elif defined(MONGO_CONFIG_HAVE___DECLSPEC_THREAD) __declspec( thread ) PointerTable::Data _pointerTableData; PointerTable::Data* PointerTable::getData() { return &_pointerTableData; diff --git a/src/mongo/dbtests/dbtests.cpp b/src/mongo/dbtests/dbtests.cpp index 4391aa1b2a9..f82bb2402eb 100644 --- a/src/mongo/dbtests/dbtests.cpp +++ b/src/mongo/dbtests/dbtests.cpp @@ -44,7 +44,6 @@ #include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/repl/replication_coordinator_mock.h" #include "mongo/dbtests/framework.h" -#include "mongo/util/gcov.h" #include "mongo/util/quick_exit.h" #include "mongo/util/signal_handlers_synchronous.h" #include "mongo/util/startup_test.h" @@ -129,7 +128,6 @@ int wmain(int argc, wchar_t* argvW[], wchar_t* envpW[]) { #else int main(int argc, char* argv[], char** envp) { int exitCode = dbtestsMain(argc, argv, envp); - flushForGcov(); quickExit(exitCode); } #endif diff --git a/src/mongo/dbtests/perftests.cpp b/src/mongo/dbtests/perftests.cpp index 38dfc814d8e..e7d05a93bfb 100644 --- a/src/mongo/dbtests/perftests.cpp +++ b/src/mongo/dbtests/perftests.cpp @@ -36,6 +36,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include <boost/filesystem/operations.hpp> @@ -287,7 +289,7 @@ namespace PerfTests { inf.append("os", "win"); #endif inf.append("git", gitVersion()); -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL inf.append("OpenSSL", openSSLVersion()); #endif inf.append("boost", BOOST_VERSION); @@ -1433,23 +1435,7 @@ namespace PerfTests { add< Throw< thr1 > >(); add< Throw< thr2 > >(); add< Throw< thr3 > >(); - -#if !defined(__clang__) || !defined(MONGO_OPTIMIZED_BUILD) - // clang-3.2 (and earlier?) miscompiles this test when optimization is on (see - // SERVER-9767 and SERVER-11183 for additional details, including a link to the - // LLVM ticket and LLVM fix). - // - // Ideally, the test above would also say - // || (__clang_major__ > 3) || ((__clang_major__ == 3) && (__clang_minor__ > 2)) - // so that the test would still run on known good vesrions of clang; see - // comments in SERVER-11183 for why that doesn't work. - // - // TODO: Remove this when we no longer need to support clang-3.2. We should - // also consider requiring clang > 3.2 in our configure tests once XCode 5 is - // ubiquitious. add< Throw< thr4 > >(); -#endif - add< Timer >(); add< Sleep0Ms >(); #if defined(__USE_XOPEN2K) diff --git a/src/mongo/installer/msi/SConscript b/src/mongo/installer/msi/SConscript index 425cfd4753d..984a709178e 100644 --- a/src/mongo/installer/msi/SConscript +++ b/src/mongo/installer/msi/SConscript @@ -49,7 +49,7 @@ if 'enterprise' in env['MONGO_MODULES']: upgrade_code = 'E7FE8DF3-00F1-4434-97DF-2721E7F712FA' # Community else: - if 'MONGO_SSL' in env['CPPDEFINES']: + if has_option('ssl'): msi_edition = 'SSL' else: msi_edition = 'Standard' diff --git a/src/mongo/platform/backtrace.cpp b/src/mongo/platform/backtrace.cpp index e8efed8191d..8ed3303decd 100644 --- a/src/mongo/platform/backtrace.cpp +++ b/src/mongo/platform/backtrace.cpp @@ -25,8 +25,10 @@ * then also delete it in the license file. */ +#include "mongo/config.h" + #if !defined(_WIN32) -#if defined(__sun) || !defined(MONGO_HAVE_EXECINFO_BACKTRACE) +#if defined(__sun) || !defined(MONGO_CONFIG_HAVE_EXECINFO_BACKTRACE) #include "mongo/platform/backtrace.h" diff --git a/src/mongo/platform/backtrace.h b/src/mongo/platform/backtrace.h index ddb695b2ba8..be4dd033d30 100644 --- a/src/mongo/platform/backtrace.h +++ b/src/mongo/platform/backtrace.h @@ -27,8 +27,10 @@ #pragma once +#include "mongo/config.h" + #if !defined(_WIN32) -#if defined(__sun) || !defined(MONGO_HAVE_EXECINFO_BACKTRACE) +#if defined(__sun) || !defined(MONGO_CONFIG_HAVE_EXECINFO_BACKTRACE) namespace mongo { namespace pal { diff --git a/src/mongo/platform/endian.h b/src/mongo/platform/endian.h index 8bccd2bb6c8..86a5e55b157 100644 --- a/src/mongo/platform/endian.h +++ b/src/mongo/platform/endian.h @@ -27,6 +27,8 @@ #pragma once +#include "mongo/config.h" + #include <climits> #include <cstring> #include <boost/static_assert.hpp> @@ -116,7 +118,7 @@ # define MONGO_UINT64_SWAB(v) endian::bswap_slow64(v) #endif -#if MONGO_BYTE_ORDER == MONGO_LITTLE_ENDIAN +#if MONGO_CONFIG_BYTE_ORDER == MONGO_LITTLE_ENDIAN # define htobe16(v) MONGO_UINT16_SWAB(v) # define htobe32(v) MONGO_UINT32_SWAB(v) # define htobe64(v) MONGO_UINT64_SWAB(v) @@ -129,7 +131,7 @@ # define le16toh(v) (v) # define le32toh(v) (v) # define le64toh(v) (v) -#elif MONGO_BYTE_ORDER == MONGO_BIG_ENDIAN +#elif MONGO_CONFIG_BYTE_ORDER == MONGO_BIG_ENDIAN # define htobe16(v) (v) # define htobe32(v) (v) # define htobe64(v) (v) @@ -144,7 +146,7 @@ # define le64toh(v) MONGO_UINT64_SWAB(v) #else # error "The endianness of target architecture is unknown. " \ - "Please define MONGO_BYTE_ORDER" + "Please define MONGO_CONFIG_BYTE_ORDER" #endif namespace mongo { diff --git a/src/mongo/platform/endian_test.cpp b/src/mongo/platform/endian_test.cpp index ab12b8c3fa3..ca6ae2a5ce4 100644 --- a/src/mongo/platform/endian_test.cpp +++ b/src/mongo/platform/endian_test.cpp @@ -25,6 +25,8 @@ * then also delete it in the license file. */ +#include "mongo/config.h" + #include "mongo/platform/endian.h" #include <cstring> @@ -79,7 +81,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(be, nativeToBig(le)); #else ASSERT_EQUALS(be, nativeToBig(be)); @@ -94,7 +96,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(be, nativeToBig(le)); #else ASSERT_EQUALS(be, nativeToBig(be)); @@ -109,7 +111,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(be, nativeToBig(le)); #else ASSERT_EQUALS(be, nativeToBig(be)); @@ -124,7 +126,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(be, nativeToBig(le)); #else ASSERT_EQUALS(be, nativeToBig(be)); @@ -139,7 +141,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(be, nativeToBig(le)); #else ASSERT_EQUALS(be, nativeToBig(be)); @@ -154,7 +156,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(be, nativeToBig(le)); #else ASSERT_EQUALS(be, nativeToBig(be)); @@ -169,7 +171,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(be, nativeToBig(le)); #else ASSERT_EQUALS(be, nativeToBig(be)); @@ -184,7 +186,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(be, nativeToBig(le)); #else ASSERT_EQUALS(be, nativeToBig(be)); @@ -199,7 +201,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, nativeToLittle(le)); #else ASSERT_EQUALS(le, nativeToLittle(be)); @@ -214,7 +216,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, nativeToLittle(le)); #else ASSERT_EQUALS(le, nativeToLittle(be)); @@ -229,7 +231,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, nativeToLittle(le)); #else ASSERT_EQUALS(le, nativeToLittle(be)); @@ -244,7 +246,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, nativeToLittle(le)); #else ASSERT_EQUALS(le, nativeToLittle(be)); @@ -259,7 +261,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, nativeToLittle(le)); #else ASSERT_EQUALS(le, nativeToLittle(be)); @@ -274,7 +276,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, nativeToLittle(le)); #else ASSERT_EQUALS(le, nativeToLittle(be)); @@ -289,7 +291,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, nativeToLittle(le)); #else ASSERT_EQUALS(le, nativeToLittle(be)); @@ -304,7 +306,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, nativeToLittle(le)); #else ASSERT_EQUALS(le, nativeToLittle(be)); @@ -319,7 +321,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, littleToNative(le)); #else ASSERT_EQUALS(be, littleToNative(le)); @@ -334,7 +336,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, littleToNative(le)); #else ASSERT_EQUALS(be, littleToNative(le)); @@ -349,7 +351,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, littleToNative(le)); #else ASSERT_EQUALS(be, littleToNative(le)); @@ -364,7 +366,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, littleToNative(le)); #else ASSERT_EQUALS(be, littleToNative(le)); @@ -379,7 +381,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, littleToNative(le)); #else ASSERT_EQUALS(be, littleToNative(le)); @@ -394,7 +396,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, littleToNative(le)); #else ASSERT_EQUALS(be, littleToNative(le)); @@ -409,7 +411,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, littleToNative(le)); #else ASSERT_EQUALS(be, littleToNative(le)); @@ -424,7 +426,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, littleToNative(le)); #else ASSERT_EQUALS(be, littleToNative(le)); @@ -439,7 +441,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, bigToNative(be)); #else ASSERT_EQUALS(be, bigToNative(be)); @@ -454,7 +456,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, bigToNative(be)); #else ASSERT_EQUALS(be, bigToNative(be)); @@ -469,7 +471,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, bigToNative(be)); #else ASSERT_EQUALS(be, bigToNative(be)); @@ -484,7 +486,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, bigToNative(be)); #else ASSERT_EQUALS(be, bigToNative(be)); @@ -499,7 +501,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, bigToNative(be)); #else ASSERT_EQUALS(be, bigToNative(be)); @@ -514,7 +516,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, bigToNative(be)); #else ASSERT_EQUALS(be, bigToNative(be)); @@ -529,7 +531,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, bigToNative(be)); #else ASSERT_EQUALS(be, bigToNative(be)); @@ -544,7 +546,7 @@ namespace mongo { std::memcpy(&le, le_buf, sizeof(le)); std::memcpy(&be, be_buf, sizeof(be)); -#if MONGO_BYTE_ORDER == 1234 +#if MONGO_CONFIG_BYTE_ORDER == 1234 ASSERT_EQUALS(le, bigToNative(be)); #else ASSERT_EQUALS(be, bigToNative(be)); diff --git a/src/mongo/s/mongos_options.cpp b/src/mongo/s/mongos_options.cpp index 566ac2e033a..592e3ba9f49 100644 --- a/src/mongo/s/mongos_options.cpp +++ b/src/mongo/s/mongos_options.cpp @@ -28,6 +28,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kSharding +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/s/mongos_options.h" @@ -72,7 +74,7 @@ namespace mongo { } #endif -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL moe::OptionSection ssl_options("SSL options"); ret = addSSLServerOptions(&ssl_options); @@ -116,7 +118,7 @@ namespace mongo { options->addSection(sharding_options); -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL options->addSection(ssl_options); #endif @@ -177,7 +179,7 @@ namespace mongo { return ret; } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL ret = canonicalizeSSLServerOptions(params); if (!ret.isOK()) { return ret; diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp index 9e1127ea3b1..c6bc28e5d8f 100644 --- a/src/mongo/s/server.cpp +++ b/src/mongo/s/server.cpp @@ -30,6 +30,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kSharding +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/s/server.h" @@ -76,7 +78,6 @@ #include "mongo/util/concurrency/thread_name.h" #include "mongo/util/exception_filter_win32.h" #include "mongo/util/exit.h" -#include "mongo/util/gcov.h" #include "mongo/util/log.h" #include "mongo/util/net/message.h" #include "mongo/util/net/message_server.h" @@ -417,7 +418,7 @@ MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) { return Status::OK(); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL MONGO_INITIALIZER_GENERAL(setSSLManagerType, MONGO_NO_PREREQUISITES, ("SSLManager"))(InitializerContext* context) { @@ -514,6 +515,5 @@ void mongo::dbexit( ExitCode rc, const char *why ) { log() << "dbexit: " << why << " rc:" << rc << endl; - flushForGcov(); quickExit(rc); } diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp index 979e5cc8625..65f26fe7182 100644 --- a/src/mongo/shell/shell_options.cpp +++ b/src/mongo/shell/shell_options.cpp @@ -26,6 +26,8 @@ * then also delete it in the license file. */ +#include "mongo/config.h" + #include "mongo/shell/shell_options.h" #include <boost/filesystem/operations.hpp> @@ -107,7 +109,7 @@ namespace mongo { "enable IPv6 support (disabled by default)"); Status ret = Status::OK(); -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL ret = addSSLClientOptions(options); if (!ret.isOK()) { return ret; @@ -184,7 +186,7 @@ namespace mongo { if (params.count("quiet")) { mongo::serverGlobalParams.quiet = true; } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL Status ret = storeSSLClientOptions(params); if (!ret.isOK()) { return ret; @@ -313,7 +315,7 @@ namespace mongo { } Status validateMongoShellOptions(const moe::Environment& params) { -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL Status ret = validateSSLMongoShellOptions(params); if (!ret.isOK()) { return ret; diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp index ce5b22f9509..395db18d5e4 100644 --- a/src/mongo/shell/shell_utils_launcher.cpp +++ b/src/mongo/shell/shell_utils_launcher.cpp @@ -456,8 +456,6 @@ namespace mongo { env[0] = NULL; env[1] = NULL; - bool isMongos = ( _argv[0].find( "mongos" ) != string::npos ); - pid_t nativePid = fork(); _pid = ProcessId::fromNative(nativePid); // Async signal unsafe functions should not be called in the child process. @@ -474,18 +472,6 @@ namespace mongo { quickExit(-1); //do not pass go, do not call atexit handlers } - // Heap-check for mongos only. 'argv[0]' must be in the path format. - if ( isMongos ) { -#if defined(HEAP_CHECKING) - env[0] = "HEAPCHECK=normal"; - env[1] = NULL; - - // NOTE execve is async signal safe, but it is not clear that execvpe is async - // signal safe. - execvpe( argv[ 0 ], const_cast<char**>(argv) , const_cast<char**>(env) ); -#endif // HEAP_CHECKING - } - // NOTE execve is async signal safe, but it is not clear that execvp is async // signal safe. execvp( argv[ 0 ], const_cast<char**>(argv) ); diff --git a/src/mongo/stdx/memory.h b/src/mongo/stdx/memory.h index aa93e14f545..7bc01af79d9 100644 --- a/src/mongo/stdx/memory.h +++ b/src/mongo/stdx/memory.h @@ -28,7 +28,9 @@ #pragma once -#if defined(MONGO_HAVE_STD_MAKE_UNIQUE) +#include "mongo/config.h" + +#if defined(MONGO_CONFIG_HAVE_STD_MAKE_UNIQUE) #include <memory> diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h index 17e00082b77..0e33e404bdf 100644 --- a/src/mongo/util/assert_util.h +++ b/src/mongo/util/assert_util.h @@ -307,15 +307,13 @@ namespace mongo { */ #define MONGO_dassert(x) if (kDebugBuild) invariant(x) -#ifdef MONGO_EXPOSE_MACROS -# define dassert MONGO_dassert -# define verify(expression) MONGO_verify(expression) -# define invariant MONGO_invariant -# define invariantOK MONGO_invariantOK -# define uassert MONGO_uassert -# define wassert MONGO_wassert -# define massert MONGO_massert -#endif +#define dassert MONGO_dassert +#define verify(expression) MONGO_verify(expression) +#define invariant MONGO_invariant +#define invariantOK MONGO_invariantOK +#define uassert MONGO_uassert +#define wassert MONGO_wassert +#define massert MONGO_massert // some special ids that we want to duplicate diff --git a/src/mongo/util/background.cpp b/src/mongo/util/background.cpp index d1ad927bb8f..4d484dc82b9 100644 --- a/src/mongo/util/background.cpp +++ b/src/mongo/util/background.cpp @@ -29,6 +29,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kCommand +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/util/background.h" @@ -166,7 +168,7 @@ namespace mongo { // We must cache this value so that we can use it after we leave the following scope. const bool selfDelete = _selfDelete; -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL // TODO(sverch): Allow people who use the BackgroundJob to also specify cleanup tasks. // Currently the networking code depends on this class and this class depends on the // networking code because of this ad hoc cleanup. diff --git a/src/mongo/util/concurrency/mutex.h b/src/mongo/util/concurrency/mutex.h index 5e207e7662b..835db801f37 100644 --- a/src/mongo/util/concurrency/mutex.h +++ b/src/mongo/util/concurrency/mutex.h @@ -39,7 +39,6 @@ #include "mongo/bson/inline_decls.h" #include "mongo/util/assert_util.h" -#include "mongo/util/heapcheck.h" #include "mongo/util/concurrency/threadlocal.h" #include "mongo/util/time_support.h" diff --git a/src/mongo/util/concurrency/threadlocal.h b/src/mongo/util/concurrency/threadlocal.h index 387b3697545..3d8b9326a70 100644 --- a/src/mongo/util/concurrency/threadlocal.h +++ b/src/mongo/util/concurrency/threadlocal.h @@ -28,6 +28,8 @@ * then also delete it in the license file. */ +#include "mongo/config.h" + #include <boost/thread/tss.hpp> namespace mongo { @@ -82,7 +84,7 @@ namespace mongo { a combination here, with the assumption that reset's are infrequent, so that get's are fast. */ -#if defined(MONGO_HAVE___THREAD) || defined(MONGO_HAVE___DECLSPEC_THREAD) +#if defined(MONGO_CONFIG_HAVE___THREAD) || defined(MONGO_CONFIG_HAVE___DECLSPEC_THREAD) template< class T > struct TSP { @@ -98,7 +100,7 @@ namespace mongo { } }; -# if defined(MONGO_HAVE___DECLSPEC_THREAD) +# if defined(MONGO_CONFIG_HAVE___DECLSPEC_THREAD) # define TSP_DECLARE(T,p) extern TSP<T> p; diff --git a/src/mongo/util/gcov.h b/src/mongo/util/gcov.h deleted file mode 100644 index 2d0350cc2f2..00000000000 --- a/src/mongo/util/gcov.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (C) 2013 10gen Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects - * for all of the code used other than as permitted herein. If you modify - * file(s) with this exception, you may extend this exception to your - * version of the file(s), but you are not obligated to do so. If you do not - * wish to do so, delete this exception statement from your version. If you - * delete this exception statement from all source files in the program, - * then also delete it in the license file. - */ - -#pragma once - -#ifdef MONGO_GCOV -extern "C" { void __gcov_flush(); } -inline void flushForGcov() { __gcov_flush(); } -#else -inline void flushForGcov() {} -#endif diff --git a/src/mongo/util/heapcheck.h b/src/mongo/util/heapcheck.h deleted file mode 100644 index b783ad2dedd..00000000000 --- a/src/mongo/util/heapcheck.h +++ /dev/null @@ -1,45 +0,0 @@ -// @file heapcheck.h - -/** -* Copyright (C) 2010 10gen Inc. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License, version 3, -* as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* As a special exception, the copyright holders give permission to link the -* code of portions of this program with the OpenSSL library under certain -* conditions as described in each individual source file and distribute -* linked combinations including the program with the OpenSSL library. You -* must comply with the GNU Affero General Public License in all respects -* for all of the code used other than as permitted herein. If you modify -* file(s) with this exception, you may extend this exception to your -* version of the file(s), but you are not obligated to do so. If you do not -* wish to do so, delete this exception statement from your version. If you -* delete this exception statement from all source files in the program, -* then also delete it in the license file. -*/ - -#pragma once - -#if defined(HEAP_CHECKING) - -#include <google/heap-checker.h> - -#define IGNORE_OBJECT( a ) HeapLeakChecker::IgnoreObject( a ) -#define UNIGNORE_OBJECT( a ) HeapLeakChecker::UnIgnoreObject( a ) - -#else - -#define IGNORE_OBJECT( a ) -#define UNIGNORE_OBJECT( a ) - -#endif diff --git a/src/mongo/util/net/httpclient.cpp b/src/mongo/util/net/httpclient.cpp index afb059f4d78..b96fae5029e 100644 --- a/src/mongo/util/net/httpclient.cpp +++ b/src/mongo/util/net/httpclient.cpp @@ -27,6 +27,8 @@ * then also delete it in the license file. */ +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/util/net/httpclient.h" @@ -120,7 +122,7 @@ namespace mongo { return -1; if ( ssl ) { -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL // pointer to global singleton instance SSLManagerInterface* mgr = getSSLManager(); diff --git a/src/mongo/util/net/listen.cpp b/src/mongo/util/net/listen.cpp index 8841be6a787..6bc9e1ace30 100644 --- a/src/mongo/util/net/listen.cpp +++ b/src/mongo/util/net/listen.cpp @@ -30,6 +30,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/util/net/listen.h" @@ -126,7 +128,7 @@ namespace mongo { Listener::Listener(const string& name, const string &ip, int port, bool logConnect ) : _port(port), _name(name), _ip(ip), _setupSocketsSuccessful(false), _logConnect(logConnect), _elapsedTime(0) { -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL _ssl = getSSLManager(); #endif } @@ -240,7 +242,7 @@ namespace mongo { return; } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL _logListen(_port, _ssl); #else _logListen(_port, false); @@ -340,7 +342,7 @@ namespace mongo { } boost::shared_ptr<Socket> pnewSock( new Socket(s, from) ); -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL if (_ssl) { pnewSock->secureAccepted(_ssl); } @@ -415,7 +417,7 @@ namespace mongo { ListeningSockets::get()->add(_socks[i]); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL _logListen(_port, _ssl); #else _logListen(_port, false); @@ -557,7 +559,7 @@ namespace mongo { } boost::shared_ptr<Socket> pnewSock( new Socket(s, from) ); -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL if (_ssl) { pnewSock->secureAccepted(_ssl); } diff --git a/src/mongo/util/net/listen.h b/src/mongo/util/net/listen.h index 481a646239f..614e5956a38 100644 --- a/src/mongo/util/net/listen.h +++ b/src/mongo/util/net/listen.h @@ -29,6 +29,8 @@ #pragma once +#include "mongo/config.h" + #include <boost/noncopyable.hpp> #include <boost/shared_ptr.hpp> #include <boost/thread/mutex.hpp> @@ -118,7 +120,7 @@ namespace mongo { // Boolean that indicates whether this Listener is ready to accept incoming network requests bool _ready; -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL SSLManagerInterface* _ssl; #endif diff --git a/src/mongo/util/net/message_port.cpp b/src/mongo/util/net/message_port.cpp index 3b6e3204417..910749e24af 100644 --- a/src/mongo/util/net/message_port.cpp +++ b/src/mongo/util/net/message_port.cpp @@ -29,6 +29,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/util/net/message_port.h" @@ -201,7 +203,7 @@ again: } // If responseTo is not 0 or -1 for first packet assume SSL else if (psock->isAwaitingHandshake()) { -#ifndef MONGO_SSL +#ifndef MONGO_CONFIG_SSL if (header.constView().getResponseTo() != 0 && header.constView().getResponseTo() != -1) { uasserted(17133, @@ -220,7 +222,7 @@ again: } uassert(17189, "The server is configured to only allow SSL connections", sslGlobalParams.sslMode.load() != SSLGlobalParams::SSLMode_requireSSL); -#endif // MONGO_SSL +#endif // MONGO_CONFIG_SSL } if ( static_cast<size_t>(len) < sizeof(MSGHEADER::Value) || static_cast<size_t>(len) > MaxMessageSizeBytes ) { diff --git a/src/mongo/util/net/message_port.h b/src/mongo/util/net/message_port.h index 59c67da856a..34b0f8250ad 100644 --- a/src/mongo/util/net/message_port.h +++ b/src/mongo/util/net/message_port.h @@ -29,6 +29,8 @@ #pragma once +#include "mongo/config.h" + #include <boost/noncopyable.hpp> #include <boost/shared_ptr.hpp> #include <vector> @@ -132,7 +134,7 @@ namespace mongo { bool connect(SockAddr& farEnd) { return psock->connect( farEnd ); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL /** * Initiates the TLS/SSL handshake on this MessagingPort. * When this function returns, further communication on this diff --git a/src/mongo/util/net/message_server_port.cpp b/src/mongo/util/net/message_server_port.cpp index c8af74dc3e8..8b769e683f4 100644 --- a/src/mongo/util/net/message_server_port.cpp +++ b/src/mongo/util/net/message_server_port.cpp @@ -29,6 +29,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include <boost/scoped_ptr.hpp> @@ -254,7 +256,7 @@ namespace { } // Normal disconnect path. -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL SSLManagerInterface* manager = getSSLManager(); if (manager) manager->cleanupThreadLocals(); diff --git a/src/mongo/util/net/miniwebserver.cpp b/src/mongo/util/net/miniwebserver.cpp index 2cbc24e099b..7cc95cd150a 100644 --- a/src/mongo/util/net/miniwebserver.cpp +++ b/src/mongo/util/net/miniwebserver.cpp @@ -29,6 +29,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/util/net/miniwebserver.h" @@ -135,7 +137,7 @@ namespace mongo { char buf[4096]; int len = 0; try { -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL psock->doSSLHandshake(); #endif psock->setTimeout(8); diff --git a/src/mongo/util/net/sock.cpp b/src/mongo/util/net/sock.cpp index 88b73e1eea0..5a63e713d38 100644 --- a/src/mongo/util/net/sock.cpp +++ b/src/mongo/util/net/sock.cpp @@ -29,6 +29,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/util/net/sock.h" @@ -475,7 +477,7 @@ namespace mongo { _bytesOut = 0; _bytesIn = 0; _awaitingHandshake = true; -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL _sslManager = 0; #endif } @@ -493,7 +495,7 @@ namespace mongo { } } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL bool Socket::secure(SSLManagerInterface* mgr, const std::string& remoteHost) { fassert(16503, mgr); if ( _fd < 0 ) { @@ -612,7 +614,7 @@ namespace mongo { // throws if SSL_write or send fails int Socket::_send( const char * data , int len, const char * context ) { -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL if ( _sslConnection.get() ) { return _sslManager->SSL_write( _sslConnection.get() , data , len ); } @@ -664,7 +666,7 @@ namespace mongo { */ void Socket::send( const vector< pair< char *, int > > &data, const char *context ) { -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL if ( _sslConnection.get() ) { _send( data , context ); return; @@ -768,7 +770,7 @@ namespace mongo { // throws if SSL_read fails or recv returns an error int Socket::_recv( char *buf, int max ) { -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL if ( _sslConnection.get() ){ return _sslManager->SSL_read( _sslConnection.get() , buf , max ); } diff --git a/src/mongo/util/net/sock.h b/src/mongo/util/net/sock.h index 43221338bf2..7f02951732b 100644 --- a/src/mongo/util/net/sock.h +++ b/src/mongo/util/net/sock.h @@ -29,6 +29,8 @@ #pragma once +#include "mongo/config.h" + #include <stdio.h> #ifndef _WIN32 @@ -57,7 +59,7 @@ namespace mongo { -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL class SSLManagerInterface; class SSLConnection; #endif @@ -255,7 +257,7 @@ namespace mongo { return _awaitingHandshake; } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL /** secures inline * ssl - Pointer to the global SSLManager. * remoteHost - The hostname of the remote server. @@ -310,7 +312,7 @@ namespace mongo { long long _bytesOut; time_t _lastValidityCheckAtSecs; -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL boost::scoped_ptr<SSLConnection> _sslConnection; SSLManagerInterface* _sslManager; #endif diff --git a/src/mongo/util/net/ssl_manager.cpp b/src/mongo/util/net/ssl_manager.cpp index ba3cdcf1b89..af87701a590 100644 --- a/src/mongo/util/net/ssl_manager.cpp +++ b/src/mongo/util/net/ssl_manager.cpp @@ -27,6 +27,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/util/net/ssl_manager.h" @@ -52,7 +54,7 @@ #include "mongo/util/net/ssl_options.h" #include "mongo/util/scopeguard.h" -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL #include <openssl/evp.h> #include <openssl/x509v3.h> #endif @@ -63,7 +65,7 @@ namespace mongo { SSLGlobalParams sslGlobalParams; -#ifndef MONGO_SSL +#ifndef MONGO_CONFIG_SSL const std::string getSSLVersion(const std::string &prefix, const std::string &suffix) { return ""; } @@ -561,9 +563,9 @@ namespace mongo { void SSLManager::_setupFIPS() { // Turn on FIPS mode if requested. - // OPENSSL_FIPS must be defined by the OpenSSL headers, plus MONGO_SSL_FIPS + // OPENSSL_FIPS must be defined by the OpenSSL headers, plus MONGO_CONFIG_SSL_FIPS // must be defined via a MongoDB build flag. -#if defined(OPENSSL_FIPS) && defined(MONGO_SSL_FIPS) +#if defined(OPENSSL_FIPS) && defined(MONGO_CONFIG_SSL_FIPS) int status = FIPS_mode_set(1); if (!status) { severe() << "can't activate FIPS mode: " << @@ -1081,5 +1083,5 @@ namespace mongo { } throw SocketException(SocketException::CONNECT_ERROR, ""); } -#endif // #ifdef MONGO_SSL +#endif // #ifdef MONGO_CONFIG_SSL } diff --git a/src/mongo/util/net/ssl_manager.h b/src/mongo/util/net/ssl_manager.h index fefb959f1d8..b5a29cb1272 100644 --- a/src/mongo/util/net/ssl_manager.h +++ b/src/mongo/util/net/ssl_manager.h @@ -27,9 +27,11 @@ #pragma once +#include "mongo/config.h" + #include <string> -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL #include "mongo/base/disallow_copying.h" #include "mongo/bson/bsonobj.h" @@ -39,7 +41,7 @@ #include <openssl/err.h> #include <openssl/ssl.h> -#endif // #ifdef MONGO_SSL +#endif // #ifdef MONGO_CONFIG_SSL namespace mongo { /* @@ -48,7 +50,7 @@ namespace mongo { const std::string getSSLVersion(const std::string &prefix, const std::string &suffix); } -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL namespace mongo { class SSLConnection { @@ -149,4 +151,4 @@ namespace mongo { extern bool isSSLServer; } -#endif // #ifdef MONGO_SSL +#endif // #ifdef MONGO_CONFIG_SSL diff --git a/src/mongo/util/quick_exit.cpp b/src/mongo/util/quick_exit.cpp index fbf6f7a2093..0f90570e344 100644 --- a/src/mongo/util/quick_exit.cpp +++ b/src/mongo/util/quick_exit.cpp @@ -26,9 +26,11 @@ * it in the license file. */ +#include "mongo/config.h" + #include "mongo/platform/basic.h" -#if defined(MONGO_HAVE_HEADER_UNISTD_H) +#if defined(MONGO_CONFIG_HAVE_HEADER_UNISTD_H) #include <unistd.h> #endif @@ -43,9 +45,16 @@ #include <sanitizer/lsan_interface.h> #endif +#ifdef MONGO_GCOV +extern "C" void __gcov_flush(); +#endif + namespace mongo { void quickExit(int code) { +#ifdef MONGO_GCOV + __gcov_flush(); +#endif #if __has_feature(address_sanitizer) __lsan_do_leak_check(); diff --git a/src/mongo/util/timer.cpp b/src/mongo/util/timer.cpp index fcf4ddc76c9..5936f00c1f6 100644 --- a/src/mongo/util/timer.cpp +++ b/src/mongo/util/timer.cpp @@ -27,13 +27,15 @@ * then also delete it in the license file. */ +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/util/timer.h" #include <ctime> #include <limits> -#if defined(MONGO_HAVE_HEADER_UNISTD_H) +#if defined(MONGO_CONFIG_HAVE_HEADER_UNISTD_H) #include <unistd.h> #endif @@ -86,7 +88,7 @@ namespace mongo { _timerNow = &timerNowWindows; } -#elif defined(MONGO_HAVE_POSIX_MONOTONIC_CLOCK) +#elif defined(MONGO_CONFIG_HAVE_POSIX_MONOTONIC_CLOCK) /** * Implementation for timer on systems that support the diff --git a/src/mongo/util/version_reporting.cpp b/src/mongo/util/version_reporting.cpp index 83370cc1ba2..104522bec77 100644 --- a/src/mongo/util/version_reporting.cpp +++ b/src/mongo/util/version_reporting.cpp @@ -29,6 +29,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kControl +#include "mongo/config.h" + #include "mongo/platform/basic.h" #include "mongo/util/version_reporting.h" @@ -59,7 +61,7 @@ namespace mongo { } void printOpenSSLVersion() { -#ifdef MONGO_SSL +#ifdef MONGO_CONFIG_SSL log() << openSSLVersion("OpenSSL version: ") << endl; #endif } |