From 161393805f606089959f04b7656bd33b9b91311f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 21 Mar 2018 17:17:34 +0100 Subject: Update Google libraries This commit updates: - gflags 2.2.0 -> 2.2.1 - glog 0.3.4 -> 0.3.4 - gmock 1.7.0 -> 1.8.0 - gtest 1.7.0 -> 1.8.0 --- extern/gflags/CMakeLists.txt | 2 +- extern/gflags/README.blender | 16 +- extern/gflags/src/config.h | 114 -------- extern/gflags/src/gflags.cc | 316 +++++++++++++-------- extern/gflags/src/gflags/config.h | 121 ++++++++ extern/gflags/src/gflags/gflags.h | 49 +++- extern/gflags/src/gflags/gflags_declare.h | 20 +- extern/gflags/src/gflags/gflags_gflags.h | 1 + extern/gflags/src/gflags_completions.cc | 15 +- extern/gflags/src/gflags_reporting.cc | 7 +- extern/gflags/src/mutex.h | 6 +- extern/gflags/src/util.h | 1 - extern/gflags/src/windows_port.h | 6 +- extern/glog/AUTHORS | 6 +- extern/glog/README.blender | 4 +- extern/glog/src/config.h | 2 - extern/glog/src/demangle.h | 1 + extern/glog/src/glog/logging.h | 14 +- extern/glog/src/glog/raw_logging.h | 7 +- extern/glog/src/glog/stl_logging.h | 220 ++++++++++++++ extern/glog/src/logging.cc | 10 +- extern/glog/src/raw_logging.cc | 3 +- extern/glog/src/symbolize.cc | 37 ++- extern/glog/src/utilities.cc | 2 +- extern/glog/src/utilities.h | 4 +- extern/glog/src/vlog_is_on.cc | 6 - extern/glog/src/windows/config.h | 7 - extern/glog/src/windows/glog/logging.h | 121 +++++--- extern/glog/src/windows/glog/stl_logging.h | 224 +++++++++++++++ extern/glog/src/windows/port.h | 7 +- extern/gmock/CHANGES | 126 ++++++++ extern/gmock/CONTRIBUTORS | 40 +++ extern/gmock/README.blender | 2 +- extern/gtest/README.blender | 2 +- extern/gtest/README.md | 138 +++++++++ extern/gtest/include/gtest/gtest-printers.h | 8 +- extern/gtest/include/gtest/gtest.h | 18 +- .../gtest/include/gtest/internal/gtest-internal.h | 8 - extern/gtest/include/gtest/internal/gtest-port.h | 57 +--- 39 files changed, 1316 insertions(+), 432 deletions(-) delete mode 100644 extern/gflags/src/config.h create mode 100644 extern/gflags/src/gflags/config.h create mode 100644 extern/glog/src/glog/stl_logging.h create mode 100644 extern/glog/src/windows/glog/stl_logging.h create mode 100644 extern/gmock/CHANGES create mode 100644 extern/gmock/CONTRIBUTORS create mode 100644 extern/gtest/README.md (limited to 'extern') diff --git a/extern/gflags/CMakeLists.txt b/extern/gflags/CMakeLists.txt index 8977fcca457..a473e6ffb40 100644 --- a/extern/gflags/CMakeLists.txt +++ b/extern/gflags/CMakeLists.txt @@ -35,7 +35,7 @@ set(SRC src/gflags_completions.cc src/gflags_reporting.cc - src/config.h + src/gflags/config.h src/gflags/gflags_completions.h src/gflags/gflags_declare.h src/gflags/gflags_gflags.h diff --git a/extern/gflags/README.blender b/extern/gflags/README.blender index b48d4d5d110..1f6f0111776 100644 --- a/extern/gflags/README.blender +++ b/extern/gflags/README.blender @@ -1,25 +1,23 @@ Project: Google Flags URL: https://github.com/gflags/gflags License: New BSD -Upstream version: 2.2.0 (9db82895) +Upstream version: 2.2.1 (46f73f88b18) Local modifications: -- Flattened the tree and only included files needed for libmv. +- Flattened the tree and only included files needed for Blender. - config.h was originally generated on linux machine with some further tweaks: * OS_WINDOWS need to be conditinally defined from inside #ifdef WIN32 - * Same applies yo HAVE_SHLWAPI_H + * Same applies to HAVE_SHLWAPI_H * Disabeld HAVE_FNMATCH_H - -- Removed attribute(unused) from FlagSaver. + * Forced disabled GFLAGS_IS_A_DLL - Applied some modifications from fork https://github.com/Nazg-Gul/gflags.git (see https://github.com/gflags/gflags/pull/129) -- Avoid attempt of acquiring mutex lock in FlagRegistry::GlobalRegistry when - doing static flags initialization. See d81dd2d in Blender repository. - - Made `google::{anonymous}::FlagValue::ValueSize() const` inlined, so it does - not trigger strict compiler warning. \ No newline at end of file + not trigger strict compiler warning. + +- Did the same for CommandLineFlagParser::ValidateFlags(). diff --git a/extern/gflags/src/config.h b/extern/gflags/src/config.h deleted file mode 100644 index 8d20e222362..00000000000 --- a/extern/gflags/src/config.h +++ /dev/null @@ -1,114 +0,0 @@ -/* Generated from config.h.in during build configuration using CMake. */ - -// Note: This header file is only used internally. It is not part of public interface! - -// --------------------------------------------------------------------------- -// System checks - -// Define if you build this library for a MS Windows OS. -#ifdef WIN32 -# define OS_WINDOWS -#endif - -// Define if you have the header file. -#define HAVE_STDINT_H - -// Define if you have the header file. -#define HAVE_SYS_TYPES_H - -// Define if you have the header file. -#define HAVE_INTTYPES_H - -// Define if you have the header file. -#define HAVE_SYS_STAT_H - -// Define if you have the header file. -#define HAVE_UNISTD_H - -// Define if you have the header file. -/* #undef HAVE_FNMATCH_H */ - -// Define if you have the header file (Windows 2000/XP). -/* #undef HAVE_SHLWAPI_H */ - -// Define if you have the strtoll function. -#define HAVE_STRTOLL - -// Define if you have the strtoq function. -/* #undef HAVE_STRTOQ */ - -// Define if you have the header file. -#define HAVE_PTHREAD - -// Define if your pthread library defines the type pthread_rwlock_t -#define HAVE_RWLOCK - -// gcc requires this to get PRId64, etc. -#if defined(HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS) -# define __STDC_FORMAT_MACROS 1 -#endif - -// --------------------------------------------------------------------------- -// Package information - -// Name of package. -#define PACKAGE gflags - -// Define to the full name of this package. -#define PACKAGE_NAME gflags - -// Define to the full name and version of this package. -#define PACKAGE_STRING gflags 2.2.0 - -// Define to the one symbol short name of this package. -#define PACKAGE_TARNAME gflags-2.2.0 - -// Define to the version of this package. -#define PACKAGE_VERSION 2.2.0 - -// Version number of package. -#define VERSION PACKAGE_VERSION - -// Define to the address where bug reports for this package should be sent. -#define PACKAGE_BUGREPORT https://github.com/schuhschuh/gflags/issues - -// --------------------------------------------------------------------------- -// Path separator -#ifndef PATH_SEPARATOR -# ifdef OS_WINDOWS -# define PATH_SEPARATOR '\\' -# else -# define PATH_SEPARATOR '/' -# endif -#endif - -// --------------------------------------------------------------------------- -// Windows - -// Whether gflags library is a DLL. -#ifndef GFLAGS_IS_A_DLL -# define GFLAGS_IS_A_DLL 0 -#endif - -// Always export symbols when compiling a shared library as this file is only -// included by internal modules when building the gflags library itself. -// The gflags_declare.h header file will set it to import these symbols otherwise. -#ifndef GFLAGS_DLL_DECL -# if GFLAGS_IS_A_DLL && defined(_MSC_VER) -# define GFLAGS_DLL_DECL __declspec(dllexport) -# else -# define GFLAGS_DLL_DECL -# endif -#endif -// Flags defined by the gflags library itself must be exported -#ifndef GFLAGS_DLL_DEFINE_FLAG -# define GFLAGS_DLL_DEFINE_FLAG GFLAGS_DLL_DECL -#endif - -#ifdef OS_WINDOWS -// The unittests import the symbols of the shared gflags library -# if GFLAGS_IS_A_DLL && defined(_MSC_VER) -# define GFLAGS_DLL_DECL_FOR_UNITTESTS __declspec(dllimport) -# endif -# include "windows_port.h" -#endif diff --git a/extern/gflags/src/gflags.cc b/extern/gflags/src/gflags.cc index 6dcc5170bcc..60965d3d201 100644 --- a/extern/gflags/src/gflags.cc +++ b/extern/gflags/src/gflags.cc @@ -88,7 +88,7 @@ // are, similarly, mostly hooks into the functionality described above. #include "config.h" -#include "gflags.h" +#include "gflags/gflags.h" #include #include @@ -96,6 +96,7 @@ #if defined(HAVE_FNMATCH_H) # include #elif defined(HAVE_SHLWAPI_H) +# define NO_SHLWAPI_ISOS # include #endif #include // For va_list and related operations @@ -170,12 +171,10 @@ enum DieWhenReporting { DIE, DO_NOT_DIE }; // Report Error and exit if requested. static void ReportError(DieWhenReporting should_die, const char* format, ...) { - char error_message[255]; va_list ap; va_start(ap, format); - vsnprintf(error_message, sizeof(error_message), format, ap); + vfprintf(stderr, format, ap); va_end(ap); - fprintf(stderr, "%s", error_message); fflush(stderr); // should be unnecessary, but cygwin's rxvt buffers stderr if (should_die == DIE) gflags_exitfunc(1); } @@ -191,29 +190,37 @@ static void ReportError(DieWhenReporting should_die, const char* format, ...) { class CommandLineFlag; class FlagValue { public: - FlagValue(void* valbuf, const char* type, bool transfer_ownership_of_value); + enum ValueType { + FV_BOOL = 0, + FV_INT32 = 1, + FV_UINT32 = 2, + FV_INT64 = 3, + FV_UINT64 = 4, + FV_DOUBLE = 5, + FV_STRING = 6, + FV_MAX_INDEX = 6, + }; + + template + FlagValue(FlagType* valbuf, bool transfer_ownership_of_value); ~FlagValue(); bool ParseFrom(const char* spec); string ToString() const; + ValueType Type() const { return static_cast(type_); } + private: friend class CommandLineFlag; // for many things, including Validate() friend class GFLAGS_NAMESPACE::FlagSaverImpl; // calls New() friend class FlagRegistry; // checks value_buffer_ for flags_by_ptr_ map - template friend T GetFromEnv(const char*, const char*, T); + template friend T GetFromEnv(const char*, T); friend bool TryParseLocked(const CommandLineFlag*, FlagValue*, const char*, string*); // for New(), CopyFrom() - enum ValueType { - FV_BOOL = 0, - FV_INT32 = 1, - FV_INT64 = 2, - FV_UINT64 = 3, - FV_DOUBLE = 4, - FV_STRING = 5, - FV_MAX_INDEX = 5, - }; + template + struct FlagValueTraits; + const char* TypeName() const; bool Equal(const FlagValue& x) const; FlagValue* New() const; // creates a new one with default value @@ -226,14 +233,33 @@ class FlagValue { // (*validate_fn)(bool) for a bool flag). bool Validate(const char* flagname, ValidateFnProto validate_fn_proto) const; - void* value_buffer_; // points to the buffer holding our data - int8 type_; // how to interpret value_ - bool owns_value_; // whether to free value on destruct + void* const value_buffer_; // points to the buffer holding our data + const int8 type_; // how to interpret value_ + const bool owns_value_; // whether to free value on destruct FlagValue(const FlagValue&); // no copying! void operator=(const FlagValue&); }; +// Map the given C++ type to a value of the ValueType enum at compile time. +#define DEFINE_FLAG_TRAITS(type, value) \ + template <> \ + struct FlagValue::FlagValueTraits { \ + static const ValueType kValueType = value; \ + } + +// Define full template specializations of the FlagValueTraits template +// for all supported flag types. +DEFINE_FLAG_TRAITS(bool, FV_BOOL); +DEFINE_FLAG_TRAITS(int32, FV_INT32); +DEFINE_FLAG_TRAITS(uint32, FV_UINT32); +DEFINE_FLAG_TRAITS(int64, FV_INT64); +DEFINE_FLAG_TRAITS(uint64, FV_UINT64); +DEFINE_FLAG_TRAITS(double, FV_DOUBLE); +DEFINE_FLAG_TRAITS(std::string, FV_STRING); + +#undef DEFINE_FLAG_TRAITS + // This could be a templated method of FlagValue, but doing so adds to the // size of the .o. Since there's no type-safety here anyway, macro is ok. @@ -241,16 +267,12 @@ class FlagValue { #define OTHER_VALUE_AS(fv, type) *reinterpret_cast(fv.value_buffer_) #define SET_VALUE_AS(type, value) VALUE_AS(type) = (value) -FlagValue::FlagValue(void* valbuf, const char* type, +template +FlagValue::FlagValue(FlagType* valbuf, bool transfer_ownership_of_value) : value_buffer_(valbuf), + type_(FlagValueTraits::kValueType), owns_value_(transfer_ownership_of_value) { - for (type_ = 0; type_ <= FV_MAX_INDEX; ++type_) { - if (!strcmp(type, TypeName())) { - break; - } - } - assert(type_ <= FV_MAX_INDEX); // Unknown typename } FlagValue::~FlagValue() { @@ -260,6 +282,7 @@ FlagValue::~FlagValue() { switch (type_) { case FV_BOOL: delete reinterpret_cast(value_buffer_); break; case FV_INT32: delete reinterpret_cast(value_buffer_); break; + case FV_UINT32: delete reinterpret_cast(value_buffer_); break; case FV_INT64: delete reinterpret_cast(value_buffer_); break; case FV_UINT64: delete reinterpret_cast(value_buffer_); break; case FV_DOUBLE: delete reinterpret_cast(value_buffer_); break; @@ -308,6 +331,16 @@ bool FlagValue::ParseFrom(const char* value) { SET_VALUE_AS(int32, static_cast(r)); return true; } + case FV_UINT32: { + while (*value == ' ') value++; + if (*value == '-') return false; // negative number + const uint64 r = strtou64(value, &end, base); + if (errno || end != value + strlen(value)) return false; // bad parse + if (static_cast(r) != r) // worked, but number out of range + return false; + SET_VALUE_AS(uint32, static_cast(r)); + return true; + } case FV_INT64: { const int64 r = strto64(value, &end, base); if (errno || end != value + strlen(value)) return false; // bad parse @@ -343,6 +376,9 @@ string FlagValue::ToString() const { case FV_INT32: snprintf(intbuf, sizeof(intbuf), "%" PRId32, VALUE_AS(int32)); return intbuf; + case FV_UINT32: + snprintf(intbuf, sizeof(intbuf), "%" PRIu32, VALUE_AS(uint32)); + return intbuf; case FV_INT64: snprintf(intbuf, sizeof(intbuf), "%" PRId64, VALUE_AS(int64)); return intbuf; @@ -369,6 +405,9 @@ bool FlagValue::Validate(const char* flagname, case FV_INT32: return reinterpret_cast( validate_fn_proto)(flagname, VALUE_AS(int32)); + case FV_UINT32: + return reinterpret_cast( + validate_fn_proto)(flagname, VALUE_AS(uint32)); case FV_INT64: return reinterpret_cast( validate_fn_proto)(flagname, VALUE_AS(int64)); @@ -391,6 +430,7 @@ const char* FlagValue::TypeName() const { static const char types[] = "bool\0xx" "int32\0x" + "uint32\0" "int64\0x" "uint64\0" "double\0" @@ -409,6 +449,7 @@ bool FlagValue::Equal(const FlagValue& x) const { switch (type_) { case FV_BOOL: return VALUE_AS(bool) == OTHER_VALUE_AS(x, bool); case FV_INT32: return VALUE_AS(int32) == OTHER_VALUE_AS(x, int32); + case FV_UINT32: return VALUE_AS(uint32) == OTHER_VALUE_AS(x, uint32); case FV_INT64: return VALUE_AS(int64) == OTHER_VALUE_AS(x, int64); case FV_UINT64: return VALUE_AS(uint64) == OTHER_VALUE_AS(x, uint64); case FV_DOUBLE: return VALUE_AS(double) == OTHER_VALUE_AS(x, double); @@ -418,14 +459,14 @@ bool FlagValue::Equal(const FlagValue& x) const { } FlagValue* FlagValue::New() const { - const char *type = TypeName(); switch (type_) { - case FV_BOOL: return new FlagValue(new bool(false), type, true); - case FV_INT32: return new FlagValue(new int32(0), type, true); - case FV_INT64: return new FlagValue(new int64(0), type, true); - case FV_UINT64: return new FlagValue(new uint64(0), type, true); - case FV_DOUBLE: return new FlagValue(new double(0.0), type, true); - case FV_STRING: return new FlagValue(new string, type, true); + case FV_BOOL: return new FlagValue(new bool(false), true); + case FV_INT32: return new FlagValue(new int32(0), true); + case FV_UINT32: return new FlagValue(new uint32(0), true); + case FV_INT64: return new FlagValue(new int64(0), true); + case FV_UINT64: return new FlagValue(new uint64(0), true); + case FV_DOUBLE: return new FlagValue(new double(0.0), true); + case FV_STRING: return new FlagValue(new string, true); default: assert(false); return NULL; // unknown type } } @@ -435,6 +476,7 @@ void FlagValue::CopyFrom(const FlagValue& x) { switch (type_) { case FV_BOOL: SET_VALUE_AS(bool, OTHER_VALUE_AS(x, bool)); break; case FV_INT32: SET_VALUE_AS(int32, OTHER_VALUE_AS(x, int32)); break; + case FV_UINT32: SET_VALUE_AS(uint32, OTHER_VALUE_AS(x, uint32)); break; case FV_INT64: SET_VALUE_AS(int64, OTHER_VALUE_AS(x, int64)); break; case FV_UINT64: SET_VALUE_AS(uint64, OTHER_VALUE_AS(x, uint64)); break; case FV_DOUBLE: SET_VALUE_AS(double, OTHER_VALUE_AS(x, double)); break; @@ -451,6 +493,7 @@ inline int FlagValue::ValueSize() const { static const uint8 valuesize[] = { sizeof(bool), sizeof(int32), + sizeof(uint32), sizeof(int64), sizeof(uint64), sizeof(double), @@ -487,11 +530,14 @@ class CommandLineFlag { ValidateFnProto validate_function() const { return validate_fn_proto_; } const void* flag_ptr() const { return current_->value_buffer_; } + FlagValue::ValueType Type() const { return defvalue_->Type(); } + void FillCommandLineFlagInfo(struct CommandLineFlagInfo* result); // If validate_fn_proto_ is non-NULL, calls it on value, returns result. bool Validate(const FlagValue& value) const; bool ValidateCurrent() const { return Validate(*current_); } + bool Modified() const { return modified_; } private: // for SetFlagLocked() and setting flags_by_ptr_ @@ -545,7 +591,7 @@ const char* CommandLineFlag::CleanFileName() const { const char* clean_name = filename() + strlen(filename()) - 1; while ( clean_name > filename() ) { if (*clean_name == PATH_SEPARATOR) { - if (strncmp(clean_name, kRootDir, sizeof(kRootDir)-1) == 0) { + if (sizeof(kRootDir) > 1 && strncmp(clean_name, kRootDir, sizeof(kRootDir)-1) == 0) { clean_name += sizeof(kRootDir)-1; // past root-dir break; } @@ -664,7 +710,7 @@ class FlagRegistry { private: friend class GFLAGS_NAMESPACE::FlagSaverImpl; // reads all the flags in order to copy them - friend class CommandLineFlagParser; // for ValidateAllFlags + friend class CommandLineFlagParser; // for ValidateUnmodifiedFlags friend void GFLAGS_NAMESPACE::GetAllFlags(vector*); // The map from name to flag, for FindFlagLocked(). @@ -680,7 +726,6 @@ class FlagRegistry { static FlagRegistry* global_registry_; // a singleton registry Mutex lock_; - static Mutex global_registry_lock_; static void InitGlobalRegistry(); @@ -725,7 +770,12 @@ void FlagRegistry::RegisterFlag(CommandLineFlag* flag) { CommandLineFlag* FlagRegistry::FindFlagLocked(const char* name) { FlagConstIterator i = flags_.find(name); if (i == flags_.end()) { - return NULL; + // If the name has dashes in it, try again after replacing with + // underscores. + if (strchr(name, '-') == NULL) return NULL; + string name_rep = name; + std::replace(name_rep.begin(), name_rep.end(), '-', '_'); + return FindFlagLocked(name_rep.c_str()); } else { return i->second; } @@ -777,7 +827,7 @@ CommandLineFlag* FlagRegistry::SplitArgumentLocked(const char* arg, kError, key->c_str()); return NULL; } - if (strcmp(flag->type_name(), "bool") != 0) { + if (flag->Type() != FlagValue::FV_BOOL) { // 'x' exists but is not boolean, so we're not in the exception case. *error_message = StringPrintf( "%sboolean value (%s) specified for %s command line flag\n", @@ -791,7 +841,7 @@ CommandLineFlag* FlagRegistry::SplitArgumentLocked(const char* arg, } // Assign a value if this is a boolean flag - if (*v == NULL && strcmp(flag->type_name(), "bool") == 0) { + if (*v == NULL && flag->Type() == FlagValue::FV_BOOL) { *v = "1"; // the --nox case was already handled, so this is the --x case } @@ -878,18 +928,12 @@ bool FlagRegistry::SetFlagLocked(CommandLineFlag* flag, // Get the singleton FlagRegistry object FlagRegistry* FlagRegistry::global_registry_ = NULL; -Mutex FlagRegistry::global_registry_lock_(Mutex::LINKER_INITIALIZED); FlagRegistry* FlagRegistry::GlobalRegistry() { - if (GetArgvSum() != 0) { - MutexLock acquire_lock(&global_registry_lock_); - if (!global_registry_) { - global_registry_ = new FlagRegistry; - } - } else { - if (!global_registry_) { - global_registry_ = new FlagRegistry; - } + static Mutex lock(Mutex::LINKER_INITIALIZED); + MutexLock acquire_lock(&lock); + if (!global_registry_) { + global_registry_ = new FlagRegistry; } return global_registry_; } @@ -926,8 +970,10 @@ class CommandLineFlagParser { // In gflags_reporting.cc:HandleCommandLineHelpFlags(). // Stage 3: validate all the commandline flags that have validators - // registered. + // registered and were not set/modified by ParseNewCommandLineFlags. + void ValidateFlags(bool all); void ValidateAllFlags(); + void ValidateUnmodifiedFlags(); // Stage 4: report any errors and return true if any were found. bool ReportErrors(); @@ -1014,9 +1060,6 @@ static string ReadFileIntoString(const char* filename) { uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv, bool remove_flags) { - const char *program_name = strrchr((*argv)[0], PATH_SEPARATOR); // nix path - program_name = (program_name == NULL ? (*argv)[0] : program_name+1); - int first_nonopt = *argc; // for non-options moved to the end registry_->Lock(); @@ -1056,7 +1099,7 @@ uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv, if (value == NULL) { // Boolean options are always assigned a value by SplitArgumentLocked() - assert(strcmp(flag->type_name(), "bool") != 0); + assert(flag->Type() != FlagValue::FV_BOOL); if (i+1 >= first_nonopt) { // This flag needs a value, but there is nothing available error_flags_[key] = (string(kError) + "flag '" + (*argv)[i] + "'" @@ -1081,7 +1124,7 @@ uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv, // "-lat -30.5" would trigger the warning. The common cases we // want to solve talk about true and false as values. if (value[0] == '-' - && strcmp(flag->type_name(), "string") == 0 + && flag->Type() == FlagValue::FV_STRING && (strstr(flag->help(), "true") || strstr(flag->help(), "false"))) { LOG(WARNING) << "Did you really mean to set flag '" @@ -1146,8 +1189,8 @@ string CommandLineFlagParser::ProcessFromenvLocked(const string& flagval, } const string envname = string("FLAGS_") + string(flagname); - string envval; - if (!SafeGetEnv(envname.c_str(), envval)) { + string envval; + if (!SafeGetEnv(envname.c_str(), envval)) { if (errors_are_fatal) { error_flags_[flagname] = (string(kError) + envname + " not found in environment\n"); @@ -1193,23 +1236,35 @@ string CommandLineFlagParser::ProcessSingleOptionLocked( return msg; } -void CommandLineFlagParser::ValidateAllFlags() { +void CommandLineFlagParser::ValidateFlags(bool all) { FlagRegistryLock frl(registry_); for (FlagRegistry::FlagConstIterator i = registry_->flags_.begin(); i != registry_->flags_.end(); ++i) { - if (!i->second->ValidateCurrent()) { + if ((all || !i->second->Modified()) && !i->second->ValidateCurrent()) { // only set a message if one isn't already there. (If there's // an error message, our job is done, even if it's not exactly // the same error.) - if (error_flags_[i->second->name()].empty()) + if (error_flags_[i->second->name()].empty()) { error_flags_[i->second->name()] = string(kError) + "--" + i->second->name() + - " must be set on the commandline" - " (default value fails validation)\n"; + " must be set on the commandline"; + if (!i->second->Modified()) { + error_flags_[i->second->name()] += " (default value fails validation)"; + } + error_flags_[i->second->name()] += "\n"; + } } } } +inline void CommandLineFlagParser::ValidateAllFlags() { + ValidateFlags(true); +} + +void CommandLineFlagParser::ValidateUnmodifiedFlags() { + ValidateFlags(false); +} + bool CommandLineFlagParser::ReportErrors() { // error_flags_ indicates errors we saw while parsing. // But we ignore undefined-names if ok'ed by --undef_ok @@ -1261,7 +1316,11 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked( for (; line_end; flagfile_contents = line_end + 1) { while (*flagfile_contents && isspace(*flagfile_contents)) ++flagfile_contents; - line_end = strchr(flagfile_contents, '\n'); + // Windows uses "\r\n" + line_end = strchr(flagfile_contents, '\r'); + if (line_end == NULL) + line_end = strchr(flagfile_contents, '\n'); + size_t len = line_end ? line_end - flagfile_contents : strlen(flagfile_contents); string line(flagfile_contents, len); @@ -1341,14 +1400,14 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked( // -------------------------------------------------------------------- template -T GetFromEnv(const char *varname, const char* type, T dflt) { +T GetFromEnv(const char *varname, T dflt) { std::string valstr; if (SafeGetEnv(varname, valstr)) { - FlagValue ifv(new T, type, true); + FlagValue ifv(new T, true); if (!ifv.ParseFrom(valstr.c_str())) { ReportError(DIE, "ERROR: error parsing env variable '%s' with value '%s'\n", varname, valstr.c_str()); - } + } return OTHER_VALUE_AS(ifv, T); } else return dflt; } @@ -1395,22 +1454,48 @@ bool AddFlagValidator(const void* flag_ptr, ValidateFnProto validate_fn_proto) { // values in a global destructor. // -------------------------------------------------------------------- -FlagRegisterer::FlagRegisterer(const char* name, const char* type, - const char* help, const char* filename, - void* current_storage, void* defvalue_storage) { +namespace { +void RegisterCommandLineFlag(const char* name, + const char* help, + const char* filename, + FlagValue* current, + FlagValue* defvalue) { if (help == NULL) help = ""; - // FlagValue expects the type-name to not include any namespace - // components, so we get rid of those, if any. - if (strchr(type, ':')) - type = strrchr(type, ':') + 1; - FlagValue* current = new FlagValue(current_storage, type, false); - FlagValue* defvalue = new FlagValue(defvalue_storage, type, false); // Importantly, flag_ will never be deleted, so storage is always good. - CommandLineFlag* flag = new CommandLineFlag(name, help, filename, - current, defvalue); - FlagRegistry::GlobalRegistry()->RegisterFlag(flag); // default registry + CommandLineFlag* flag = + new CommandLineFlag(name, help, filename, current, defvalue); + FlagRegistry::GlobalRegistry()->RegisterFlag(flag); // default registry } +} + +template +FlagRegisterer::FlagRegisterer(const char* name, + const char* help, + const char* filename, + FlagType* current_storage, + FlagType* defvalue_storage) { + FlagValue* const current = new FlagValue(current_storage, false); + FlagValue* const defvalue = new FlagValue(defvalue_storage, false); + RegisterCommandLineFlag(name, help, filename, current, defvalue); +} + +// Force compiler to generate code for the given template specialization. +#define INSTANTIATE_FLAG_REGISTERER_CTOR(type) \ + template GFLAGS_DLL_DECL FlagRegisterer::FlagRegisterer( \ + const char* name, const char* help, const char* filename, \ + type* current_storage, type* defvalue_storage) + +// Do this for all supported flag types. +INSTANTIATE_FLAG_REGISTERER_CTOR(bool); +INSTANTIATE_FLAG_REGISTERER_CTOR(int32); +INSTANTIATE_FLAG_REGISTERER_CTOR(uint32); +INSTANTIATE_FLAG_REGISTERER_CTOR(int64); +INSTANTIATE_FLAG_REGISTERER_CTOR(uint64); +INSTANTIATE_FLAG_REGISTERER_CTOR(double); +INSTANTIATE_FLAG_REGISTERER_CTOR(std::string); + +#undef INSTANTIATE_FLAG_REGISTERER_CTOR // -------------------------------------------------------------------- // GetAllFlags() @@ -1460,65 +1545,58 @@ void GetAllFlags(vector* OUTPUT) { // These values are not protected by a Mutex because they are normally // set only once during program startup. -static const char* argv0 = "UNKNOWN"; // just the program name -static const char* cmdline = ""; // the entire command-line +static string argv0("UNKNOWN"); // just the program name +static string cmdline; // the entire command-line +static string program_usage; static vector argvs; static uint32 argv_sum = 0; -static const char* program_usage = NULL; void SetArgv(int argc, const char** argv) { static bool called_set_argv = false; - if (called_set_argv) // we already have an argv for you - return; - + if (called_set_argv) return; called_set_argv = true; - assert(argc > 0); // every program has at least a progname - argv0 = strdup(argv[0]); // small memory leak, but fn only called once - assert(argv0); + assert(argc > 0); // every program has at least a name + argv0 = argv[0]; - string cmdline_string; // easier than doing strcats + cmdline.clear(); for (int i = 0; i < argc; i++) { - if (i != 0) { - cmdline_string += " "; - } - cmdline_string += argv[i]; + if (i != 0) cmdline += " "; + cmdline += argv[i]; argvs.push_back(argv[i]); } - cmdline = strdup(cmdline_string.c_str()); // another small memory leak - assert(cmdline); // Compute a simple sum of all the chars in argv - for (const char* c = cmdline; *c; c++) + argv_sum = 0; + for (string::const_iterator c = cmdline.begin(); c != cmdline.end(); ++c) { argv_sum += *c; + } } const vector& GetArgvs() { return argvs; } -const char* GetArgv() { return cmdline; } -const char* GetArgv0() { return argv0; } +const char* GetArgv() { return cmdline.c_str(); } +const char* GetArgv0() { return argv0.c_str(); } uint32 GetArgvSum() { return argv_sum; } const char* ProgramInvocationName() { // like the GNU libc fn return GetArgv0(); } const char* ProgramInvocationShortName() { // like the GNU libc fn - const char* slash = strrchr(argv0, '/'); + size_t pos = argv0.rfind('/'); #ifdef OS_WINDOWS - if (!slash) slash = strrchr(argv0, '\\'); + if (pos == string::npos) pos = argv0.rfind('\\'); #endif - return slash ? slash + 1 : argv0; + return (pos == string::npos ? argv0.c_str() : (argv0.c_str() + pos + 1)); } void SetUsageMessage(const string& usage) { - if (program_usage != NULL) - ReportError(DIE, "ERROR: SetUsageMessage() called twice\n"); - program_usage = strdup(usage.c_str()); // small memory leak + program_usage = usage; } const char* ProgramUsage() { - if (program_usage) { - return program_usage; + if (program_usage.empty()) { + return "Warning: SetUsageMessage() never called"; } - return "Warning: SetUsageMessage() never called"; + return program_usage.c_str(); } // -------------------------------------------------------------------- @@ -1526,16 +1604,14 @@ const char* ProgramUsage() { // VersionString() // -------------------------------------------------------------------- -static const char* version_string = NULL; +static string version_string; void SetVersionString(const string& version) { - if (version_string != NULL) - ReportError(DIE, "ERROR: SetVersionString() called twice\n"); - version_string = strdup(version.c_str()); // small memory leak + version_string = version; } const char* VersionString() { - return version_string ? version_string : ""; + return version_string.c_str(); } @@ -1796,6 +1872,7 @@ bool ReadFromFlagsFile(const string& filename, const char* prog_name, // -------------------------------------------------------------------- // BoolFromEnv() // Int32FromEnv() +// Uint32FromEnv() // Int64FromEnv() // Uint64FromEnv() // DoubleFromEnv() @@ -1807,19 +1884,22 @@ bool ReadFromFlagsFile(const string& filename, const char* prog_name, // -------------------------------------------------------------------- bool BoolFromEnv(const char *v, bool dflt) { - return GetFromEnv(v, "bool", dflt); + return GetFromEnv(v, dflt); } int32 Int32FromEnv(const char *v, int32 dflt) { - return GetFromEnv(v, "int32", dflt); + return GetFromEnv(v, dflt); +} +uint32 Uint32FromEnv(const char *v, uint32 dflt) { + return GetFromEnv(v, dflt); } int64 Int64FromEnv(const char *v, int64 dflt) { - return GetFromEnv(v, "int64", dflt); + return GetFromEnv(v, dflt); } uint64 Uint64FromEnv(const char *v, uint64 dflt) { - return GetFromEnv(v, "uint64", dflt); + return GetFromEnv(v, dflt); } double DoubleFromEnv(const char *v, double dflt) { - return GetFromEnv(v, "double", dflt); + return GetFromEnv(v, dflt); } #ifdef _MSC_VER @@ -1855,6 +1935,10 @@ bool RegisterFlagValidator(const int32* flag, bool (*validate_fn)(const char*, int32)) { return AddFlagValidator(flag, reinterpret_cast(validate_fn)); } +bool RegisterFlagValidator(const uint32* flag, + bool (*validate_fn)(const char*, uint32)) { + return AddFlagValidator(flag, reinterpret_cast(validate_fn)); +} bool RegisterFlagValidator(const int64* flag, bool (*validate_fn)(const char*, int64)) { return AddFlagValidator(flag, reinterpret_cast(validate_fn)); @@ -1910,7 +1994,7 @@ static uint32 ParseCommandLineFlagsInternal(int* argc, char*** argv, HandleCommandLineHelpFlags(); // may cause us to exit on --help, etc. // See if any of the unset flags fail their validation checks - parser.ValidateAllFlags(); + parser.ValidateUnmodifiedFlags(); if (parser.ReportErrors()) // may cause us to exit on illegal flags gflags_exitfunc(1); diff --git a/extern/gflags/src/gflags/config.h b/extern/gflags/src/gflags/config.h new file mode 100644 index 00000000000..a65a94b0571 --- /dev/null +++ b/extern/gflags/src/gflags/config.h @@ -0,0 +1,121 @@ +/* Generated from config.h.in during build configuration using CMake. */ + +// Note: This header file is only used internally. It is not part of public interface! + +#ifndef GFLAGS_CONFIG_H_ +#define GFLAGS_CONFIG_H_ + + +// --------------------------------------------------------------------------- +// System checks + +// Define if you build this library for a MS Windows OS. +#ifdef _WIN32 +# define OS_WINDOWS +#endif + +// Define if you have the header file. +#define HAVE_STDINT_H + +// Define if you have the header file. +#define HAVE_SYS_TYPES_H + +// Define if you have the header file. +#define HAVE_INTTYPES_H + +// Define if you have the header file. +#define HAVE_SYS_STAT_H + +// Define if you have the header file. +#define HAVE_UNISTD_H + +// Define if you have the header file. +/* #undef HAVE_FNMATCH_H */ + +// Define if you have the header file (Windows 2000/XP). +/* #undef HAVE_SHLWAPI_H */ + +// Define if you have the strtoll function. +#define HAVE_STRTOLL + +// Define if you have the strtoq function. +/* #undef HAVE_STRTOQ */ + +// Define if you have the header file. +#define HAVE_PTHREAD + +// Define if your pthread library defines the type pthread_rwlock_t +#define HAVE_RWLOCK + +// gcc requires this to get PRId64, etc. +#if defined(HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS) +# define __STDC_FORMAT_MACROS 1 +#endif + +// --------------------------------------------------------------------------- +// Package information + +// Name of package. +#define PACKAGE gflags + +// Define to the full name of this package. +#define PACKAGE_NAME gflags + +// Define to the full name and version of this package. +#define PACKAGE_STRING gflags 2.2.1 + +// Define to the one symbol short name of this package. +#define PACKAGE_TARNAME gflags-2.2.1 + +// Define to the version of this package. +#define PACKAGE_VERSION 2.2.1 + +// Version number of package. +#define VERSION PACKAGE_VERSION + +// Define to the address where bug reports for this package should be sent. +#define PACKAGE_BUGREPORT https://github.com/gflags/gflags/issues + +// --------------------------------------------------------------------------- +// Path separator +#ifndef PATH_SEPARATOR +# ifdef OS_WINDOWS +# define PATH_SEPARATOR '\\' +# else +# define PATH_SEPARATOR '/' +# endif +#endif + +// --------------------------------------------------------------------------- +// Windows + +// Whether gflags library is a DLL. +#ifndef GFLAGS_IS_A_DLL +# define GFLAGS_IS_A_DLL 0 +#endif + +// Always export symbols when compiling a shared library as this file is only +// included by internal modules when building the gflags library itself. +// The gflags_declare.h header file will set it to import these symbols otherwise. +#ifndef GFLAGS_DLL_DECL +# if GFLAGS_IS_A_DLL && defined(_MSC_VER) +# define GFLAGS_DLL_DECL __declspec(dllexport) +# else +# define GFLAGS_DLL_DECL +# endif +#endif +// Flags defined by the gflags library itself must be exported +#ifndef GFLAGS_DLL_DEFINE_FLAG +# define GFLAGS_DLL_DEFINE_FLAG GFLAGS_DLL_DECL +#endif + +#ifdef OS_WINDOWS +// The unittests import the symbols of the shared gflags library +# if GFLAGS_IS_A_DLL && defined(_MSC_VER) +# define GFLAGS_DLL_DECL_FOR_UNITTESTS __declspec(dllimport) +# endif +# include "windows_port.h" +#endif + + +#endif // GFLAGS_CONFIG_H_ diff --git a/extern/gflags/src/gflags/gflags.h b/extern/gflags/src/gflags/gflags.h index 357eec6be7c..02b40e158dc 100644 --- a/extern/gflags/src/gflags/gflags.h +++ b/extern/gflags/src/gflags/gflags.h @@ -81,12 +81,12 @@ #include #include -#include "gflags_declare.h" // IWYU pragma: export +#include "gflags/gflags_declare.h" // IWYU pragma: export // We always want to export variables defined in user code #ifndef GFLAGS_DLL_DEFINE_FLAG -# ifdef _MSC_VER +# if GFLAGS_IS_A_DLL && defined(_MSC_VER) # define GFLAGS_DLL_DEFINE_FLAG __declspec(dllexport) # else # define GFLAGS_DLL_DEFINE_FLAG @@ -128,6 +128,7 @@ namespace GFLAGS_NAMESPACE { // validator is already registered for this flag). extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const bool* flag, bool (*validate_fn)(const char*, bool)); extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int32* flag, bool (*validate_fn)(const char*, int32)); +extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const uint32* flag, bool (*validate_fn)(const char*, uint32)); extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int64* flag, bool (*validate_fn)(const char*, int64)); extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const uint64* flag, bool (*validate_fn)(const char*, uint64)); extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const double* flag, bool (*validate_fn)(const char*, double)); @@ -284,7 +285,7 @@ class GFLAGS_DLL_DECL FlagSaver { FlagSaver(const FlagSaver&); // no copying! void operator=(const FlagSaver&); -}; +}__attribute((unused)); // -------------------------------------------------------------------- // Some deprecated or hopefully-soon-to-be-deprecated functions. @@ -313,6 +314,7 @@ extern GFLAGS_DLL_DECL bool ReadFromFlagsFile(const std::string& filename, const extern GFLAGS_DLL_DECL bool BoolFromEnv(const char *varname, bool defval); extern GFLAGS_DLL_DECL int32 Int32FromEnv(const char *varname, int32 defval); +extern GFLAGS_DLL_DECL uint32 Uint32FromEnv(const char *varname, uint32 defval); extern GFLAGS_DLL_DECL int64 Int64FromEnv(const char *varname, int64 defval); extern GFLAGS_DLL_DECL uint64 Uint64FromEnv(const char *varname, uint64 defval); extern GFLAGS_DLL_DECL double DoubleFromEnv(const char *varname, double defval); @@ -429,9 +431,14 @@ extern GFLAGS_DLL_DECL void ShutDownCommandLineFlags(); class GFLAGS_DLL_DECL FlagRegisterer { public: - FlagRegisterer(const char* name, const char* type, + // We instantiate this template ctor for all supported types, + // so it is possible to place implementation of the FlagRegisterer ctor in + // .cc file. + // Calling this constructor with unsupported type will produce linker error. + template + FlagRegisterer(const char* name, const char* help, const char* filename, - void* current_storage, void* defvalue_storage); + FlagType* current_storage, FlagType* defvalue_storage); }; // If your application #defines STRIP_FLAG_HELP to a non-zero value @@ -473,7 +480,7 @@ extern GFLAGS_DLL_DECL const char kStrippedFlagHelp[]; GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \ type FLAGS_no##name = FLAGS_nono##name; \ static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \ - #name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \ + #name, MAYBE_STRIPPED_HELP(help), __FILE__, \ &FLAGS_##name, &FLAGS_no##name); \ } \ using fL##shorttype::FLAGS_##name @@ -508,6 +515,10 @@ GFLAGS_DLL_DECL bool IsBoolFlag(bool from); DEFINE_VARIABLE(GFLAGS_NAMESPACE::int32, I, \ name, val, txt) +#define DEFINE_uint32(name,val, txt) \ + DEFINE_VARIABLE(GFLAGS_NAMESPACE::uint32, U, \ + name, val, txt) + #define DEFINE_int64(name, val, txt) \ DEFINE_VARIABLE(GFLAGS_NAMESPACE::int64, I64, \ name, val, txt) @@ -538,6 +549,26 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot, } inline clstring* dont_pass0toDEFINE_string(char *stringspot, int value); + +// Auxiliary class used to explicitly call destructor of string objects +// allocated using placement new during static program deinitialization. +// The destructor MUST be an inline function such that the explicit +// destruction occurs in the same compilation unit as the placement new. +class StringFlagDestructor { + void *current_storage_; + void *defvalue_storage_; + +public: + + StringFlagDestructor(void *current, void *defvalue) + : current_storage_(current), defvalue_storage_(defvalue) {} + + ~StringFlagDestructor() { + reinterpret_cast(current_storage_ )->~clstring(); + reinterpret_cast(defvalue_storage_)->~clstring(); + } +}; + } // namespace fLS // We need to define a var named FLAGS_no##name so people don't define @@ -550,13 +581,15 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot, #define DEFINE_string(name, val, txt) \ namespace fLS { \ using ::fLS::clstring; \ + using ::fLS::StringFlagDestructor; \ static union { void* align; char s[sizeof(clstring)]; } s_##name[2]; \ clstring* const FLAGS_no##name = ::fLS:: \ dont_pass0toDEFINE_string(s_##name[0].s, \ val); \ static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \ - #name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \ - s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name)); \ + #name, MAYBE_STRIPPED_HELP(txt), __FILE__, \ + FLAGS_no##name, new (s_##name[1].s) clstring(*FLAGS_no##name)); \ + static StringFlagDestructor d_##name(s_##name[0].s, s_##name[1].s); \ extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \ using fLS::FLAGS_##name; \ clstring& FLAGS_##name = *FLAGS_no##name; \ diff --git a/extern/gflags/src/gflags/gflags_declare.h b/extern/gflags/src/gflags/gflags_declare.h index 9b85f46cfdc..98747f3cda1 100644 --- a/extern/gflags/src/gflags/gflags_declare.h +++ b/extern/gflags/src/gflags/gflags_declare.h @@ -45,18 +45,27 @@ // --------------------------------------------------------------------------- // Windows DLL import/export. -// We always want to import the symbols of the gflags library +// Whether gflags library is a DLL. +// +// Set to 1 by default when the shared gflags library was built on Windows. +// Must be overwritten when this header file is used with the optionally also +// built static library instead; set by CMake's INTERFACE_COMPILE_DEFINITIONS. +#ifndef GFLAGS_IS_A_DLL +# define GFLAGS_IS_A_DLL 1 +#endif + +// We always want to import the symbols of the gflags library. #ifndef GFLAGS_DLL_DECL -# if 1 && defined(_MSC_VER) +# if GFLAGS_IS_A_DLL && defined(_MSC_VER) # define GFLAGS_DLL_DECL __declspec(dllimport) # else # define GFLAGS_DLL_DECL # endif #endif -// We always want to import variables declared in user code +// We always want to import variables declared in user code. #ifndef GFLAGS_DLL_DECLARE_FLAG -# ifdef _MSC_VER +# if GFLAGS_IS_A_DLL && defined(_MSC_VER) # define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport) # else # define GFLAGS_DLL_DECLARE_FLAG @@ -120,6 +129,9 @@ typedef std::string clstring; #define DECLARE_int32(name) \ DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int32, I, name) +#define DECLARE_uint32(name) \ + DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint32, U, name) + #define DECLARE_int64(name) \ DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int64, I64, name) diff --git a/extern/gflags/src/gflags/gflags_gflags.h b/extern/gflags/src/gflags/gflags_gflags.h index 0c17825dd62..36d0ba1d54c 100644 --- a/extern/gflags/src/gflags/gflags_gflags.h +++ b/extern/gflags/src/gflags/gflags_gflags.h @@ -77,6 +77,7 @@ using GFLAGS_NAMESPACE::AppendFlagsIntoFile; using GFLAGS_NAMESPACE::ReadFromFlagsFile; using GFLAGS_NAMESPACE::BoolFromEnv; using GFLAGS_NAMESPACE::Int32FromEnv; +using GFLAGS_NAMESPACE::Uint32FromEnv; using GFLAGS_NAMESPACE::Int64FromEnv; using GFLAGS_NAMESPACE::Uint64FromEnv; using GFLAGS_NAMESPACE::DoubleFromEnv; diff --git a/extern/gflags/src/gflags_completions.cc b/extern/gflags/src/gflags_completions.cc index d7097caeef7..c663453c59c 100644 --- a/extern/gflags/src/gflags_completions.cc +++ b/extern/gflags/src/gflags_completions.cc @@ -46,11 +46,6 @@ // 5a) Force bash to place most-relevent groups at the top of the list // 5b) Trim most flag's descriptions to fit on a single terminal line - -#include "gflags_completions.h" - -#include "config.h" - #include #include #include // for strlen @@ -60,7 +55,11 @@ #include #include -#include "gflags.h" +#include "gflags_completions.h" + +#include "config.h" +#include "gflags/gflags.h" +#include "gflags/gflags_completions.h" #include "util.h" using std::set; @@ -122,7 +121,7 @@ static void CategorizeAllMatchingFlags( NotableFlags *notable_flags); static void TryFindModuleAndPackageDir( - const vector all_flags, + const vector &all_flags, string *module, string *package_dir); @@ -472,7 +471,7 @@ static void PushNameWithSuffix(vector* suffixes, const char* suffix) { } static void TryFindModuleAndPackageDir( - const vector all_flags, + const vector &all_flags, string *module, string *package_dir) { module->clear(); diff --git a/extern/gflags/src/gflags_reporting.cc b/extern/gflags/src/gflags_reporting.cc index 9cc41a7488c..7cc66913459 100644 --- a/extern/gflags/src/gflags_reporting.cc +++ b/extern/gflags/src/gflags_reporting.cc @@ -56,8 +56,8 @@ #include #include "config.h" -#include "gflags.h" -#include "gflags_completions.h" +#include "gflags/gflags.h" +#include "gflags/gflags_completions.h" #include "util.h" @@ -126,7 +126,8 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) { string final_string = ""; int chars_in_line = 0; // how many chars in current line so far? while (1) { - assert(chars_left == strlen(c_string)); // Unless there's a \0 in there? + assert(static_cast(chars_left) + == strlen(c_string)); // Unless there's a \0 in there? const char* newline = strchr(c_string, '\n'); if (newline == NULL && chars_in_line+chars_left < kLineLength) { // The whole remainder of the string fits on this line diff --git a/extern/gflags/src/mutex.h b/extern/gflags/src/mutex.h index ff96f2b67f7..7d7c364b795 100644 --- a/extern/gflags/src/mutex.h +++ b/extern/gflags/src/mutex.h @@ -106,7 +106,7 @@ #ifndef GFLAGS_MUTEX_H_ #define GFLAGS_MUTEX_H_ -#include "gflags_declare.h" // to figure out pthreads support +#include "gflags/gflags_declare.h" // to figure out pthreads support #if defined(NO_THREADS) typedef int MutexType; // to keep a lock-count @@ -166,7 +166,7 @@ class Mutex { // It inhibits work being done by the destructor, which makes it // safer for code that tries to acqiure this mutex in their global // destructor. - inline Mutex(LinkerInitialized); + explicit inline Mutex(LinkerInitialized); // Destructor inline ~Mutex(); @@ -197,7 +197,7 @@ class Mutex { inline void SetIsSafe() { is_safe_ = true; } // Catch the error of writing Mutex when intending MutexLock. - Mutex(Mutex* /*ignored*/) {} + explicit Mutex(Mutex* /*ignored*/) {} // Disallow "evil" constructors Mutex(const Mutex&); void operator=(const Mutex&); diff --git a/extern/gflags/src/util.h b/extern/gflags/src/util.h index fb59b38ddc4..164e3cf86ab 100644 --- a/extern/gflags/src/util.h +++ b/extern/gflags/src/util.h @@ -37,7 +37,6 @@ #include "config.h" #include -#include #ifdef HAVE_INTTYPES_H # include #endif diff --git a/extern/gflags/src/windows_port.h b/extern/gflags/src/windows_port.h index 1f546996783..61cf5b7e3a1 100644 --- a/extern/gflags/src/windows_port.h +++ b/extern/gflags/src/windows_port.h @@ -69,10 +69,8 @@ extern GFLAGS_DLL_DECL int snprintf(char *str, size_t size, extern int GFLAGS_DLL_DECL safe_vsnprintf(char *str, size_t size, const char *format, va_list ap); #define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap) -#if defined(_MSC_VER) && (_MSC_VER < 1400) #define va_copy(dst, src) (dst) = (src) #endif -#endif #endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */ #ifdef _MSC_VER @@ -111,7 +109,9 @@ inline void setenv(const char* name, const char* value, int) { #define unlink _unlink #endif -#if !(defined(_MSC_VER) && _MSC_VER >= 1400) +#if defined(_MSC_VER) && _MSC_VER >= 1800 +#include +#else #define PRId32 "d" #define PRIu32 "u" #define PRId64 "I64d" diff --git a/extern/glog/AUTHORS b/extern/glog/AUTHORS index 72959a02585..8e654101b7c 100644 --- a/extern/glog/AUTHORS +++ b/extern/glog/AUTHORS @@ -8,11 +8,15 @@ # # Please keep the list sorted. +Abhishek Dasgupta Abhishek Parmar +Andy Ying Brian Silverman Google Inc. +Guillaume Dumont Michael Tanner +MiniLight romange -Sergiu Dotenco +Sergiu Deitsch tbennun Teddy Reed diff --git a/extern/glog/README.blender b/extern/glog/README.blender index 288e78b3259..c48bc468e4c 100644 --- a/extern/glog/README.blender +++ b/extern/glog/README.blender @@ -1,9 +1,7 @@ Project: Google Logging URL: https://github.com/google/glog License: New BSD -Upstream version: 0.3.4, 4d391fe +Upstream version: 0.3.5, a6a166db069 Local modifications: * Added per-platform config.h files so no configuration-time checks for functions and so are needed. -* Applied changes from a fork https://github.com/Nazg-Gul/glog - (see https://github.com/google/glog/pull/81) diff --git a/extern/glog/src/config.h b/extern/glog/src/config.h index 2703b7ba9dd..f5c9c0b0a7b 100644 --- a/extern/glog/src/config.h +++ b/extern/glog/src/config.h @@ -14,6 +14,4 @@ #include "windows/config.h" #elif defined(__GNU__) #include "config_hurd.h" -#elif defined(__HAIKU__) - #include "config_haiku.h" #endif diff --git a/extern/glog/src/demangle.h b/extern/glog/src/demangle.h index 265302997fc..991b6ffcf2e 100644 --- a/extern/glog/src/demangle.h +++ b/extern/glog/src/demangle.h @@ -71,6 +71,7 @@ #define BASE_DEMANGLE_H_ #include "config.h" +#include "glog/logging.h" _START_GOOGLE_NAMESPACE_ diff --git a/extern/glog/src/glog/logging.h b/extern/glog/src/glog/logging.h index c632fcaca1b..8238ca9610f 100644 --- a/extern/glog/src/glog/logging.h +++ b/extern/glog/src/glog/logging.h @@ -33,10 +33,6 @@ // Pretty much everybody needs to #include this file so that they can // log various happenings. // -#ifdef WIN32 -# include "windows/glog/logging.h" -#else // WIN32 - #ifndef _LOGGING_H_ #define _LOGGING_H_ @@ -648,7 +644,7 @@ void MakeCheckOpValueString(std::ostream* os, const unsigned char& v); // Build the error message string. Specify no inlining for code size. template std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext) - __attribute__((noinline)); + __attribute__ ((noinline)); namespace base { namespace internal { @@ -1244,7 +1240,7 @@ public: void SendToSyslogAndLog(); // Actually dispatch to syslog and the logs // Call abort() or similar to perform LOG(FATAL) crash. - static void __attribute__((noreturn)) Fail(); + static void __attribute__ ((noreturn)) Fail(); std::ostream& stream(); @@ -1292,7 +1288,7 @@ class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage { public: LogMessageFatal(const char* file, int line); LogMessageFatal(const char* file, int line, const CheckOpString& result); - __attribute__((noreturn)) ~LogMessageFatal(); + __attribute__ ((noreturn)) ~LogMessageFatal(); }; // A non-macro interface to the log facility; (useful @@ -1596,7 +1592,7 @@ class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream { NullStreamFatal() { } NullStreamFatal(const char* file, int line, const CheckOpString& result) : NullStream(file, line, result) { } - __attribute__((noreturn)) ~NullStreamFatal() throw () { _exit(1); } + __attribute__ ((noreturn)) ~NullStreamFatal() throw () { _exit(1); } }; // Install a signal handler that will dump signal information and a stack @@ -1627,5 +1623,3 @@ GOOGLE_GLOG_DLL_DECL void InstallFailureWriter( } #endif // _LOGGING_H_ - -#endif // WIN32 diff --git a/extern/glog/src/glog/raw_logging.h b/extern/glog/src/glog/raw_logging.h index de751d8a6b2..65278f62803 100644 --- a/extern/glog/src/glog/raw_logging.h +++ b/extern/glog/src/glog/raw_logging.h @@ -32,9 +32,6 @@ // Thread-safe logging routines that do not allocate any memory or // acquire any locks, and can therefore be used by low-level memory // allocation and synchronization code. -#ifdef WIN32 -# include "windows/glog/raw_logging.h" -#else // WIN32 #ifndef BASE_RAW_LOGGING_H_ #define BASE_RAW_LOGGING_H_ @@ -176,7 +173,7 @@ GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity, const char* file, int line, const char* format, ...) - ; + __attribute__((__format__ (__printf__, 4, 5))); // Hack to propagate time information into this module so that // this module does not have to directly call localtime_r(), @@ -186,5 +183,3 @@ GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs); } #endif // BASE_RAW_LOGGING_H_ - -#endif // WIN32 diff --git a/extern/glog/src/glog/stl_logging.h b/extern/glog/src/glog/stl_logging.h new file mode 100644 index 00000000000..40a15aa4578 --- /dev/null +++ b/extern/glog/src/glog/stl_logging.h @@ -0,0 +1,220 @@ +// Copyright (c) 2003, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Stream output operators for STL containers; to be used for logging *only*. +// Inclusion of this file lets you do: +// +// list x; +// LOG(INFO) << "data: " << x; +// vector v1, v2; +// CHECK_EQ(v1, v2); +// +// If you want to use this header file with hash maps or slist, you +// need to define macros before including this file: +// +// - GLOG_STL_LOGGING_FOR_UNORDERED - and +// - GLOG_STL_LOGGING_FOR_TR1_UNORDERED - +// - GLOG_STL_LOGGING_FOR_EXT_HASH - +// - GLOG_STL_LOGGING_FOR_EXT_SLIST - +// + +#ifndef UTIL_GTL_STL_LOGGING_INL_H_ +#define UTIL_GTL_STL_LOGGING_INL_H_ + +#if !1 +# error We do not support stl_logging for this compiler +#endif + +#include +#include +#include +#include +#include +#include +#include + +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +# include +# include +#endif + +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +# include +# include +#endif + +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH +# include +# include +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST +# include +#endif + +// Forward declare these two, and define them after all the container streams +// operators so that we can recurse from pair -> container -> container -> pair +// properly. +template +std::ostream& operator<<(std::ostream& out, const std::pair& p); + +namespace google { + +template +void PrintSequence(std::ostream& out, Iter begin, Iter end); + +} + +#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + google::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + +OUTPUT_TWO_ARG_CONTAINER(std::vector) +OUTPUT_TWO_ARG_CONTAINER(std::deque) +OUTPUT_TWO_ARG_CONTAINER(std::list) +#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST +OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist) +#endif + +#undef OUTPUT_TWO_ARG_CONTAINER + +#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + google::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + +OUTPUT_THREE_ARG_CONTAINER(std::set) +OUTPUT_THREE_ARG_CONTAINER(std::multiset) + +#undef OUTPUT_THREE_ARG_CONTAINER + +#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + google::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + +OUTPUT_FOUR_ARG_CONTAINER(std::map) +OUTPUT_FOUR_ARG_CONTAINER(std::multimap) +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set) +OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset) +#endif +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_set) +OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_multiset) +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH +OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set) +OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset) +#endif + +#undef OUTPUT_FOUR_ARG_CONTAINER + +#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + google::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map) +OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap) +#endif +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_map) +OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_multimap) +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH +OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map) +OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap) +#endif + +#undef OUTPUT_FIVE_ARG_CONTAINER + +template +inline std::ostream& operator<<(std::ostream& out, + const std::pair& p) { + out << '(' << p.first << ", " << p.second << ')'; + return out; +} + +namespace google { + +template +inline void PrintSequence(std::ostream& out, Iter begin, Iter end) { + // Output at most 100 elements -- appropriate if used for logging. + for (int i = 0; begin != end && i < 100; ++i, ++begin) { + if (i > 0) out << ' '; + out << *begin; + } + if (begin != end) { + out << " ..."; + } +} + +} + +// Note that this is technically undefined behavior! We are adding things into +// the std namespace for a reason though -- we are providing new operations on +// types which are themselves defined with this namespace. Without this, these +// operator overloads cannot be found via ADL. If these definitions are not +// found via ADL, they must be #included before they're used, which requires +// this header to be included before apparently independent other headers. +// +// For example, base/logging.h defines various template functions to implement +// CHECK_EQ(x, y) and stream x and y into the log in the event the check fails. +// It does so via the function template MakeCheckOpValueString: +// template +// void MakeCheckOpValueString(strstream* ss, const T& v) { +// (*ss) << v; +// } +// Because 'glog/logging.h' is included before 'glog/stl_logging.h', +// subsequent CHECK_EQ(v1, v2) for vector<...> typed variable v1 and v2 can only +// find these operator definitions via ADL. +// +// Even this solution has problems -- it may pull unintended operators into the +// namespace as well, allowing them to also be found via ADL, and creating code +// that only works with a particular order of includes. Long term, we need to +// move all of the *definitions* into namespace std, bet we need to ensure no +// one references them first. This lets us take that step. We cannot define them +// in both because that would create ambiguous overloads when both are found. +namespace std { using ::operator<<; } + +#endif // UTIL_GTL_STL_LOGGING_INL_H_ diff --git a/extern/glog/src/logging.cc b/extern/glog/src/logging.cc index 6552f46efdd..3e8f48e814d 100644 --- a/extern/glog/src/logging.cc +++ b/extern/glog/src/logging.cc @@ -260,6 +260,9 @@ static bool TerminalSupportsColor() { !strcmp(term, "xterm-color") || !strcmp(term, "xterm-256color") || !strcmp(term, "screen-256color") || + !strcmp(term, "konsole") || + !strcmp(term, "konsole-16color") || + !strcmp(term, "konsole-256color") || !strcmp(term, "screen") || !strcmp(term, "linux") || !strcmp(term, "cygwin"); @@ -301,7 +304,7 @@ static GLogColor SeverityToColor(LogSeverity severity) { #ifdef OS_WINDOWS // Returns the character attribute for the given color. -static WORD GetColorAttribute(GLogColor color) { +WORD GetColorAttribute(GLogColor color) { switch (color) { case COLOR_RED: return FOREGROUND_RED; case COLOR_GREEN: return FOREGROUND_GREEN; @@ -313,7 +316,7 @@ static WORD GetColorAttribute(GLogColor color) { #else // Returns the ANSI color code for the given color. -static const char* GetAnsiColorCode(GLogColor color) { +const char* GetAnsiColorCode(GLogColor color) { switch (color) { case COLOR_RED: return "1"; case COLOR_GREEN: return "2"; @@ -825,6 +828,7 @@ void LogDestination::DeleteLogDestinations() { } MutexLock l(&sink_mutex_); delete sinks_; + sinks_ = NULL; } namespace { @@ -1677,7 +1681,6 @@ void LogToStderr() { namespace base { namespace internal { -bool GetExitOnDFatal(); bool GetExitOnDFatal() { MutexLock l(&log_mutex); return exit_on_dfatal; @@ -1693,7 +1696,6 @@ bool GetExitOnDFatal() { // and the stack trace is not recorded. The LOG(FATAL) *will* still // exit the program. Since this function is used only in testing, // these differences are acceptable. -void SetExitOnDFatal(bool value); void SetExitOnDFatal(bool value) { MutexLock l(&log_mutex); exit_on_dfatal = value; diff --git a/extern/glog/src/raw_logging.cc b/extern/glog/src/raw_logging.cc index 8517129fa81..7a7409bbf34 100644 --- a/extern/glog/src/raw_logging.cc +++ b/extern/glog/src/raw_logging.cc @@ -59,8 +59,7 @@ # include #endif -// Hurd does not have SYS_write. -#if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && !defined(__GNU__) +#if defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H) # define safe_write(fd, s, len) syscall(SYS_write, fd, s, len) #else // Not so safe, but what can you do? diff --git a/extern/glog/src/symbolize.cc b/extern/glog/src/symbolize.cc index 6211e85e5db..f83c309738e 100644 --- a/extern/glog/src/symbolize.cc +++ b/extern/glog/src/symbolize.cc @@ -327,7 +327,7 @@ FindSymbol(uint64_t pc, const int fd, char *out, int out_size, // false. static bool GetSymbolFromObjectFile(const int fd, uint64_t pc, char *out, int out_size, - uint64_t map_start_address) { + uint64_t map_base_address) { // Read the ELF header. ElfW(Ehdr) elf_header; if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) { @@ -336,7 +336,28 @@ static bool GetSymbolFromObjectFile(const int fd, uint64_t pc, uint64_t symbol_offset = 0; if (elf_header.e_type == ET_DYN) { // DSO needs offset adjustment. - symbol_offset = map_start_address; + ElfW(Phdr) phdr; + // We need to find the PT_LOAD segment corresponding to the read-execute + // file mapping in order to correctly perform the offset adjustment. + for (unsigned i = 0; i != elf_header.e_phnum; ++i) { + if (!ReadFromOffsetExact(fd, &phdr, sizeof(phdr), + elf_header.e_phoff + i * sizeof(phdr))) + return false; + if (phdr.p_type == PT_LOAD && + (phdr.p_flags & (PF_R | PF_X)) == (PF_R | PF_X)) { + // Find the mapped address corresponding to virtual address zero. We do + // this by first adding p_offset. This gives us the mapped address of + // the start of the segment, or in other words the mapped address + // corresponding to the virtual address of the segment. (Note that this + // is distinct from the start address, as p_offset is not guaranteed to + // be page aligned.) We then subtract p_vaddr, which takes us to virtual + // address zero. + symbol_offset = map_base_address + phdr.p_offset - phdr.p_vaddr; + break; + } + } + if (symbol_offset == 0) + return false; } ElfW(Shdr) symtab, strtab; @@ -569,8 +590,8 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc, return -1; // Malformed line. } - // Check flags. We are only interested in "r-x" maps. - if (memcmp(flags_start, "r-x", 3) != 0) { // Not a "r-x" map. + // Check flags. We are only interested in "r*x" maps. + if (flags_start[0] != 'r' || flags_start[2] != 'x') { continue; // We skip this map. } ++cursor; // Skip ' '. @@ -634,7 +655,7 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc, // bytes. Output will be truncated as needed, and a NUL character is always // appended. // NOTE: code from sandbox/linux/seccomp-bpf/demo.cc. -static char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) { +char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) { // Make sure we can write at least one NUL byte. size_t n = 1; if (n > sz) @@ -696,7 +717,7 @@ static char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) // Safely appends string |source| to string |dest|. Never writes past the // buffer size |dest_size| and guarantees that |dest| is null-terminated. -static void SafeAppendString(const char* source, char* dest, int dest_size) { +void SafeAppendString(const char* source, char* dest, int dest_size) { int dest_string_length = strlen(dest); SAFE_ASSERT(dest_string_length < dest_size); dest += dest_string_length; @@ -709,7 +730,7 @@ static void SafeAppendString(const char* source, char* dest, int dest_size) { // Converts a 64-bit value into a hex string, and safely appends it to |dest|. // Never writes past the buffer size |dest_size| and guarantees that |dest| is // null-terminated. -static void SafeAppendHexNumber(uint64_t value, char* dest, int dest_size) { +void SafeAppendHexNumber(uint64_t value, char* dest, int dest_size) { // 64-bit numbers in hex can have up to 16 digits. char buf[17] = {'\0'}; SafeAppendString(itoa_r(value, buf, sizeof(buf), 16, 0), dest, dest_size); @@ -782,7 +803,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out, } } if (!GetSymbolFromObjectFile(wrapped_object_fd.get(), pc0, - out, out_size, start_address)) { + out, out_size, base_address)) { return false; } diff --git a/extern/glog/src/utilities.cc b/extern/glog/src/utilities.cc index 296fa7a67f3..5c88e58d3c0 100644 --- a/extern/glog/src/utilities.cc +++ b/extern/glog/src/utilities.cc @@ -84,7 +84,7 @@ static void DebugWriteToStderr(const char* data, void *) { } } -static void DebugWriteToString(const char* data, void *arg) { +void DebugWriteToString(const char* data, void *arg) { reinterpret_cast(arg)->append(data); } diff --git a/extern/glog/src/utilities.h b/extern/glog/src/utilities.h index 4f41c92e434..5f79968ef55 100644 --- a/extern/glog/src/utilities.h +++ b/extern/glog/src/utilities.h @@ -101,9 +101,7 @@ // correctly when GetStackTrace() is called with max_depth == 0. // Some code may do that. -#if defined(__MINGW32__) || defined(__FreeBSD__) -# undef STACKTRACE_H -#elif defined(HAVE_LIB_UNWIND) +#if defined(HAVE_LIB_UNWIND) # define STACKTRACE_H "stacktrace_libunwind-inl.h" #elif !defined(NO_FRAME_POINTER) # if defined(__i386__) && __GNUC__ >= 2 diff --git a/extern/glog/src/vlog_is_on.cc b/extern/glog/src/vlog_is_on.cc index e8fdbae7dcb..4c95583b683 100644 --- a/extern/glog/src/vlog_is_on.cc +++ b/extern/glog/src/vlog_is_on.cc @@ -62,12 +62,6 @@ _START_GOOGLE_NAMESPACE_ namespace glog_internal_namespace_ { -// Used by logging_unittests.cc so can't make it static here. -GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern, - size_t patt_len, - const char* str, - size_t str_len); - // Implementation of fnmatch that does not need 0-termination // of arguments and does not allocate any memory, // but we only support "*" and "?" wildcards, not the "[...]" patterns. diff --git a/extern/glog/src/windows/config.h b/extern/glog/src/windows/config.h index 1cc2533daa5..2d23fb08159 100644 --- a/extern/glog/src/windows/config.h +++ b/extern/glog/src/windows/config.h @@ -1,8 +1,5 @@ /* src/config.h.in. Generated from configure.ac by autoheader. */ -/* define if you have google gflags library */ -#define HAVE_LIB_GFLAGS 1 - /* Namespace for Google classes */ #define GOOGLE_NAMESPACE google @@ -12,10 +9,6 @@ /* Puts following code inside the Google namespace */ #define _START_GOOGLE_NAMESPACE_ namespace google { -#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER >= 1900)) -# define HAVE_SNPRINTF -#endif - /* Always the empty-string on non-windows systems. On windows, should be "__declspec(dllexport)". This way, when we compile the dll, we export our functions/classes. It's safe to define this here because config.h is only diff --git a/extern/glog/src/windows/glog/logging.h b/extern/glog/src/windows/glog/logging.h index 50135329d77..f521a2b9424 100644 --- a/extern/glog/src/windows/glog/logging.h +++ b/extern/glog/src/windows/glog/logging.h @@ -52,14 +52,6 @@ #endif #include -// Annoying stuff for windows -- makes sure clients can import these functions -#ifndef GOOGLE_GLOG_DLL_DECL -# if defined(_WIN32) && !defined(__CYGWIN__) -# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport) -# else -# define GOOGLE_GLOG_DLL_DECL -# endif -#endif #if defined(_MSC_VER) #define GLOG_MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ __pragma(warning(disable:n)) @@ -69,35 +61,38 @@ #define GLOG_MSVC_POP_WARNING() #endif +// Annoying stuff for windows -- makes sure clients can import these functions +#ifndef GOOGLE_GLOG_DLL_DECL +# if defined(_WIN32) && !defined(__CYGWIN__) +# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport) +# else +# define GOOGLE_GLOG_DLL_DECL +# endif +#endif + // We care a lot about number of bits things take up. Unfortunately, // systems define their bit-specific ints in a lot of different ways. // We use our own way, and have a typedef to get there. // Note: these commands below may look like "#if 1" or "#if 0", but // that's because they were constructed that way at ./configure time. // Look at logging.h.in to see how they're calculated (based on your config). -#ifdef __MINGW32__ +#if 0 #include // the normal place uint16_t is defined #endif -#ifdef __MINGW32__ +#if 0 #include // the normal place u_int16_t is defined #endif -#ifdef __MINGW32__ +#if 0 #include // a third place for uint16_t or u_int16_t #endif -#if 1 +#if 0 #include #endif -#ifdef __MINGW32__ -# include -# include -# define _exit(x) exit(x) -#endif - namespace google { -#if defined(__MINGW32__) // the C99 format +#if 0 // the C99 format typedef int32_t int32; typedef uint32_t uint32; typedef int64_t int64; @@ -107,7 +102,7 @@ typedef int32_t int32; typedef u_int32_t uint32; typedef int64_t int64; typedef u_int64_t uint64; -#elif defined(_MSC_VER) // the windows (vc7) format +#elif 1 // the windows (vc7) format typedef __int32 int32; typedef unsigned __int32 uint32; typedef __int64 int64; @@ -139,15 +134,28 @@ typedef unsigned __int64 uint64; #ifndef GOOGLE_PREDICT_BRANCH_NOT_TAKEN #if 0 #define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) (__builtin_expect(x, 0)) -#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0)) -#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) #else #define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) x +#endif +#endif + +#ifndef GOOGLE_PREDICT_FALSE +#if 0 +#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0)) +#else #define GOOGLE_PREDICT_FALSE(x) x +#endif +#endif + +#ifndef GOOGLE_PREDICT_TRUE +#if 0 +#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) +#else #define GOOGLE_PREDICT_TRUE(x) x #endif #endif + // Make a bunch of macros for logging. The way to log things is to stream // things to LOG(). E.g., // @@ -357,6 +365,9 @@ DECLARE_int32(minloglevel); // default logging directory. DECLARE_string(log_dir); +// Set the log file mode. +DECLARE_int32(logfile_mode); + // Sets the path of the directory into which to put additional links // to the log files. DECLARE_string(log_link); @@ -424,9 +435,15 @@ DECLARE_bool(stop_logging_if_full_disk); #define LOG_TO_STRING_FATAL(message) google::NullStreamFatal() #endif +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) +#define DCHECK_IS_ON() 0 +#else +#define DCHECK_IS_ON() 1 +#endif + // For DFATAL, we want to use LogMessage (as opposed to // LogMessageFatal), to be consistent with the original behavior. -#ifdef NDEBUG +#if !DCHECK_IS_ON() #define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR #elif GOOGLE_STRIP_LOG <= 3 #define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \ @@ -552,7 +569,7 @@ class LogSink; // defined below // vector *outvec; // The cast is to disambiguate NULL arguments. #define LOG_STRING(severity, outvec) \ - LOG_TO_STRING_##severity(static_cast*>(outvec)).stream() + LOG_TO_STRING_##severity(static_cast*>(outvec)).stream() #define LOG_IF(severity, condition) \ !(condition) ? (void) 0 : google::LogMessageVoidify() & LOG(severity) @@ -565,7 +582,7 @@ class LogSink; // defined below SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition // CHECK dies with a fatal error if condition is not true. It is *not* -// controlled by NDEBUG, so the check will be executed regardless of +// controlled by DCHECK_IS_ON(), so the check will be executed regardless of // compilation mode. Therefore, it is safe to do things like: // CHECK(fp->Write(x) == 4) #define CHECK(condition) \ @@ -715,15 +732,15 @@ DEFINE_CHECK_OP_IMPL(Check_GT, > ) #if defined(STATIC_ANALYSIS) // Only for static analysis tool to know that it is equivalent to assert #define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2)) -#elif !defined(NDEBUG) +#elif DCHECK_IS_ON() // In debug mode, avoid constructing CheckOpStrings if possible, // to reduce the overhead of CHECK statments by 2x. // Real DCHECK-heavy tests have seen 1.5x speedups. -// The meaning of "string" might be different between now and +// The meaning of "string" might be different between now and // when this macro gets invoked (e.g., if someone is experimenting // with other string implementations that get defined after this -// file is included). Save the current meaning now and use it +// file is included). Save the current meaning now and use it // in the macro. typedef std::string _Check_string; #define CHECK_OP_LOG(name, op, val1, val2, log) \ @@ -744,7 +761,7 @@ typedef std::string _Check_string; google::GetReferenceableValue(val2), \ #val1 " " #op " " #val2)) \ log(__FILE__, __LINE__, _result).stream() -#endif // STATIC_ANALYSIS, !NDEBUG +#endif // STATIC_ANALYSIS, DCHECK_IS_ON() #if GOOGLE_STRIP_LOG <= 3 #define CHECK_OP(name, op, val1, val2) \ @@ -969,7 +986,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR; // Plus some debug-logging macros that get compiled to nothing for production -#ifndef NDEBUG +#if DCHECK_IS_ON() #define DLOG(severity) LOG(severity) #define DVLOG(verboselevel) VLOG(verboselevel) @@ -979,7 +996,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR; LOG_IF_EVERY_N(severity, condition, n) #define DLOG_ASSERT(condition) LOG_ASSERT(condition) -// debug-only checking. not executed in NDEBUG mode. +// debug-only checking. executed if DCHECK_IS_ON(). #define DCHECK(condition) CHECK(condition) #define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2) #define DCHECK_NE(val1, val2) CHECK_NE(val1, val2) @@ -993,7 +1010,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR; #define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2) #define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2) -#else // NDEBUG +#else // !DCHECK_IS_ON() #define DLOG(severity) \ true ? (void) 0 : google::LogMessageVoidify() & LOG(severity) @@ -1074,7 +1091,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR; while (false) \ GLOG_MSVC_POP_WARNING() CHECK_STRCASENE(str1, str2) -#endif // NDEBUG +#endif // DCHECK_IS_ON() // Log only in verbose mode. @@ -1164,6 +1181,8 @@ public: char* str() const { return pbase(); } private: + LogStream(const LogStream&); + LogStream& operator=(const LogStream&); base_logging::LogStreamBuf streambuf_; int ctr_; // Counter hack (for the LOG_EVERY_X() macro) LogStream *self_; // Consistency check hack @@ -1231,7 +1250,7 @@ public: void SendToSyslogAndLog(); // Actually dispatch to syslog and the logs // Call abort() or similar to perform LOG(FATAL) crash. - static void Fail() ; + static void __declspec(noreturn) Fail(); std::ostream& stream(); @@ -1279,7 +1298,7 @@ class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage { public: LogMessageFatal(const char* file, int line); LogMessageFatal(const char* file, int line, const CheckOpString& result); - ~LogMessageFatal() ; + __declspec(noreturn) ~LogMessageFatal(); }; // A non-macro interface to the log facility; (useful @@ -1294,6 +1313,35 @@ inline void LogAtLevel(int const severity, std::string const &msg) { // LOG macros, 2. this macro can be used as C++ stream. #define LOG_AT_LEVEL(severity) google::LogMessage(__FILE__, __LINE__, severity).stream() +// Check if it's compiled in C++11 mode. +// +// GXX_EXPERIMENTAL_CXX0X is defined by gcc and clang up to at least +// gcc-4.7 and clang-3.1 (2011-12-13). __cplusplus was defined to 1 +// in gcc before 4.7 (Crosstool 16) and clang before 3.1, but is +// defined according to the language version in effect thereafter. +// Microsoft Visual Studio 14 (2015) sets __cplusplus==199711 despite +// reasonably good C++11 support, so we set LANG_CXX for it and +// newer versions (_MSC_VER >= 1900). +#if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || \ + (defined(_MSC_VER) && _MSC_VER >= 1900)) +// Helper for CHECK_NOTNULL(). +// +// In C++11, all cases can be handled by a single function. Since the value +// category of the argument is preserved (also for rvalue references), +// member initializer lists like the one below will compile correctly: +// +// Foo() +// : x_(CHECK_NOTNULL(MethodReturningUniquePtr())) {} +template +T CheckNotNull(const char* file, int line, const char* names, T&& t) { + if (t == nullptr) { + LogMessageFatal(file, line, new std::string(names)); + } + return std::forward(t); +} + +#else + // A small helper for CHECK_NOTNULL(). template T* CheckNotNull(const char *file, int line, const char *names, T* t) { @@ -1302,6 +1350,7 @@ T* CheckNotNull(const char *file, int line, const char *names, T* t) { } return t; } +#endif // Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This // only works if ostream is a LogStream. If the ostream is not a @@ -1583,7 +1632,7 @@ class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream { NullStreamFatal() { } NullStreamFatal(const char* file, int line, const CheckOpString& result) : NullStream(file, line, result) { } - ~NullStreamFatal() { _exit(1); } + __declspec(noreturn) ~NullStreamFatal() throw () { _exit(1); } }; // Install a signal handler that will dump signal information and a stack diff --git a/extern/glog/src/windows/glog/stl_logging.h b/extern/glog/src/windows/glog/stl_logging.h new file mode 100644 index 00000000000..a97a9089595 --- /dev/null +++ b/extern/glog/src/windows/glog/stl_logging.h @@ -0,0 +1,224 @@ +// This file is automatically generated from src/glog/stl_logging.h.in +// using src/windows/preprocess.sh. +// DO NOT EDIT! + +// Copyright (c) 2003, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Stream output operators for STL containers; to be used for logging *only*. +// Inclusion of this file lets you do: +// +// list x; +// LOG(INFO) << "data: " << x; +// vector v1, v2; +// CHECK_EQ(v1, v2); +// +// If you want to use this header file with hash_compare maps or slist, you +// need to define macros before including this file: +// +// - GLOG_STL_LOGGING_FOR_UNORDERED - and +// - GLOG_STL_LOGGING_FOR_TR1_UNORDERED - +// - GLOG_STL_LOGGING_FOR_EXT_HASH - +// - GLOG_STL_LOGGING_FOR_EXT_SLIST - +// + +#ifndef UTIL_GTL_STL_LOGGING_INL_H_ +#define UTIL_GTL_STL_LOGGING_INL_H_ + +#if !1 +# error We do not support stl_logging for this compiler +#endif + +#include +#include +#include +#include +#include +#include +#include + +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +# include +# include +#endif + +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +# include +# include +#endif + +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH +# include +# include +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST +# include +#endif + +// Forward declare these two, and define them after all the container streams +// operators so that we can recurse from pair -> container -> container -> pair +// properly. +template +std::ostream& operator<<(std::ostream& out, const std::pair& p); + +namespace google { + +template +void PrintSequence(std::ostream& out, Iter begin, Iter end); + +} + +#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + google::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + +OUTPUT_TWO_ARG_CONTAINER(std::vector) +OUTPUT_TWO_ARG_CONTAINER(std::deque) +OUTPUT_TWO_ARG_CONTAINER(std::list) +#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST +OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist) +#endif + +#undef OUTPUT_TWO_ARG_CONTAINER + +#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + google::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + +OUTPUT_THREE_ARG_CONTAINER(std::set) +OUTPUT_THREE_ARG_CONTAINER(std::multiset) + +#undef OUTPUT_THREE_ARG_CONTAINER + +#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + google::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + +OUTPUT_FOUR_ARG_CONTAINER(std::map) +OUTPUT_FOUR_ARG_CONTAINER(std::multimap) +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set) +OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset) +#endif +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_set) +OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_multiset) +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH +OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set) +OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset) +#endif + +#undef OUTPUT_FOUR_ARG_CONTAINER + +#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + google::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map) +OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap) +#endif +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_map) +OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_multimap) +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH +OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map) +OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap) +#endif + +#undef OUTPUT_FIVE_ARG_CONTAINER + +template +inline std::ostream& operator<<(std::ostream& out, + const std::pair& p) { + out << '(' << p.first << ", " << p.second << ')'; + return out; +} + +namespace google { + +template +inline void PrintSequence(std::ostream& out, Iter begin, Iter end) { + // Output at most 100 elements -- appropriate if used for logging. + for (int i = 0; begin != end && i < 100; ++i, ++begin) { + if (i > 0) out << ' '; + out << *begin; + } + if (begin != end) { + out << " ..."; + } +} + +} + +// Note that this is technically undefined behavior! We are adding things into +// the std namespace for a reason though -- we are providing new operations on +// types which are themselves defined with this namespace. Without this, these +// operator overloads cannot be found via ADL. If these definitions are not +// found via ADL, they must be #included before they're used, which requires +// this header to be included before apparently independent other headers. +// +// For example, base/logging.h defines various template functions to implement +// CHECK_EQ(x, y) and stream x and y into the log in the event the check fails. +// It does so via the function template MakeCheckOpValueString: +// template +// void MakeCheckOpValueString(strstream* ss, const T& v) { +// (*ss) << v; +// } +// Because 'glog/logging.h' is included before 'glog/stl_logging.h', +// subsequent CHECK_EQ(v1, v2) for vector<...> typed variable v1 and v2 can only +// find these operator definitions via ADL. +// +// Even this solution has problems -- it may pull unintended operators into the +// namespace as well, allowing them to also be found via ADL, and creating code +// that only works with a particular order of includes. Long term, we need to +// move all of the *definitions* into namespace std, bet we need to ensure no +// one references them first. This lets us take that step. We cannot define them +// in both because that would create ambiguous overloads when both are found. +namespace std { using ::operator<<; } + +#endif // UTIL_GTL_STL_LOGGING_INL_H_ diff --git a/extern/glog/src/windows/port.h b/extern/glog/src/windows/port.h index 02c6f6e77b2..819846151b9 100644 --- a/extern/glog/src/windows/port.h +++ b/extern/glog/src/windows/port.h @@ -136,6 +136,7 @@ typedef int pid_t; #endif // _MSC_VER // ----------------------------------- THREADS +#ifndef __MINGW32__ typedef DWORD pthread_t; typedef DWORD pthread_key_t; typedef LONG pthread_once_t; @@ -147,15 +148,11 @@ inline struct tm* localtime_r(const time_t* timep, struct tm* result) { localtime_s(result, timep); return result; } +#endif inline char* strerror_r(int errnum, char* buf, size_t buflen) { -#ifdef FREE_WINDOWS - strncpy(buf, "Not implemented yet", buflen); - return buf; -#else strerror_s(buf, buflen, errnum); return buf; -#endif } #ifndef __cplusplus diff --git a/extern/gmock/CHANGES b/extern/gmock/CHANGES new file mode 100644 index 00000000000..d6f2f760e34 --- /dev/null +++ b/extern/gmock/CHANGES @@ -0,0 +1,126 @@ +Changes for 1.7.0: + +* All new improvements in Google Test 1.7.0. +* New feature: matchers DoubleNear(), FloatNear(), + NanSensitiveDoubleNear(), NanSensitiveFloatNear(), + UnorderedElementsAre(), UnorderedElementsAreArray(), WhenSorted(), + WhenSortedBy(), IsEmpty(), and SizeIs(). +* Improvement: Google Mock can now be built as a DLL. +* Improvement: when compiled by a C++11 compiler, matchers AllOf() + and AnyOf() can accept an arbitrary number of matchers. +* Improvement: when compiled by a C++11 compiler, matchers + ElementsAreArray() can accept an initializer list. +* Improvement: when exceptions are enabled, a mock method with no + default action now throws instead crashing the test. +* Improvement: added class testing::StringMatchResultListener to aid + definition of composite matchers. +* Improvement: function return types used in MOCK_METHOD*() macros can + now contain unprotected commas. +* Improvement (potentially breaking): EXPECT_THAT() and ASSERT_THAT() + are now more strict in ensuring that the value type and the matcher + type are compatible, catching potential bugs in tests. +* Improvement: Pointee() now works on an optional. +* Improvement: the ElementsAreArray() matcher can now take a vector or + iterator range as input, and makes a copy of its input elements + before the conversion to a Matcher. +* Improvement: the Google Mock Generator can now generate mocks for + some class templates. +* Bug fix: mock object destruction triggerred by another mock object's + destruction no longer hangs. +* Improvement: Google Mock Doctor works better with newer Clang and + GCC now. +* Compatibility fixes. +* Bug/warning fixes. + +Changes for 1.6.0: + +* Compilation is much faster and uses much less memory, especially + when the constructor and destructor of a mock class are moved out of + the class body. +* New matchers: Pointwise(), Each(). +* New actions: ReturnPointee() and ReturnRefOfCopy(). +* CMake support. +* Project files for Visual Studio 2010. +* AllOf() and AnyOf() can handle up-to 10 arguments now. +* Google Mock doctor understands Clang error messages now. +* SetArgPointee<> now accepts string literals. +* gmock_gen.py handles storage specifier macros and template return + types now. +* Compatibility fixes. +* Bug fixes and implementation clean-ups. +* Potentially incompatible changes: disables the harmful 'make install' + command in autotools. + +Potentially breaking changes: + +* The description string for MATCHER*() changes from Python-style + interpolation to an ordinary C++ string expression. +* SetArgumentPointee is deprecated in favor of SetArgPointee. +* Some non-essential project files for Visual Studio 2005 are removed. + +Changes for 1.5.0: + + * New feature: Google Mock can be safely used in multi-threaded tests + on platforms having pthreads. + * New feature: function for printing a value of arbitrary type. + * New feature: function ExplainMatchResult() for easy definition of + composite matchers. + * The new matcher API lets user-defined matchers generate custom + explanations more directly and efficiently. + * Better failure messages all around. + * NotNull() and IsNull() now work with smart pointers. + * Field() and Property() now work when the matcher argument is a pointer + passed by reference. + * Regular expression matchers on all platforms. + * Added GCC 4.0 support for Google Mock Doctor. + * Added gmock_all_test.cc for compiling most Google Mock tests + in a single file. + * Significantly cleaned up compiler warnings. + * Bug fixes, better test coverage, and implementation clean-ups. + + Potentially breaking changes: + + * Custom matchers defined using MatcherInterface or MakePolymorphicMatcher() + need to be updated after upgrading to Google Mock 1.5.0; matchers defined + using MATCHER or MATCHER_P* aren't affected. + * Dropped support for 'make install'. + +Changes for 1.4.0 (we skipped 1.2.* and 1.3.* to match the version of +Google Test): + + * Works in more environments: Symbian and minGW, Visual C++ 7.1. + * Lighter weight: comes with our own implementation of TR1 tuple (no + more dependency on Boost!). + * New feature: --gmock_catch_leaked_mocks for detecting leaked mocks. + * New feature: ACTION_TEMPLATE for defining templatized actions. + * New feature: the .After() clause for specifying expectation order. + * New feature: the .With() clause for for specifying inter-argument + constraints. + * New feature: actions ReturnArg(), ReturnNew(...), and + DeleteArg(). + * New feature: matchers Key(), Pair(), Args<...>(), AllArgs(), IsNull(), + and Contains(). + * New feature: utility class MockFunction, useful for checkpoints, etc. + * New feature: functions Value(x, m) and SafeMatcherCast(m). + * New feature: copying a mock object is rejected at compile time. + * New feature: a script for fusing all Google Mock and Google Test + source files for easy deployment. + * Improved the Google Mock doctor to diagnose more diseases. + * Improved the Google Mock generator script. + * Compatibility fixes for Mac OS X and gcc. + * Bug fixes and implementation clean-ups. + +Changes for 1.1.0: + + * New feature: ability to use Google Mock with any testing framework. + * New feature: macros for easily defining new matchers + * New feature: macros for easily defining new actions. + * New feature: more container matchers. + * New feature: actions for accessing function arguments and throwing + exceptions. + * Improved the Google Mock doctor script for diagnosing compiler errors. + * Bug fixes and implementation clean-ups. + +Changes for 1.0.0: + + * Initial Open Source release of Google Mock diff --git a/extern/gmock/CONTRIBUTORS b/extern/gmock/CONTRIBUTORS new file mode 100644 index 00000000000..6e9ae362b60 --- /dev/null +++ b/extern/gmock/CONTRIBUTORS @@ -0,0 +1,40 @@ +# This file contains a list of people who've made non-trivial +# contribution to the Google C++ Mocking Framework project. People +# who commit code to the project are encouraged to add their names +# here. Please keep the list sorted by first names. + +Benoit Sigoure +Bogdan Piloca +Chandler Carruth +Dave MacLachlan +David Anderson +Dean Sturtevant +Gene Volovich +Hal Burch +Jeffrey Yasskin +Jim Keller +Joe Walnes +Jon Wray +Keir Mierle +Keith Ray +Kostya Serebryany +Lev Makhlis +Manuel Klimek +Mario Tanev +Mark Paskin +Markus Heule +Matthew Simmons +Mike Bland +Neal Norwitz +Nermin Ozkiranartli +Owen Carlsen +Paneendra Ba +Paul Menage +Piotr Kaminski +Russ Rufer +Sverre Sundsdal +Takeshi Yoshino +Vadim Berman +Vlad Losev +Wolfgang Klier +Zhanyong Wan diff --git a/extern/gmock/README.blender b/extern/gmock/README.blender index 41dda92c19c..6165bd6f717 100644 --- a/extern/gmock/README.blender +++ b/extern/gmock/README.blender @@ -1,7 +1,7 @@ Project: Google C++ Testing Framework URL: https://github.com/google/googletest License: New BSD -Upstream version: 1.7.0 (ec44c6c) +Upstream version: 1.8.0 (ec44c6c1675) Local modifications: None. diff --git a/extern/gtest/README.blender b/extern/gtest/README.blender index 41dda92c19c..6165bd6f717 100644 --- a/extern/gtest/README.blender +++ b/extern/gtest/README.blender @@ -1,7 +1,7 @@ Project: Google C++ Testing Framework URL: https://github.com/google/googletest License: New BSD -Upstream version: 1.7.0 (ec44c6c) +Upstream version: 1.8.0 (ec44c6c1675) Local modifications: None. diff --git a/extern/gtest/README.md b/extern/gtest/README.md new file mode 100644 index 00000000000..22df99bd4b0 --- /dev/null +++ b/extern/gtest/README.md @@ -0,0 +1,138 @@ + +# Google Test # + +[![Build Status](https://travis-ci.org/google/googletest.svg?branch=master)](https://travis-ci.org/google/googletest) + +Welcome to **Google Test**, Google's C++ test framework! + +This repository is a merger of the formerly separate GoogleTest and +GoogleMock projects. These were so closely related that it makes sense to +maintain and release them together. + +Please see the project page above for more information as well as the +mailing list for questions, discussions, and development. There is +also an IRC channel on OFTC (irc.oftc.net) #gtest available. Please +join us! + +**Google Mock** is an extension to Google Test for writing and using C++ mock +classes. See the separate [Google Mock documentation](googlemock/README.md). + +More detailed documentation for googletest (including build instructions) are +in its interior [googletest/README.md](googletest/README.md) file. + +## Features ## + + * An [XUnit](https://en.wikipedia.org/wiki/XUnit) test framework. + * Test discovery. + * A rich set of assertions. + * User-defined assertions. + * Death tests. + * Fatal and non-fatal failures. + * Value-parameterized tests. + * Type-parameterized tests. + * Various options for running the tests. + * XML test report generation. + +## Platforms ## + +Google test has been used on a variety of platforms: + + * Linux + * Mac OS X + * Windows + * Cygwin + * MinGW + * Windows Mobile + * Symbian + +## Who Is Using Google Test? ## + +In addition to many internal projects at Google, Google Test is also used by +the following notable projects: + + * The [Chromium projects](http://www.chromium.org/) (behind the Chrome + browser and Chrome OS). + * The [LLVM](http://llvm.org/) compiler. + * [Protocol Buffers](https://github.com/google/protobuf), Google's data + interchange format. + * The [OpenCV](http://opencv.org/) computer vision library. + +## Related Open Source Projects ## + +[Google Test UI](https://github.com/ospector/gtest-gbar) is test runner that runs +your test binary, allows you to track its progress via a progress bar, and +displays a list of test failures. Clicking on one shows failure text. Google +Test UI is written in C#. + +[GTest TAP Listener](https://github.com/kinow/gtest-tap-listener) is an event +listener for Google Test that implements the +[TAP protocol](https://en.wikipedia.org/wiki/Test_Anything_Protocol) for test +result output. If your test runner understands TAP, you may find it useful. + +## Requirements ## + +Google Test is designed to have fairly minimal requirements to build +and use with your projects, but there are some. Currently, we support +Linux, Windows, Mac OS X, and Cygwin. We will also make our best +effort to support other platforms (e.g. Solaris, AIX, and z/OS). +However, since core members of the Google Test project have no access +to these platforms, Google Test may have outstanding issues there. If +you notice any problems on your platform, please notify +. Patches for fixing them are +even more welcome! + +### Linux Requirements ### + +These are the base requirements to build and use Google Test from a source +package (as described below): + + * GNU-compatible Make or gmake + * POSIX-standard shell + * POSIX(-2) Regular Expressions (regex.h) + * A C++98-standard-compliant compiler + +### Windows Requirements ### + + * Microsoft Visual C++ v7.1 or newer + +### Cygwin Requirements ### + + * Cygwin v1.5.25-14 or newer + +### Mac OS X Requirements ### + + * Mac OS X v10.4 Tiger or newer + * XCode Developer Tools + +### Requirements for Contributors ### + +We welcome patches. If you plan to contribute a patch, you need to +build Google Test and its own tests from a git checkout (described +below), which has further requirements: + + * [Python](https://www.python.org/) v2.3 or newer (for running some of + the tests and re-generating certain source files from templates) + * [CMake](https://cmake.org/) v2.6.4 or newer + +## Regenerating Source Files ## + +Some of Google Test's source files are generated from templates (not +in the C++ sense) using a script. +For example, the +file include/gtest/internal/gtest-type-util.h.pump is used to generate +gtest-type-util.h in the same directory. + +You don't need to worry about regenerating the source files +unless you need to modify them. You would then modify the +corresponding `.pump` files and run the '[pump.py](googletest/scripts/pump.py)' +generator script. See the [Pump Manual](googletest/docs/PumpManual.md). + +### Contributing Code ### + +We welcome patches. Please read the +[Developer's Guide](googletest/docs/DevGuide.md) +for how you can contribute. In particular, make sure you have signed +the Contributor License Agreement, or we won't be able to accept the +patch. + +Happy testing! diff --git a/extern/gtest/include/gtest/gtest-printers.h b/extern/gtest/include/gtest/gtest-printers.h index 27a1edc3728..8a33164cb38 100644 --- a/extern/gtest/include/gtest/gtest-printers.h +++ b/extern/gtest/include/gtest/gtest-printers.h @@ -103,7 +103,7 @@ #include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-internal.h" -#if defined(GTEST_HAS_STD_TUPLE_) && GTEST_HAS_STD_TUPLE_ +#if GTEST_HAS_STD_TUPLE_ # include #endif @@ -581,7 +581,7 @@ inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) { } #endif // GTEST_HAS_STD_WSTRING -#if GTEST_HAS_TR1_TUPLE || (defined(GTEST_HAS_STD_TUPLE_) && GTEST_HAS_STD_TUPLE_) +#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_ // Helper function for printing a tuple. T must be instantiated with // a tuple type. template @@ -664,7 +664,7 @@ void PrintTo( } #endif // GTEST_HAS_TR1_TUPLE -#if defined(GTEST_HAS_STD_TUPLE_) && GTEST_HAS_STD_TUPLE_ +#if GTEST_HAS_STD_TUPLE_ template void PrintTo(const ::std::tuple& t, ::std::ostream* os) { PrintTupleTo(t, os); @@ -888,7 +888,7 @@ template const size_t TuplePolicy::tuple_size; #endif // GTEST_HAS_TR1_TUPLE -#if defined(GTEST_HAS_STD_TUPLE_) && GTEST_HAS_STD_TUPLE_ +#if GTEST_HAS_STD_TUPLE_ template struct TuplePolicy< ::std::tuple > { typedef ::std::tuple Tuple; diff --git a/extern/gtest/include/gtest/gtest.h b/extern/gtest/include/gtest/gtest.h index 18d3ed4b469..f846c5bd669 100644 --- a/extern/gtest/include/gtest/gtest.h +++ b/extern/gtest/include/gtest/gtest.h @@ -1818,7 +1818,7 @@ class TestWithParam : public Test, public WithParamInterface { // Define this macro to 1 to omit the definition of FAIL(), which is a // generic name and clashes with some other libraries. -#if !defined(GTEST_DONT_DEFINE_FAIL) || !GTEST_DONT_DEFINE_FAIL +#if !GTEST_DONT_DEFINE_FAIL # define FAIL() GTEST_FAIL() #endif @@ -1827,7 +1827,7 @@ class TestWithParam : public Test, public WithParamInterface { // Define this macro to 1 to omit the definition of SUCCEED(), which // is a generic name and clashes with some other libraries. -#if !defined(GTEST_DONT_DEFINE_SUCCEED) || !GTEST_DONT_DEFINE_SUCCEED +#if !GTEST_DONT_DEFINE_SUCCEED # define SUCCEED() GTEST_SUCCEED() #endif @@ -1952,27 +1952,27 @@ class TestWithParam : public Test, public WithParamInterface { // Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of // ASSERT_XY(), which clashes with some users' own code. -#if !defined(GTEST_DONT_DEFINE_ASSERT_EQ) || !GTEST_DONT_DEFINE_ASSERT_EQ +#if !GTEST_DONT_DEFINE_ASSERT_EQ # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2) #endif -#if !defined(GTEST_DONT_DEFINE_ASSERT_NE) || !GTEST_DONT_DEFINE_ASSERT_NE +#if !GTEST_DONT_DEFINE_ASSERT_NE # define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2) #endif -#if !defined(GTEST_DONT_DEFINE_ASSERT_LE) || !GTEST_DONT_DEFINE_ASSERT_LE +#if !GTEST_DONT_DEFINE_ASSERT_LE # define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2) #endif -#if !defined(GTEST_DONT_DEFINE_ASSERT_LT) || !GTEST_DONT_DEFINE_ASSERT_LT +#if !GTEST_DONT_DEFINE_ASSERT_LT # define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2) #endif -#if !defined(GTEST_DONT_DEFINE_ASSERT_GE) || !GTEST_DONT_DEFINE_ASSERT_GE +#if !GTEST_DONT_DEFINE_ASSERT_GE # define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2) #endif -#if !defined(GTEST_DONT_DEFINE_ASSERT_GT) || !GTEST_DONT_DEFINE_ASSERT_GT +#if !GTEST_DONT_DEFINE_ASSERT_GT # define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2) #endif @@ -2183,7 +2183,7 @@ bool StaticAssertTypeEq() { // Define this macro to 1 to omit the definition of TEST(), which // is a generic name and clashes with some other libraries. -#if !defined(GTEST_DONT_DEFINE_TEST) || !GTEST_DONT_DEFINE_TEST +#if !GTEST_DONT_DEFINE_TEST # define TEST(test_case_name, test_name) GTEST_TEST(test_case_name, test_name) #endif diff --git a/extern/gtest/include/gtest/internal/gtest-internal.h b/extern/gtest/include/gtest/internal/gtest-internal.h index ca15a2f3a78..ebd1cf615de 100644 --- a/extern/gtest/include/gtest/internal/gtest-internal.h +++ b/extern/gtest/include/gtest/internal/gtest-internal.h @@ -60,10 +60,6 @@ #include #include -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# include -#endif - #include "gtest/gtest-message.h" #include "gtest/internal/gtest-string.h" #include "gtest/internal/gtest-filepath.h" @@ -858,7 +854,6 @@ struct AddReference { typedef T& type; }; // NOLINT template class ImplicitlyConvertible { private: -#if !((__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800)) // We need the following helper functions only for their types. // They have no implementations. @@ -879,7 +874,6 @@ class ImplicitlyConvertible { // implicitly converted to type To. static char Helper(To); static char (&Helper(...))[2]; // NOLINT -#endif // We have to put the 'public' section after the 'private' section, // or MSVC refuses to compile the code. @@ -889,8 +883,6 @@ class ImplicitlyConvertible { // instantiation. The simplest workaround is to use its C++0x type traits // functions (C++Builder 2009 and above only). static const bool value = __is_convertible(From, To); -#elif (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) - static const bool value = std::is_convertible::value; #else // MSVC warns about implicitly converting from double to int for // possible loss of data, so we need to temporarily disable the diff --git a/extern/gtest/include/gtest/internal/gtest-port.h b/extern/gtest/include/gtest/internal/gtest-port.h index ad2a43df17d..0094ed5077e 100644 --- a/extern/gtest/include/gtest/internal/gtest-port.h +++ b/extern/gtest/include/gtest/internal/gtest-port.h @@ -306,7 +306,7 @@ // GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385) // /* code that triggers warnings C4800 and C4385 */ // GTEST_DISABLE_MSC_WARNINGS_POP_() -#if defined(_MSC_VER) && _MSC_VER >= 1500 +#if _MSC_VER >= 1500 # define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \ __pragma(warning(push)) \ __pragma(warning(disable: warnings)) @@ -323,7 +323,7 @@ // -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a // value for __cplusplus, and recent versions of clang, gcc, and // probably other compilers set that too in C++11 mode. -# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L // Compiling in at least C++11 mode. # define GTEST_LANG_CXX11 1 # else @@ -352,7 +352,7 @@ #endif // Only use C++11 library features if the library provides them. -#if defined(GTEST_STDLIB_CXX11) && GTEST_STDLIB_CXX11 +#if GTEST_STDLIB_CXX11 # define GTEST_HAS_STD_BEGIN_AND_END_ 1 # define GTEST_HAS_STD_FORWARD_LIST_ 1 # define GTEST_HAS_STD_FUNCTION_ 1 @@ -387,37 +387,6 @@ # endif #endif -#ifndef GTEST_OS_WINDOWS -# define GTEST_OS_WINDOWS 0 -#endif -#ifndef GTEST_OS_WINDOWS_MINGW -# define GTEST_OS_WINDOWS_MINGW 0 -#endif -#ifndef GTEST_OS_WINDOWS_PHONE -# define GTEST_OS_WINDOWS_PHONE 0 -#endif -#ifndef GTEST_OS_WINDOWS_MOBILE -# define GTEST_OS_WINDOWS_MOBILE 0 -#endif -#ifndef GTEST_OS_WINDOWS_RT -# define GTEST_OS_WINDOWS_RT 0 -#endif -#ifndef GTEST_OS_LINUX_ANDROID -# define GTEST_OS_LINUX_ANDROID 0 -#endif -#ifndef GTEST_OS_QNX -# define GTEST_OS_QNX 0 -#endif -#ifndef GTEST_OS_SYMBIAN -# define GTEST_OS_SYMBIAN 0 -#endif -#ifndef GTEST_OS_CYGWIN -# define GTEST_OS_CYGWIN 0 -#endif -#ifndef GTEST_OS_SOLARIS -# define GTEST_OS_SOLARIS 0 -#endif - // Brings in definitions for functions used in the testing::internal::posix // namespace (read, write, close, chdir, isatty, stat). We do not currently // use them on Windows Mobile. @@ -454,7 +423,7 @@ struct _RTL_CRITICAL_SECTION; # endif #endif -#if defined(GTEST_USES_PCRE) && GTEST_USES_PCRE +#if GTEST_USES_PCRE // The appropriate headers have already been included. #elif GTEST_HAS_POSIX_RE @@ -647,7 +616,7 @@ struct _RTL_CRITICAL_SECTION; // Determines if hash_map/hash_set are available. // Only used for testing against those containers. #if !defined(GTEST_HAS_HASH_MAP_) -# if defined(_MSC_VER) +# if _MSC_VER # define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available. # define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available. # endif // _MSC_VER @@ -691,8 +660,6 @@ struct _RTL_CRITICAL_SECTION; // can build with clang but need to use gcc4.2's libstdc++). # if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325) # define GTEST_ENV_HAS_STD_TUPLE_ 1 -# else -# define GTEST_ENV_HAS_STD_TUPLE_ 0 # endif # if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_ @@ -706,7 +673,7 @@ struct _RTL_CRITICAL_SECTION; // To avoid conditional compilation everywhere, we make it // gtest-port.h's responsibility to #include the header implementing // tuple. -#if defined(GTEST_HAS_STD_TUPLE_) && GTEST_HAS_STD_TUPLE_ +#if GTEST_HAS_STD_TUPLE_ # include // IWYU pragma: export # define GTEST_TUPLE_NAMESPACE_ ::std #endif // GTEST_HAS_STD_TUPLE_ @@ -947,7 +914,7 @@ using ::std::tuple_size; # endif #define GTEST_IS_THREADSAFE \ - ((defined(GTEST_HAS_MUTEX_AND_THREAD_LOCAL_) && GTEST_HAS_MUTEX_AND_THREAD_LOCAL_) \ + (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ \ || (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) \ || GTEST_HAS_PTHREAD) @@ -1343,7 +1310,7 @@ inline void FlushInfoLog() { fflush(NULL); } GTEST_LOG_(FATAL) << #posix_call << "failed with error " \ << gtest_error -#if defined(GTEST_HAS_STD_MOVE_) && GTEST_HAS_STD_MOVE_ +#if GTEST_HAS_STD_MOVE_ using std::move; #else // GTEST_HAS_STD_MOVE_ template @@ -1427,7 +1394,7 @@ Derived* CheckedDowncastToActualType(Base* base) { GTEST_CHECK_(typeid(*base) == typeid(Derived)); #endif -#if defined(GTEST_HAS_DOWNCAST_) && GTEST_HAS_DOWNCAST_ +#if GTEST_HAS_DOWNCAST_ return ::down_cast(base); #elif GTEST_HAS_RTTI return dynamic_cast(base); // NOLINT @@ -1487,7 +1454,7 @@ inline void SleepMilliseconds(int n) { } # endif // GTEST_HAS_PTHREAD -# if defined(GTEST_HAS_NOTIFICATION_) && GTEST_HAS_NOTIFICATION_ +# if GTEST_HAS_NOTIFICATION_ // Notification has already been imported into the namespace. // Nothing to do here. @@ -1670,7 +1637,7 @@ class ThreadWithParam : public ThreadWithParamBase { # endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD || // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ -# if defined(GTEST_HAS_MUTEX_AND_THREAD_LOCAL_) && GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ +# if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ // Mutex and ThreadLocal have already been imported into the namespace. // Nothing to do here. @@ -2450,7 +2417,7 @@ inline void Abort() { abort(); } // MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate // function in order to achieve that. We use macro definition here because // snprintf is a variadic function. -#if defined(_MSC_VER) && _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE +#if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE // MSVC 2005 and above support variadic macros. # define GTEST_SNPRINTF_(buffer, size, format, ...) \ _snprintf_s(buffer, size, size, format, __VA_ARGS__) -- cgit v1.2.3