http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/src/gflags_reporting.cc ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/src/gflags_reporting.cc b/third_party/src/tmb/third_party/gflags/src/gflags_reporting.cc deleted file mode 100644 index 9cc41a7..0000000 --- a/third_party/src/tmb/third_party/gflags/src/gflags_reporting.cc +++ /dev/null @@ -1,441 +0,0 @@ -// Copyright (c) 1999, 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. - -// --- -// -// Revamped and reorganized by Craig Silverstein -// -// This file contains code for handling the 'reporting' flags. These -// are flags that, when present, cause the program to report some -// information and then exit. --help and --version are the canonical -// reporting flags, but we also have flags like --helpxml, etc. -// -// There's only one function that's meant to be called externally: -// HandleCommandLineHelpFlags(). (Well, actually, ShowUsageWithFlags(), -// ShowUsageWithFlagsRestrict(), and DescribeOneFlag() can be called -// externally too, but there's little need for it.) These are all -// declared in the main gflags.h header file. -// -// HandleCommandLineHelpFlags() will check what 'reporting' flags have -// been defined, if any -- the "help" part of the function name is a -// bit misleading -- and do the relevant reporting. It should be -// called after all flag-values have been assigned, that is, after -// parsing the command-line. - -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include <assert.h> -#include <string> -#include <vector> - -#include "config.h" -#include "gflags.h" -#include "gflags_completions.h" -#include "util.h" - - -// The 'reporting' flags. They all call gflags_exitfunc(). -DEFINE_bool (help, false, "show help on all flags [tip: all flags can have two dashes]"); -DEFINE_bool (helpfull, false, "show help on all flags -- same as -help"); -DEFINE_bool (helpshort, false, "show help on only the main module for this program"); -DEFINE_string(helpon, "", "show help on the modules named by this flag value"); -DEFINE_string(helpmatch, "", "show help on modules whose name contains the specified substr"); -DEFINE_bool (helppackage, false, "show help on all modules in the main package"); -DEFINE_bool (helpxml, false, "produce an xml version of help"); -DEFINE_bool (version, false, "show version and build info and exit"); - - -namespace GFLAGS_NAMESPACE { - - -using std::string; -using std::vector; - - -// -------------------------------------------------------------------- -// DescribeOneFlag() -// DescribeOneFlagInXML() -// Routines that pretty-print info about a flag. These use -// a CommandLineFlagInfo, which is the way the gflags -// API exposes static info about a flag. -// -------------------------------------------------------------------- - -static const int kLineLength = 80; - -static void AddString(const string& s, - string* final_string, int* chars_in_line) { - const int slen = static_cast<int>(s.length()); - if (*chars_in_line + 1 + slen >= kLineLength) { // < 80 chars/line - *final_string += "\n "; - *chars_in_line = 6; - } else { - *final_string += " "; - *chars_in_line += 1; - } - *final_string += s; - *chars_in_line += slen; -} - -static string PrintStringFlagsWithQuotes(const CommandLineFlagInfo& flag, - const string& text, bool current) { - const char* c_string = (current ? flag.current_value.c_str() : - flag.default_value.c_str()); - if (strcmp(flag.type.c_str(), "string") == 0) { // add quotes for strings - return StringPrintf("%s: \"%s\"", text.c_str(), c_string); - } else { - return StringPrintf("%s: %s", text.c_str(), c_string); - } -} - -// Create a descriptive string for a flag. -// Goes to some trouble to make pretty line breaks. -string DescribeOneFlag(const CommandLineFlagInfo& flag) { - string main_part; - SStringPrintf(&main_part, " -%s (%s)", - flag.name.c_str(), - flag.description.c_str()); - const char* c_string = main_part.c_str(); - int chars_left = static_cast<int>(main_part.length()); - 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? - 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 - final_string += c_string; - chars_in_line += chars_left; - break; - } - if (newline != NULL && newline - c_string < kLineLength - chars_in_line) { - int n = static_cast<int>(newline - c_string); - final_string.append(c_string, n); - chars_left -= n + 1; - c_string += n + 1; - } else { - // Find the last whitespace on this 80-char line - int whitespace = kLineLength-chars_in_line-1; // < 80 chars/line - while ( whitespace > 0 && !isspace(c_string[whitespace]) ) { - --whitespace; - } - if (whitespace <= 0) { - // Couldn't find any whitespace to make a line break. Just dump the - // rest out! - final_string += c_string; - chars_in_line = kLineLength; // next part gets its own line for sure! - break; - } - final_string += string(c_string, whitespace); - chars_in_line += whitespace; - while (isspace(c_string[whitespace])) ++whitespace; - c_string += whitespace; - chars_left -= whitespace; - } - if (*c_string == '\0') - break; - StringAppendF(&final_string, "\n "); - chars_in_line = 6; - } - - // Append data type - AddString(string("type: ") + flag.type, &final_string, &chars_in_line); - // The listed default value will be the actual default from the flag - // definition in the originating source file, unless the value has - // subsequently been modified using SetCommandLineOptionWithMode() with mode - // SET_FLAGS_DEFAULT, or by setting FLAGS_foo = bar before ParseCommandLineFlags(). - AddString(PrintStringFlagsWithQuotes(flag, "default", false), &final_string, - &chars_in_line); - if (!flag.is_default) { - AddString(PrintStringFlagsWithQuotes(flag, "currently", true), - &final_string, &chars_in_line); - } - - StringAppendF(&final_string, "\n"); - return final_string; -} - -// Simple routine to xml-escape a string: escape & and < only. -static string XMLText(const string& txt) { - string ans = txt; - for (string::size_type pos = 0; (pos = ans.find("&", pos)) != string::npos; ) - ans.replace(pos++, 1, "&"); - for (string::size_type pos = 0; (pos = ans.find("<", pos)) != string::npos; ) - ans.replace(pos++, 1, "<"); - return ans; -} - -static void AddXMLTag(string* r, const char* tag, const string& txt) { - StringAppendF(r, "<%s>%s</%s>", tag, XMLText(txt).c_str(), tag); -} - - -static string DescribeOneFlagInXML(const CommandLineFlagInfo& flag) { - // The file and flagname could have been attributes, but default - // and meaning need to avoid attribute normalization. This way it - // can be parsed by simple programs, in addition to xml parsers. - string r("<flag>"); - AddXMLTag(&r, "file", flag.filename); - AddXMLTag(&r, "name", flag.name); - AddXMLTag(&r, "meaning", flag.description); - AddXMLTag(&r, "default", flag.default_value); - AddXMLTag(&r, "current", flag.current_value); - AddXMLTag(&r, "type", flag.type); - r += "</flag>"; - return r; -} - -// -------------------------------------------------------------------- -// ShowUsageWithFlags() -// ShowUsageWithFlagsRestrict() -// ShowXMLOfFlags() -// These routines variously expose the registry's list of flag -// values. ShowUsage*() prints the flag-value information -// to stdout in a user-readable format (that's what --help uses). -// The Restrict() version limits what flags are shown. -// ShowXMLOfFlags() prints the flag-value information to stdout -// in a machine-readable format. In all cases, the flags are -// sorted: first by filename they are defined in, then by flagname. -// -------------------------------------------------------------------- - -static const char* Basename(const char* filename) { - const char* sep = strrchr(filename, PATH_SEPARATOR); - return sep ? sep + 1 : filename; -} - -static string Dirname(const string& filename) { - string::size_type sep = filename.rfind(PATH_SEPARATOR); - return filename.substr(0, (sep == string::npos) ? 0 : sep); -} - -// Test whether a filename contains at least one of the substrings. -static bool FileMatchesSubstring(const string& filename, - const vector<string>& substrings) { - for (vector<string>::const_iterator target = substrings.begin(); - target != substrings.end(); - ++target) { - if (strstr(filename.c_str(), target->c_str()) != NULL) - return true; - // If the substring starts with a '/', that means that we want - // the string to be at the beginning of a directory component. - // That should match the first directory component as well, so - // we allow '/foo' to match a filename of 'foo'. - if (!target->empty() && (*target)[0] == PATH_SEPARATOR && - strncmp(filename.c_str(), target->c_str() + 1, - strlen(target->c_str() + 1)) == 0) - return true; - } - return false; -} - -// Show help for every filename which matches any of the target substrings. -// If substrings is empty, shows help for every file. If a flag's help message -// has been stripped (e.g. by adding '#define STRIP_FLAG_HELP 1' -// before including gflags/gflags.h), then this flag will not be displayed -// by '--help' and its variants. -static void ShowUsageWithFlagsMatching(const char *argv0, - const vector<string> &substrings) { - fprintf(stdout, "%s: %s\n", Basename(argv0), ProgramUsage()); - - vector<CommandLineFlagInfo> flags; - GetAllFlags(&flags); // flags are sorted by filename, then flagname - - string last_filename; // so we know when we're at a new file - bool first_directory = true; // controls blank lines between dirs - bool found_match = false; // stays false iff no dir matches restrict - for (vector<CommandLineFlagInfo>::const_iterator flag = flags.begin(); - flag != flags.end(); - ++flag) { - if (substrings.empty() || - FileMatchesSubstring(flag->filename, substrings)) { - // If the flag has been stripped, pretend that it doesn't exist. - if (flag->description == kStrippedFlagHelp) continue; - found_match = true; // this flag passed the match! - if (flag->filename != last_filename) { // new file - if (Dirname(flag->filename) != Dirname(last_filename)) { // new dir! - if (!first_directory) - fprintf(stdout, "\n\n"); // put blank lines between directories - first_directory = false; - } - fprintf(stdout, "\n Flags from %s:\n", flag->filename.c_str()); - last_filename = flag->filename; - } - // Now print this flag - fprintf(stdout, "%s", DescribeOneFlag(*flag).c_str()); - } - } - if (!found_match && !substrings.empty()) { - fprintf(stdout, "\n No modules matched: use -help\n"); - } -} - -void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict) { - vector<string> substrings; - if (restrict != NULL && *restrict != '\0') { - substrings.push_back(restrict); - } - ShowUsageWithFlagsMatching(argv0, substrings); -} - -void ShowUsageWithFlags(const char *argv0) { - ShowUsageWithFlagsRestrict(argv0, ""); -} - -// Convert the help, program, and usage to xml. -static void ShowXMLOfFlags(const char *prog_name) { - vector<CommandLineFlagInfo> flags; - GetAllFlags(&flags); // flags are sorted: by filename, then flagname - - // XML. There is no corresponding schema yet - fprintf(stdout, "<?xml version=\"1.0\"?>\n"); - // The document - fprintf(stdout, "<AllFlags>\n"); - // the program name and usage - fprintf(stdout, "<program>%s</program>\n", - XMLText(Basename(prog_name)).c_str()); - fprintf(stdout, "<usage>%s</usage>\n", - XMLText(ProgramUsage()).c_str()); - // All the flags - for (vector<CommandLineFlagInfo>::const_iterator flag = flags.begin(); - flag != flags.end(); - ++flag) { - if (flag->description != kStrippedFlagHelp) - fprintf(stdout, "%s\n", DescribeOneFlagInXML(*flag).c_str()); - } - // The end of the document - fprintf(stdout, "</AllFlags>\n"); -} - -// -------------------------------------------------------------------- -// ShowVersion() -// Called upon --version. Prints build-related info. -// -------------------------------------------------------------------- - -static void ShowVersion() { - const char* version_string = VersionString(); - if (version_string && *version_string) { - fprintf(stdout, "%s version %s\n", - ProgramInvocationShortName(), version_string); - } else { - fprintf(stdout, "%s\n", ProgramInvocationShortName()); - } -# if !defined(NDEBUG) - fprintf(stdout, "Debug build (NDEBUG not #defined)\n"); -# endif -} - -static void AppendPrognameStrings(vector<string>* substrings, - const char* progname) { - string r(""); - r += PATH_SEPARATOR; - r += progname; - substrings->push_back(r + "."); - substrings->push_back(r + "-main."); - substrings->push_back(r + "_main."); -} - -// -------------------------------------------------------------------- -// HandleCommandLineHelpFlags() -// Checks all the 'reporting' commandline flags to see if any -// have been set. If so, handles them appropriately. Note -// that all of them, by definition, cause the program to exit -// if they trigger. -// -------------------------------------------------------------------- - -void HandleCommandLineHelpFlags() { - const char* progname = ProgramInvocationShortName(); - - HandleCommandLineCompletions(); - - vector<string> substrings; - AppendPrognameStrings(&substrings, progname); - - if (FLAGS_helpshort) { - // show only flags related to this binary: - // E.g. for fileutil.cc, want flags containing ... "/fileutil." cc - ShowUsageWithFlagsMatching(progname, substrings); - gflags_exitfunc(1); - - } else if (FLAGS_help || FLAGS_helpfull) { - // show all options - ShowUsageWithFlagsRestrict(progname, ""); // empty restrict - gflags_exitfunc(1); - - } else if (!FLAGS_helpon.empty()) { - string restrict = PATH_SEPARATOR + FLAGS_helpon + "."; - ShowUsageWithFlagsRestrict(progname, restrict.c_str()); - gflags_exitfunc(1); - - } else if (!FLAGS_helpmatch.empty()) { - ShowUsageWithFlagsRestrict(progname, FLAGS_helpmatch.c_str()); - gflags_exitfunc(1); - - } else if (FLAGS_helppackage) { - // Shows help for all files in the same directory as main(). We - // don't want to resort to looking at dirname(progname), because - // the user can pick progname, and it may not relate to the file - // where main() resides. So instead, we search the flags for a - // filename like "/progname.cc", and take the dirname of that. - vector<CommandLineFlagInfo> flags; - GetAllFlags(&flags); - string last_package; - for (vector<CommandLineFlagInfo>::const_iterator flag = flags.begin(); - flag != flags.end(); - ++flag) { - if (!FileMatchesSubstring(flag->filename, substrings)) - continue; - const string package = Dirname(flag->filename) + PATH_SEPARATOR; - if (package != last_package) { - ShowUsageWithFlagsRestrict(progname, package.c_str()); - VLOG(7) << "Found package: " << package; - if (!last_package.empty()) { // means this isn't our first pkg - LOG(WARNING) << "Multiple packages contain a file=" << progname; - } - last_package = package; - } - } - if (last_package.empty()) { // never found a package to print - LOG(WARNING) << "Unable to find a package for file=" << progname; - } - gflags_exitfunc(1); - - } else if (FLAGS_helpxml) { - ShowXMLOfFlags(progname); - gflags_exitfunc(1); - - } else if (FLAGS_version) { - ShowVersion(); - // Unlike help, we may be asking for version in a script, so return 0 - gflags_exitfunc(0); - - } -} - - -} // namespace GFLAGS_NAMESPACE
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/src/mutex.h ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/src/mutex.h b/third_party/src/tmb/third_party/gflags/src/mutex.h deleted file mode 100644 index 0bdd9d5..0000000 --- a/third_party/src/tmb/third_party/gflags/src/mutex.h +++ /dev/null @@ -1,351 +0,0 @@ -// Copyright (c) 2007, 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. -// -// --- -// -// A simple mutex wrapper, supporting locks and read-write locks. -// You should assume the locks are *not* re-entrant. -// -// This class is meant to be internal-only and should be wrapped by an -// internal namespace. Before you use this module, please give the -// name of your internal namespace for this module. Or, if you want -// to expose it, you'll want to move it to the Google namespace. We -// cannot put this class in global namespace because there can be some -// problems when we have multiple versions of Mutex in each shared object. -// -// NOTE: by default, we have #ifdef'ed out the TryLock() method. -// This is for two reasons: -// 1) TryLock() under Windows is a bit annoying (it requires a -// #define to be defined very early). -// 2) TryLock() is broken for NO_THREADS mode, at least in NDEBUG -// mode. -// If you need TryLock(), and either these two caveats are not a -// problem for you, or you're willing to work around them, then -// feel free to #define GMUTEX_TRYLOCK, or to remove the #ifdefs -// in the code below. -// -// CYGWIN NOTE: Cygwin support for rwlock seems to be buggy: -// http://www.cygwin.com/ml/cygwin/2008-12/msg00017.html -// Because of that, we might as well use windows locks for -// cygwin. They seem to be more reliable than the cygwin pthreads layer. -// -// TRICKY IMPLEMENTATION NOTE: -// This class is designed to be safe to use during -// dynamic-initialization -- that is, by global constructors that are -// run before main() starts. The issue in this case is that -// dynamic-initialization happens in an unpredictable order, and it -// could be that someone else's dynamic initializer could call a -// function that tries to acquire this mutex -- but that all happens -// before this mutex's constructor has run. (This can happen even if -// the mutex and the function that uses the mutex are in the same .cc -// file.) Basically, because Mutex does non-trivial work in its -// constructor, it's not, in the naive implementation, safe to use -// before dynamic initialization has run on it. -// -// The solution used here is to pair the actual mutex primitive with a -// bool that is set to true when the mutex is dynamically initialized. -// (Before that it's false.) Then we modify all mutex routines to -// look at the bool, and not try to lock/unlock until the bool makes -// it to true (which happens after the Mutex constructor has run.) -// -// This works because before main() starts -- particularly, during -// dynamic initialization -- there are no threads, so a) it's ok that -// the mutex operations are a no-op, since we don't need locking then -// anyway; and b) we can be quite confident our bool won't change -// state between a call to Lock() and a call to Unlock() (that would -// require a global constructor in one translation unit to call Lock() -// and another global constructor in another translation unit to call -// Unlock() later, which is pretty perverse). -// -// That said, it's tricky, and can conceivably fail; it's safest to -// avoid trying to acquire a mutex in a global constructor, if you -// can. One way it can fail is that a really smart compiler might -// initialize the bool to true at static-initialization time (too -// early) rather than at dynamic-initialization time. To discourage -// that, we set is_safe_ to true in code (not the constructor -// colon-initializer) and set it to true via a function that always -// evaluates to true, but that the compiler can't know always -// evaluates to true. This should be good enough. -// -// A related issue is code that could try to access the mutex -// after it's been destroyed in the global destructors (because -// the Mutex global destructor runs before some other global -// destructor, that tries to acquire the mutex). The way we -// deal with this is by taking a constructor arg that global -// mutexes should pass in, that causes the destructor to do no -// work. We still depend on the compiler not doing anything -// weird to a Mutex's memory after it is destroyed, but for a -// static global variable, that's pretty safe. - -#ifndef GFLAGS_MUTEX_H_ -#define GFLAGS_MUTEX_H_ - -#include "gflags_declare.h" // to figure out pthreads support - -#if defined(NO_THREADS) - typedef int MutexType; // to keep a lock-count -#elif defined(OS_WINDOWS) -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN // We only need minimal includes -# endif -# ifndef NOMINMAX -# define NOMINMAX // Don't want windows to override min()/max() -# endif -# ifdef GMUTEX_TRYLOCK - // We need Windows NT or later for TryEnterCriticalSection(). If you - // don't need that functionality, you can remove these _WIN32_WINNT - // lines, and change TryLock() to assert(0) or something. -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0400 -# endif -# endif -# include <windows.h> - typedef CRITICAL_SECTION MutexType; -#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK) - // Needed for pthread_rwlock_*. If it causes problems, you could take it - // out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it - // *does* cause problems for FreeBSD, or MacOSX, but isn't needed - // for locking there.) -# ifdef __linux__ -# if _XOPEN_SOURCE < 500 // including not being defined at all -# undef _XOPEN_SOURCE -# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls -# endif -# endif -# include <pthread.h> - typedef pthread_rwlock_t MutexType; -#elif defined(HAVE_PTHREAD) -# include <pthread.h> - typedef pthread_mutex_t MutexType; -#else -# error Need to implement mutex.h for your architecture, or #define NO_THREADS -#endif - -#include <assert.h> -#include <stdlib.h> // for abort() - -#define MUTEX_NAMESPACE gflags_mutex_namespace - -namespace MUTEX_NAMESPACE { - -class Mutex { - public: - // This is used for the single-arg constructor - enum LinkerInitialized { LINKER_INITIALIZED }; - - // Create a Mutex that is not held by anybody. This constructor is - // typically used for Mutexes allocated on the heap or the stack. - inline Mutex(); - // This constructor should be used for global, static Mutex objects. - // 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); - - // Destructor - inline ~Mutex(); - - inline void Lock(); // Block if needed until free then acquire exclusively - inline void Unlock(); // Release a lock acquired via Lock() -#ifdef GMUTEX_TRYLOCK - inline bool TryLock(); // If free, Lock() and return true, else return false -#endif - // Note that on systems that don't support read-write locks, these may - // be implemented as synonyms to Lock() and Unlock(). So you can use - // these for efficiency, but don't use them anyplace where being able - // to do shared reads is necessary to avoid deadlock. - inline void ReaderLock(); // Block until free or shared then acquire a share - inline void ReaderUnlock(); // Release a read share of this Mutex - inline void WriterLock() { Lock(); } // Acquire an exclusive lock - inline void WriterUnlock() { Unlock(); } // Release a lock from WriterLock() - - private: - MutexType mutex_; - // We want to make sure that the compiler sets is_safe_ to true only - // when we tell it to, and never makes assumptions is_safe_ is - // always true. volatile is the most reliable way to do that. - volatile bool is_safe_; - // This indicates which constructor was called. - bool destroy_; - - inline void SetIsSafe() { is_safe_ = true; } - - // Catch the error of writing Mutex when intending MutexLock. - Mutex(Mutex* /*ignored*/) {} - // Disallow "evil" constructors - Mutex(const Mutex&); - void operator=(const Mutex&); -}; - -// Now the implementation of Mutex for various systems -#if defined(NO_THREADS) - -// When we don't have threads, we can be either reading or writing, -// but not both. We can have lots of readers at once (in no-threads -// mode, that's most likely to happen in recursive function calls), -// but only one writer. We represent this by having mutex_ be -1 when -// writing and a number > 0 when reading (and 0 when no lock is held). -// -// In debug mode, we assert these invariants, while in non-debug mode -// we do nothing, for efficiency. That's why everything is in an -// assert. - -Mutex::Mutex() : mutex_(0) { } -Mutex::Mutex(Mutex::LinkerInitialized) : mutex_(0) { } -Mutex::~Mutex() { assert(mutex_ == 0); } -void Mutex::Lock() { assert(--mutex_ == -1); } -void Mutex::Unlock() { assert(mutex_++ == -1); } -#ifdef GMUTEX_TRYLOCK -bool Mutex::TryLock() { if (mutex_) return false; Lock(); return true; } -#endif -void Mutex::ReaderLock() { assert(++mutex_ > 0); } -void Mutex::ReaderUnlock() { assert(mutex_-- > 0); } - -#elif defined(OS_WINDOWS) - -Mutex::Mutex() : destroy_(true) { - InitializeCriticalSection(&mutex_); - SetIsSafe(); -} -Mutex::Mutex(LinkerInitialized) : destroy_(false) { - InitializeCriticalSection(&mutex_); - SetIsSafe(); -} -Mutex::~Mutex() { if (destroy_) DeleteCriticalSection(&mutex_); } -void Mutex::Lock() { if (is_safe_) EnterCriticalSection(&mutex_); } -void Mutex::Unlock() { if (is_safe_) LeaveCriticalSection(&mutex_); } -#ifdef GMUTEX_TRYLOCK -bool Mutex::TryLock() { return is_safe_ ? - TryEnterCriticalSection(&mutex_) != 0 : true; } -#endif -void Mutex::ReaderLock() { Lock(); } // we don't have read-write locks -void Mutex::ReaderUnlock() { Unlock(); } - -#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK) - -#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \ - if (is_safe_ && fncall(&mutex_) != 0) abort(); \ -} while (0) - -Mutex::Mutex() : destroy_(true) { - SetIsSafe(); - if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort(); -} -Mutex::Mutex(Mutex::LinkerInitialized) : destroy_(false) { - SetIsSafe(); - if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort(); -} -Mutex::~Mutex() { if (destroy_) SAFE_PTHREAD(pthread_rwlock_destroy); } -void Mutex::Lock() { SAFE_PTHREAD(pthread_rwlock_wrlock); } -void Mutex::Unlock() { SAFE_PTHREAD(pthread_rwlock_unlock); } -#ifdef GMUTEX_TRYLOCK -bool Mutex::TryLock() { return is_safe_ ? - pthread_rwlock_trywrlock(&mutex_) == 0 : true; } -#endif -void Mutex::ReaderLock() { SAFE_PTHREAD(pthread_rwlock_rdlock); } -void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); } -#undef SAFE_PTHREAD - -#elif defined(HAVE_PTHREAD) - -#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \ - if (is_safe_ && fncall(&mutex_) != 0) abort(); \ -} while (0) - -Mutex::Mutex() : destroy_(true) { - SetIsSafe(); - if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort(); -} -Mutex::Mutex(Mutex::LinkerInitialized) : destroy_(false) { - SetIsSafe(); - if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort(); -} -Mutex::~Mutex() { if (destroy_) SAFE_PTHREAD(pthread_mutex_destroy); } -void Mutex::Lock() { SAFE_PTHREAD(pthread_mutex_lock); } -void Mutex::Unlock() { SAFE_PTHREAD(pthread_mutex_unlock); } -#ifdef GMUTEX_TRYLOCK -bool Mutex::TryLock() { return is_safe_ ? - pthread_mutex_trylock(&mutex_) == 0 : true; } -#endif -void Mutex::ReaderLock() { Lock(); } -void Mutex::ReaderUnlock() { Unlock(); } -#undef SAFE_PTHREAD - -#endif - -// -------------------------------------------------------------------------- -// Some helper classes - -// MutexLock(mu) acquires mu when constructed and releases it when destroyed. -class MutexLock { - public: - explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); } - ~MutexLock() { mu_->Unlock(); } - private: - Mutex * const mu_; - // Disallow "evil" constructors - MutexLock(const MutexLock&); - void operator=(const MutexLock&); -}; - -// ReaderMutexLock and WriterMutexLock do the same, for rwlocks -class ReaderMutexLock { - public: - explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); } - ~ReaderMutexLock() { mu_->ReaderUnlock(); } - private: - Mutex * const mu_; - // Disallow "evil" constructors - ReaderMutexLock(const ReaderMutexLock&); - void operator=(const ReaderMutexLock&); -}; - -class WriterMutexLock { - public: - explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); } - ~WriterMutexLock() { mu_->WriterUnlock(); } - private: - Mutex * const mu_; - // Disallow "evil" constructors - WriterMutexLock(const WriterMutexLock&); - void operator=(const WriterMutexLock&); -}; - -// Catch bug where variable name is omitted, e.g. MutexLock (&mu); -#define MutexLock(x) COMPILE_ASSERT(0, mutex_lock_decl_missing_var_name) -#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name) -#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name) - -} // namespace MUTEX_NAMESPACE - -using namespace MUTEX_NAMESPACE; - -#undef MUTEX_NAMESPACE - -#endif /* #define GFLAGS_MUTEX_H__ */ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/src/util.h ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/src/util.h b/third_party/src/tmb/third_party/gflags/src/util.h deleted file mode 100644 index 366e1be..0000000 --- a/third_party/src/tmb/third_party/gflags/src/util.h +++ /dev/null @@ -1,373 +0,0 @@ -// Copyright (c) 2011, 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. -// --- -// -// Some generically useful utility routines that in google-land would -// be their own projects. We make a shortened version here. - -#ifndef GFLAGS_UTIL_H_ -#define GFLAGS_UTIL_H_ - -#include "config.h" - -#include <assert.h> -#include <config.h> -#ifdef HAVE_INTTYPES_H -# include <inttypes.h> -#endif -#include <stdarg.h> // for va_* -#include <stdlib.h> -#include <stdio.h> -#include <iostream> -#include <string> -#include <errno.h> -#ifdef HAVE_SYS_STAT_H -# include <sys/stat.h> // for mkdir -#endif - - -namespace GFLAGS_NAMESPACE { - - -// This is used for unittests for death-testing. It is defined in gflags.cc. -extern GFLAGS_DLL_DECL void (*gflags_exitfunc)(int); - -// Work properly if either strtoll or strtoq is on this system. -#if defined(strtoll) || defined(HAVE_STRTOLL) -# define strto64 strtoll -# define strtou64 strtoull -#elif defined(HAVE_STRTOQ) -# define strto64 strtoq -# define strtou64 strtouq -// Neither strtoll nor strtoq are defined. I hope strtol works! -#else -# define strto64 strtol -# define strtou64 strtoul -#endif - -// If we have inttypes.h, it will have defined PRId32/etc for us. -// If not, take our best guess. -#ifndef PRId32 -# define PRId32 "d" -#endif -#ifndef PRId64 -# define PRId64 "lld" -#endif -#ifndef PRIu64 -# define PRIu64 "llu" -#endif - -typedef signed char int8; -typedef unsigned char uint8; - -// -- utility macros --------------------------------------------------------- - -template <bool> struct CompileAssert {}; -#define COMPILE_ASSERT(expr, msg) \ - typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] - -// Returns the number of elements in an array. -#define arraysize(arr) (sizeof(arr)/sizeof(*(arr))) - - -// -- logging and testing --------------------------------------------------- - -// For now, we ignore the level for logging, and don't show *VLOG's at -// all, except by hand-editing the lines below -#define LOG(level) std::cerr -#define VLOG(level) if (true) {} else std::cerr -#define DVLOG(level) if (true) {} else std::cerr - -// 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 -// compilation mode. Therefore, it is safe to do things like: -// CHECK(fp->Write(x) == 4) -// We allow stream-like objects after this for debugging, but they're ignored. -#define EXPECT_TRUE(condition) \ - if (true) { \ - if (!(condition)) { \ - fprintf(stderr, "Check failed: %s\n", #condition); \ - exit(1); \ - } \ - } else std::cerr << "" - -#define EXPECT_OP(op, val1, val2) \ - if (true) { \ - if (!((val1) op (val2))) { \ - fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2); \ - exit(1); \ - } \ - } else std::cerr << "" - -#define EXPECT_EQ(val1, val2) EXPECT_OP(==, val1, val2) -#define EXPECT_NE(val1, val2) EXPECT_OP(!=, val1, val2) -#define EXPECT_LE(val1, val2) EXPECT_OP(<=, val1, val2) -#define EXPECT_LT(val1, val2) EXPECT_OP(< , val1, val2) -#define EXPECT_GE(val1, val2) EXPECT_OP(>=, val1, val2) -#define EXPECT_GT(val1, val2) EXPECT_OP(> , val1, val2) -#define EXPECT_FALSE(cond) EXPECT_TRUE(!(cond)) - -// C99 declares isnan and isinf should be macros, so the #ifdef test -// should be reliable everywhere. Of course, it's not, but these -// are testing pertty marginal functionality anyway, so it's ok to -// not-run them even in situations they might, with effort, be made to work. -#ifdef isnan // Some compilers, like sun's for Solaris 10, don't define this -#define EXPECT_NAN(arg) \ - do { \ - if (!isnan(arg)) { \ - fprintf(stderr, "Check failed: isnan(%s)\n", #arg); \ - exit(1); \ - } \ - } while (0) -#else -#define EXPECT_NAN(arg) -#endif - -#ifdef isinf // Some compilers, like sun's for Solaris 10, don't define this -#define EXPECT_INF(arg) \ - do { \ - if (!isinf(arg)) { \ - fprintf(stderr, "Check failed: isinf(%s)\n", #arg); \ - exit(1); \ - } \ - } while (0) -#else -#define EXPECT_INF(arg) -#endif - -#define EXPECT_DOUBLE_EQ(val1, val2) \ - do { \ - if (((val1) < (val2) - 0.001 || (val1) > (val2) + 0.001)) { \ - fprintf(stderr, "Check failed: %s == %s\n", #val1, #val2); \ - exit(1); \ - } \ - } while (0) - -#define EXPECT_STREQ(val1, val2) \ - do { \ - if (strcmp((val1), (val2)) != 0) { \ - fprintf(stderr, "Check failed: streq(%s, %s)\n", #val1, #val2); \ - exit(1); \ - } \ - } while (0) - -// Call this in a .cc file where you will later call RUN_ALL_TESTS in main(). -#define TEST_INIT \ - static std::vector<void (*)()> g_testlist; /* the tests to run */ \ - static int RUN_ALL_TESTS() { \ - std::vector<void (*)()>::const_iterator it; \ - for (it = g_testlist.begin(); it != g_testlist.end(); ++it) { \ - (*it)(); /* The test will error-exit if there's a problem. */ \ - } \ - fprintf(stderr, "\nPassed %d tests\n\nPASS\n", \ - static_cast<int>(g_testlist.size())); \ - return 0; \ - } - -// Note that this macro uses a FlagSaver to keep tests isolated. -#define TEST(a, b) \ - struct Test_##a##_##b { \ - Test_##a##_##b() { g_testlist.push_back(&Run); } \ - static void Run() { \ - FlagSaver fs; \ - fprintf(stderr, "Running test %s/%s\n", #a, #b); \ - RunTest(); \ - } \ - static void RunTest(); \ - }; \ - static Test_##a##_##b g_test_##a##_##b; \ - void Test_##a##_##b::RunTest() - -// This is a dummy class that eases the google->opensource transition. -namespace testing { -class Test {}; -} - -// Call this in a .cc file where you will later call EXPECT_DEATH -#define EXPECT_DEATH_INIT \ - static bool g_called_exit; \ - static void CalledExit(int) { g_called_exit = true; } - -#define EXPECT_DEATH(fn, msg) \ - do { \ - g_called_exit = false; \ - gflags_exitfunc = &CalledExit; \ - fn; \ - gflags_exitfunc = &exit; /* set back to its default */ \ - if (!g_called_exit) { \ - fprintf(stderr, "Function didn't die (%s): %s\n", msg, #fn); \ - exit(1); \ - } \ - } while (0) - -#define GTEST_HAS_DEATH_TEST 1 - -// -- path routines ---------------------------------------------------------- - -// Tries to create the directory path as a temp-dir. If it fails, -// changes path to some directory it *can* create. -#if defined(__MINGW32__) -#include <io.h> -inline void MakeTmpdir(std::string* path) { - if (!path->empty()) { - path->append("/gflags_unittest_testdir"); - int err = mkdir(path->c_str()); - if (err == 0 || errno == EEXIST) return; - } - // I had trouble creating a directory in /tmp from mingw - *path = "./gflags_unittest"; - mkdir(path->c_str()); -} -#elif defined(_MSC_VER) -#include <direct.h> -inline void MakeTmpdir(std::string* path) { - if (!path->empty()) { - int err = _mkdir(path->c_str()); - if (err == 0 || errno == EEXIST) return; - } - char tmppath_buffer[1024]; - int tmppath_len = GetTempPathA(sizeof(tmppath_buffer), tmppath_buffer); - assert(tmppath_len > 0 && tmppath_len < sizeof(tmppath_buffer)); - assert(tmppath_buffer[tmppath_len - 1] == '\\'); // API guarantees it - *path = std::string(tmppath_buffer) + "gflags_unittest"; - _mkdir(path->c_str()); -} -#else -inline void MakeTmpdir(std::string* path) { - if (!path->empty()) { - int err = mkdir(path->c_str(), 0755); - if (err == 0 || errno == EEXIST) return; - } - mkdir("/tmp/gflags_unittest", 0755); -} -#endif - -// -- string routines -------------------------------------------------------- - -inline void InternalStringPrintf(std::string* output, const char* format, - va_list ap) { - char space[128]; // try a small buffer and hope it fits - - // It's possible for methods that use a va_list to invalidate - // the data in it upon use. The fix is to make a copy - // of the structure before using it and use that copy instead. - va_list backup_ap; - va_copy(backup_ap, ap); - int bytes_written = vsnprintf(space, sizeof(space), format, backup_ap); - va_end(backup_ap); - - if ((bytes_written >= 0) && (static_cast<size_t>(bytes_written) < sizeof(space))) { - output->append(space, bytes_written); - return; - } - - // Repeatedly increase buffer size until it fits. - int length = sizeof(space); - while (true) { - if (bytes_written < 0) { - // Older snprintf() behavior. :-( Just try doubling the buffer size - length *= 2; - } else { - // We need exactly "bytes_written+1" characters - length = bytes_written+1; - } - char* buf = new char[length]; - - // Restore the va_list before we use it again - va_copy(backup_ap, ap); - bytes_written = vsnprintf(buf, length, format, backup_ap); - va_end(backup_ap); - - if ((bytes_written >= 0) && (bytes_written < length)) { - output->append(buf, bytes_written); - delete[] buf; - return; - } - delete[] buf; - } -} - -// Clears output before writing to it. -inline void SStringPrintf(std::string* output, const char* format, ...) { - va_list ap; - va_start(ap, format); - output->clear(); - InternalStringPrintf(output, format, ap); - va_end(ap); -} - -inline void StringAppendF(std::string* output, const char* format, ...) { - va_list ap; - va_start(ap, format); - InternalStringPrintf(output, format, ap); - va_end(ap); -} - -inline std::string StringPrintf(const char* format, ...) { - va_list ap; - va_start(ap, format); - std::string output; - InternalStringPrintf(&output, format, ap); - va_end(ap); - return output; -} - -inline bool SafeGetEnv(const char *varname, std::string &valstr) -{ -#if defined(_MSC_VER) && _MSC_VER >= 1400 - char *val; - size_t sz; - if (_dupenv_s(&val, &sz, varname) != 0 || !val) return false; - valstr = val; - free(val); -#else - const char * const val = getenv(varname); - if (!val) return false; - valstr = val; -#endif - return true; -} - -inline int SafeFOpen(FILE **fp, const char* fname, const char *mode) -{ -#if defined(_MSC_VER) && _MSC_VER >= 1400 - return fopen_s(fp, fname, mode); -#else - assert(fp != NULL); - *fp = fopen(fname, mode); - // errno only guaranteed to be set on failure - return ((*fp == NULL) ? errno : 0); -#endif -} - - -} // namespace GFLAGS_NAMESPACE - - -#endif // GFLAGS_UTIL_H_ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/src/windows_port.cc ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/src/windows_port.cc b/third_party/src/tmb/third_party/gflags/src/windows_port.cc deleted file mode 100644 index 1f40458..0000000 --- a/third_party/src/tmb/third_party/gflags/src/windows_port.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) 2009, 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. - * - * --- - * Author: Craig Silverstein - */ - -#ifndef _WIN32 -# error You should only be including windows/port.cc in a windows environment! -#endif - -#include <string.h> // for strlen(), memset(), memcmp() -#include <assert.h> -#include <stdarg.h> // for va_list, va_start, va_end -#include <windows.h> - -#include "windows_port.h" - -// These call the windows _vsnprintf, but always NUL-terminate. -#if !defined(__MINGW32__) && !defined(__MINGW64__) /* mingw already defines */ - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4996) // ignore _vsnprintf security warning -#endif -int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) { - if (size == 0) // not even room for a \0? - return -1; // not what C99 says to do, but what windows does - str[size-1] = '\0'; - return _vsnprintf(str, size-1, format, ap); -} -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -int snprintf(char *str, size_t size, const char *format, ...) { - int r; - va_list ap; - va_start(ap, format); - r = vsnprintf(str, size, format, ap); - va_end(ap); - return r; -} - -#endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/src/windows_port.h ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/src/windows_port.h b/third_party/src/tmb/third_party/gflags/src/windows_port.h deleted file mode 100644 index c8ff24f..0000000 --- a/third_party/src/tmb/third_party/gflags/src/windows_port.h +++ /dev/null @@ -1,127 +0,0 @@ -/* Copyright (c) 2009, 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. - * - * --- - * Author: Craig Silverstein - * - * These are some portability typedefs and defines to make it a bit - * easier to compile this code under VC++. - * - * Several of these are taken from glib: - * http://developer.gnome.org/doc/API/glib/glib-windows-compatability-functions.html - */ - -#ifndef GFLAGS_WINDOWS_PORT_H_ -#define GFLAGS_WINDOWS_PORT_H_ - -#include "config.h" - -// This must be defined before the windows.h is included. -// It's needed for mutex.h, to give access to the TryLock method. -# if !defined(_WIN32_WINNT) && !(defined( __MINGW32__) || defined(__MINGW64__)) -# define _WIN32_WINNT 0x0400 -# endif -// We always want minimal includes -#ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -#endif -#include <windows.h> -#include <direct.h> /* for mkdir */ -#include <stdlib.h> /* for _putenv, getenv */ -#include <stdio.h> /* need this to override stdio's snprintf, also defines _unlink used by unit tests */ -#include <stdarg.h> /* util.h uses va_copy */ -#include <string.h> /* for _stricmp and _strdup */ - -/* We can't just use _vsnprintf and _snprintf as drop-in-replacements, - * because they don't always NUL-terminate. :-( We also can't use the - * name vsnprintf, since windows defines that (but not snprintf (!)). - */ -#if !defined(__MINGW32__) && !defined(__MINGW64__) /* mingw already defines */ -extern GFLAGS_DLL_DECL int snprintf(char *str, size_t size, - const char *format, ...); -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) -#define va_copy(dst, src) (dst) = (src) -#endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */ - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4996) // ignore getenv security warning -#endif -inline void setenv(const char* name, const char* value, int) { - // In windows, it's impossible to set a variable to the empty string. - // We handle this by setting it to "0" and the NUL-ing out the \0. - // That is, we putenv("FOO=0") and then find out where in memory the - // putenv wrote "FOO=0", and change it in-place to "FOO=\0". - // c.f. http://svn.apache.org/viewvc/stdcxx/trunk/tests/src/environ.cpp?r1=611451&r2=637508&pathrev=637508 - static const char* const kFakeZero = "0"; - if (*value == '\0') - value = kFakeZero; - // Apparently the semantics of putenv() is that the input - // must live forever, so we leak memory here. :-( - const size_t nameval_len = strlen(name) + 1 + strlen(value) + 1; - char* nameval = reinterpret_cast<char*>(malloc(nameval_len)); - snprintf(nameval, nameval_len, "%s=%s", name, value); - _putenv(nameval); - if (value == kFakeZero) { - nameval[nameval_len - 2] = '\0'; // works when putenv() makes no copy - if (*getenv(name) != '\0') - *getenv(name) = '\0'; // works when putenv() copies nameval - } -} -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#define strcasecmp _stricmp - -#if defined(_MSC_VER) && _MSC_VER >= 1400 -#define strdup _strdup -#define unlink _unlink -#endif - -#define PRId32 "d" -#define PRIu32 "u" -#define PRId64 "I64d" -#define PRIu64 "I64u" - -#if !defined(__MINGW32__) && !defined(__MINGW64__) -#define strtoq _strtoi64 -#define strtouq _strtoui64 -#define strtoll _strtoi64 -#define strtoull _strtoui64 -#define atoll _atoi64 -#endif - -#ifndef PATH_MAX -#define PATH_MAX 1024 -#endif - -#endif /* GFLAGS_WINDOWS_PORT_H_ */ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/test/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/CMakeLists.txt b/third_party/src/tmb/third_party/gflags/test/CMakeLists.txt deleted file mode 100644 index ff07474..0000000 --- a/third_party/src/tmb/third_party/gflags/test/CMakeLists.txt +++ /dev/null @@ -1,185 +0,0 @@ -## gflags tests - -# ---------------------------------------------------------------------------- -# output directories -set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") -set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") -set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") - -# set working directory of test commands -set (GFLAGS_FLAGFILES_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - -# ---------------------------------------------------------------------------- -# common include directories and link libraries -include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") - -if (BUILD_SHARED_LIBS) - set (type shared) -else () - set (type static) -endif () -if (BUILD_gflags_LIB) - link_libraries (gflags-${type}) -else () - link_libraries (gflags_nothreads-${type}) -endif () - -# ---------------------------------------------------------------------------- -# STRIP_FLAG_HELP -add_executable (gflags_strip_flags_test gflags_strip_flags_test.cc) -# Make sure the --help output doesn't print the stripped text. -add_gflags_test (strip_flags_help 1 "" "This text should be stripped out" gflags_strip_flags_test --help) -# Make sure the stripped text isn't in the binary at all. -add_test ( - NAME strip_flags_binary - COMMAND "${CMAKE_COMMAND}" "-DBINARY=$<TARGET_FILE:gflags_strip_flags_test>" - -P "${CMAKE_CURRENT_SOURCE_DIR}/gflags_strip_flags_test.cmake" -) - -# ---------------------------------------------------------------------------- -# unit tests -configure_file (gflags_unittest.cc gflags_unittest-main.cc COPYONLY) -configure_file (gflags_unittest.cc gflags_unittest_main.cc COPYONLY) - -add_executable (gflags_unittest gflags_unittest.cc) -add_executable (gflags_unittest-main gflags_unittest-main.cc) -add_executable (gflags_unittest_main gflags_unittest_main.cc) - -if (OS_WINDOWS) - set (SLASH "\\\\") -else () - set (SLASH "/") -endif () - -# First, just make sure the gflags_unittest works as-is -add_gflags_test(unittest 0 "" "" gflags_unittest) - -# --help should show all flags, including flags from gflags_reporting -add_gflags_test(help-reporting 1 "${SLASH}gflags_reporting.cc:" "" gflags_unittest --help) - -# Make sure that --help prints even very long helpstrings. -add_gflags_test(long-helpstring 1 "end of a long helpstring" "" gflags_unittest --help) - -# Make sure --help reflects flag changes made before flag-parsing -add_gflags_test(changed_bool1 1 "-changed_bool1 (changed) type: bool default: true" "" gflags_unittest --help) -add_gflags_test(changed_bool2 1 "-changed_bool2 (changed) type: bool default: false currently: true" "" gflags_unittest --help) -# And on the command-line, too -add_gflags_test(changeable_string_var 1 "-changeable_string_var () type: string default: \"1\" currently: \"2\"" "" gflags_unittest --changeable_string_var 2 --help) - -# --nohelp and --help=false should be as if we didn't say anything -add_gflags_test(nohelp 0 "PASS" "" gflags_unittest --nohelp) -add_gflags_test(help=false 0 "PASS" "" gflags_unittest --help=false) - -# --helpfull is the same as help -add_gflags_test(helpfull 1 "${SLASH}gflags_reporting.cc:" "" gflags_unittest --helpfull) - -# --helpshort should show only flags from the gflags_unittest itself -add_gflags_test(helpshort 1 "${SLASH}gflags_unittest.cc:" "${SLASH}gflags_reporting.cc:" gflags_unittest --helpshort) - -# --helpshort should show the tldflag we created in the gflags_unittest dir -add_gflags_test(helpshort-tldflag1 1 "tldflag1" "${SLASH}google.cc:" gflags_unittest --helpshort) -add_gflags_test(helpshort-tldflag2 1 "tldflag2" "${SLASH}google.cc:" gflags_unittest --helpshort) - -# --helpshort should work if the main source file is suffixed with [_-]main -add_gflags_test(helpshort-main 1 "${SLASH}gflags_unittest-main.cc:" "${SLASH}gflags_reporting.cc:" gflags_unittest-main --helpshort) -add_gflags_test(helpshort_main 1 "${SLASH}gflags_unittest_main.cc:" "${SLASH}gflags_reporting.cc:" gflags_unittest_main --helpshort) - -# --helpon needs an argument -add_gflags_test(helpon 1 "'--helpon' is missing its argument; flag description: show help on" "" gflags_unittest --helpon) -# --helpon argument indicates what file we'll show args from -add_gflags_test(helpon=gflags 1 "${SLASH}gflags.cc:" "${SLASH}gflags_unittest.cc:" gflags_unittest --helpon=gflags) -# another way of specifying the argument -add_gflags_test(helpon_gflags 1 "${SLASH}gflags.cc:" "${SLASH}gflags_unittest.cc:" gflags_unittest --helpon gflags) -# test another argument -add_gflags_test(helpon=gflags_unittest 1 "${SLASH}gflags_unittest.cc:" "${SLASH}gflags.cc:" gflags_unittest --helpon=gflags_unittest) - -# helpmatch is like helpon but takes substrings -add_gflags_test(helpmatch_reporting 1 "${SLASH}gflags_reporting.cc:" "${SLASH}gflags_unittest.cc:" gflags_unittest -helpmatch reporting) -add_gflags_test(helpmatch=unittest 1 "${SLASH}gflags_unittest.cc:" "${SLASH}gflags.cc:" gflags_unittest -helpmatch=unittest) - -# if no flags are found with helpmatch or helpon, suggest --help -add_gflags_test(helpmatch=nosuchsubstring 1 "No modules matched" "${SLASH}gflags_unittest.cc:" gflags_unittest -helpmatch=nosuchsubstring) -add_gflags_test(helpon=nosuchmodule 1 "No modules matched" "${SLASH}gflags_unittest.cc:" gflags_unittest -helpon=nosuchmodule) - -# helppackage shows all the flags in the same dir as this unittest -# --help should show all flags, including flags from google.cc -add_gflags_test(helppackage 1 "${SLASH}gflags_reporting.cc:" "" gflags_unittest --helppackage) - -# xml! -add_gflags_test(helpxml 1 "${SLASH}gflags_unittest.cc</file>" "${SLASH}gflags_unittest.cc:" gflags_unittest --helpxml) - -# just print the version info and exit -add_gflags_test(version-1 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --version) -add_gflags_test(version-2 0 "version test_version" "${SLASH}gflags_unittest.cc:" gflags_unittest --version) - -# --undefok is a fun flag... -add_gflags_test(undefok-1 1 "unknown command line flag 'foo'" "" gflags_unittest --undefok= --foo --unused_bool) -add_gflags_test(undefok-2 0 "PASS" "" gflags_unittest --undefok=foo --foo --unused_bool) -# If you say foo is ok to be undefined, we'll accept --nofoo as well -add_gflags_test(undefok-3 0 "PASS" "" gflags_unittest --undefok=foo --nofoo --unused_bool) -# It's ok if the foo is in the middle -add_gflags_test(undefok-4 0 "PASS" "" gflags_unittest --undefok=fee,fi,foo,fum --foo --unused_bool) -# But the spelling has to be just right... -add_gflags_test(undefok-5 1 "unknown command line flag 'foo'" "" gflags_unittest --undefok=fo --foo --unused_bool) -add_gflags_test(undefok-6 1 "unknown command line flag 'foo'" "" gflags_unittest --undefok=foot --foo --unused_bool) - -# See if we can successfully load our flags from the flagfile -add_gflags_test(flagfile.1 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest "--flagfile=flagfile.1") -add_gflags_test(flagfile.2 0 "PASS" "" gflags_unittest "--flagfile=flagfile.2") -add_gflags_test(flagfile.3 0 "PASS" "" gflags_unittest "--flagfile=flagfile.3") - -# Also try to load flags from the environment -add_gflags_test(fromenv=version 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --fromenv=version) -add_gflags_test(tryfromenv=version 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --tryfromenv=version) -add_gflags_test(fromenv=help 0 "PASS" "" gflags_unittest --fromenv=help) -add_gflags_test(tryfromenv=help 0 "PASS" "" gflags_unittest --tryfromenv=help) -add_gflags_test(fromenv=helpfull 1 "helpfull not found in environment" "" gflags_unittest --fromenv=helpfull) -add_gflags_test(tryfromenv=helpfull 0 "PASS" "" gflags_unittest --tryfromenv=helpfull) -add_gflags_test(tryfromenv=undefok 0 "PASS" "" gflags_unittest --tryfromenv=undefok --foo) -add_gflags_test(tryfromenv=weirdo 1 "unknown command line flag" "" gflags_unittest --tryfromenv=weirdo) -add_gflags_test(tryfromenv-multiple 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --tryfromenv=test_bool,version,unused_bool) -add_gflags_test(fromenv=test_bool 1 "not found in environment" "" gflags_unittest --fromenv=test_bool) -add_gflags_test(fromenv=test_bool-ok 1 "unknown command line flag" "" gflags_unittest --fromenv=test_bool,ok) -# Here, the --version overrides the fromenv -add_gflags_test(version-overrides-fromenv 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --fromenv=test_bool,version,ok) - -# Make sure -- by itself stops argv processing -add_gflags_test(dashdash 0 "PASS" "" gflags_unittest -- --help) - -# And we should die if the flag value doesn't pass the validator -add_gflags_test(always_fail 1 "ERROR: failed validation of new value 'true' for flag 'always_fail'" "" gflags_unittest --always_fail) - -# And if locking in validators fails -# TODO(andreas): Worked on Windows 7 Release configuration, but causes -# debugger abort() intervention in case of Debug configuration. -#add_gflags_test(deadlock_if_cant_lock 0 "PASS" "" gflags_unittest --deadlock_if_cant_lock) - -# ---------------------------------------------------------------------------- -# use gflags_declare.h -add_executable (gflags_declare_test gflags_declare_test.cc gflags_declare_flags.cc) - -add_test(NAME gflags_declare COMMAND gflags_declare_test --message "Hello gflags!") -set_tests_properties(gflags_declare PROPERTIES PASS_REGULAR_EXPRESSION "Hello gflags!") - -# ---------------------------------------------------------------------------- -# (negative) compilation tests -if (BUILD_NC_TESTS) - find_package (PythonInterp) - if (NOT PYTHON_EXECUTABLE) - message (FATAL_ERROR "No Python installation found! It is required by the negative compilation tests." - " Either install Python or set BUILD_NC_TESTS to FALSE and try again.") - endif () - set (SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/nc") - configure_file (gflags_nc.py.in "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/nc.py" @ONLY) - macro (add_gflags_nc_test name) - add_test ( - NAME nc_${name} - COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/nc.py" ${name} - ) - endmacro () - add_gflags_nc_test (sanity) - add_gflags_nc_test (swapped_args) - add_gflags_nc_test (int_instead_of_bool) - add_gflags_nc_test (bool_in_quotes) - add_gflags_nc_test (define_string_with_0) -endif () http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/test/config_for_unittests.h ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/config_for_unittests.h b/third_party/src/tmb/third_party/gflags/test/config_for_unittests.h deleted file mode 100644 index 914571b..0000000 --- a/third_party/src/tmb/third_party/gflags/test/config_for_unittests.h +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2007, 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. - -// --- -// All Rights Reserved. -// -// -// This file is needed for windows -- unittests are not part of the -// gflags dll, but still want to include config.h just like the -// dll does, so they can use internal tools and APIs for testing. -// -// The problem is that config.h declares GFLAGS_DLL_DECL to be -// for exporting symbols, but the unittest needs to *import* symbols -// (since it's not the dll). -// -// The solution is to have this file, which is just like config.h but -// sets GFLAGS_DLL_DECL to do a dllimport instead of a dllexport. -// -// The reason we need this extra GFLAGS_DLL_DECL_FOR_UNITTESTS -// variable is in case people want to set GFLAGS_DLL_DECL explicitly -// to something other than __declspec(dllexport). In that case, they -// may want to use something other than __declspec(dllimport) for the -// unittest case. For that, we allow folks to define both -// GFLAGS_DLL_DECL and GFLAGS_DLL_DECL_FOR_UNITTESTS explicitly. -// -// NOTE: This file is equivalent to config.h on non-windows systems, -// which never defined GFLAGS_DLL_DECL_FOR_UNITTESTS and always -// define GFLAGS_DLL_DECL to the empty string. - -#include "config.h" - -#ifdef GFLAGS_DLL_DECL -# undef GFLAGS_DLL_DECL -#endif -#ifdef GFLAGS_DLL_DEFINE_FLAG -# undef GFLAGS_DLL_DEFINE_FLAG -#endif -#ifdef GFLAGS_DLL_DECLARE_FLAG -# undef GFLAGS_DLL_DECLARE_FLAG -#endif - -#ifdef GFLAGS_DLL_DECL_FOR_UNITTESTS -# define GFLAGS_DLL_DECL GFLAGS_DLL_DECL_FOR_UNITTESTS -#else -# define GFLAGS_DLL_DECL // if DLL_DECL_FOR_UNITTESTS isn't defined, use "" -#endif - -// Import flags defined by gflags.cc -#if GFLAGS_IS_A_DLL && defined(_MSC_VER) -# define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport) -#else -# define GFLAGS_DLL_DECLARE_FLAG -#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/test/flagfile.1 ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/flagfile.1 b/third_party/src/tmb/third_party/gflags/test/flagfile.1 deleted file mode 100644 index e0f9217..0000000 --- a/third_party/src/tmb/third_party/gflags/test/flagfile.1 +++ /dev/null @@ -1 +0,0 @@ ---version \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/test/flagfile.2 ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/flagfile.2 b/third_party/src/tmb/third_party/gflags/test/flagfile.2 deleted file mode 100644 index 864f8e8..0000000 --- a/third_party/src/tmb/third_party/gflags/test/flagfile.2 +++ /dev/null @@ -1,2 +0,0 @@ ---foo=bar ---nounused_bool \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/test/flagfile.3 ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/flagfile.3 b/third_party/src/tmb/third_party/gflags/test/flagfile.3 deleted file mode 100644 index 76d92bb..0000000 --- a/third_party/src/tmb/third_party/gflags/test/flagfile.3 +++ /dev/null @@ -1 +0,0 @@ ---flagfile=flagfile.2 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/test/gflags_declare_flags.cc ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/gflags_declare_flags.cc b/third_party/src/tmb/third_party/gflags/test/gflags_declare_flags.cc deleted file mode 100644 index dc53de5..0000000 --- a/third_party/src/tmb/third_party/gflags/test/gflags_declare_flags.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include <iostream> -#include <gflags/gflags_declare.h> - -DECLARE_string(message); // in gflags_delcare_test.cc - -void print_message() -{ - std::cout << FLAGS_message << std::endl; -} http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/test/gflags_declare_test.cc ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/gflags_declare_test.cc b/third_party/src/tmb/third_party/gflags/test/gflags_declare_test.cc deleted file mode 100644 index 707bcc0..0000000 --- a/third_party/src/tmb/third_party/gflags/test/gflags_declare_test.cc +++ /dev/null @@ -1,12 +0,0 @@ -#include <gflags/gflags.h> - -DEFINE_string(message, "", "The message to print"); -void print_message(); // in gflags_declare_flags.cc - -int main(int argc, char **argv) -{ - gflags::SetUsageMessage("Test compilation and use of gflags_declare.h"); - gflags::ParseCommandLineFlags(&argc, &argv, true); - print_message(); - return 0; -} http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/test/gflags_nc.py.in ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/gflags_nc.py.in b/third_party/src/tmb/third_party/gflags/test/gflags_nc.py.in deleted file mode 100644 index 7636782..0000000 --- a/third_party/src/tmb/third_party/gflags/test/gflags_nc.py.in +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -import subprocess -import shutil - -CMAKE = '@CMAKE_COMMAND@' -TMPDIR = '@TEMPDIR@' -SRCDIR = '@SRCDIR@' -GFLAGS_DIR = '@gflags_BINARY_DIR@' - -if __name__ == "__main__": - if len(sys.argv) != 2: - sys.stderr.write(' '.join(['usage:', sys.argv[0], '<test_name>\n'])) - sys.exit(1) - test_name = sys.argv[1] - bindir = os.path.join(TMPDIR, '_'.join(['nc', test_name])) - if TMPDIR == '': - sys.stderr.write('Temporary directory not set!\n') - sys.exit(1) - # create build directory - if os.path.isdir(bindir): shutil.rmtree(bindir) - os.makedirs(bindir) - # configure the build tree - if subprocess.call([CMAKE, '-Dgflags_DIR:PATH='+GFLAGS_DIR, '-DTEST_NAME:STRING='+test_name, SRCDIR], cwd=bindir) != 0: - sys.stderr.write('Failed to configure the build tree!\n') - sys.exit(1) - # try build, which is supposed to fail (except in case of the sanity check) - if subprocess.call([CMAKE, '--build', bindir], cwd=bindir) == 0 and test_name != 'sanity': - sys.stderr.write('Build expected to fail, but it succeeded!\n') - sys.exit(1) - sys.exit(0) http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/test/gflags_strip_flags_test.cc ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/gflags_strip_flags_test.cc b/third_party/src/tmb/third_party/gflags/test/gflags_strip_flags_test.cc deleted file mode 100644 index 25ef53a..0000000 --- a/third_party/src/tmb/third_party/gflags/test/gflags_strip_flags_test.cc +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2011, 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. -// -// --- -// Author: csilv...@google.com (Craig Silverstein) -// -// A simple program that uses STRIP_FLAG_HELP. We'll have a shell -// script that runs 'strings' over this program and makes sure -// that the help string is not in there. - -#include "config_for_unittests.h" -#define STRIP_FLAG_HELP 1 -#include <gflags/gflags.h> - -#include <stdio.h> - -using GFLAGS_NAMESPACE::SetUsageMessage; -using GFLAGS_NAMESPACE::ParseCommandLineFlags; - - -DEFINE_bool(test, true, "This text should be stripped out"); - -int main(int argc, char** argv) { - SetUsageMessage("Usage message"); - ParseCommandLineFlags(&argc, &argv, false); - - // Unfortunately, for us, libtool can replace executables with a shell - // script that does some work before calling the 'real' executable - // under a different name. We need the 'real' executable name to run - // 'strings' on it, so we construct this binary to print the real - // name (argv[0]) on stdout when run. - puts(argv[0]); - - return 0; -} http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5454337/third_party/src/tmb/third_party/gflags/test/gflags_strip_flags_test.cmake ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/gflags_strip_flags_test.cmake b/third_party/src/tmb/third_party/gflags/test/gflags_strip_flags_test.cmake deleted file mode 100644 index bd419c4..0000000 --- a/third_party/src/tmb/third_party/gflags/test/gflags_strip_flags_test.cmake +++ /dev/null @@ -1,7 +0,0 @@ -if (NOT BINARY) - message (FATAl_ERROR "BINARY file to check not specified!") -endif () -file (STRINGS "${BINARY}" strings REGEX "This text should be stripped out") -if (strings) - message (FATAL_ERROR "Text not stripped from binary like it should be: ${BINARY}") -endif () \ No newline at end of file