quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbdeshm...@apache.org
Subject [11/51] [partial] incubator-quickstep git commit: Added shell script to download prerequisite third party libs
Date Tue, 17 Jan 2017 19:31:05 GMT
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bb3371c3/third_party/gperftools/src/profile-handler.cc
----------------------------------------------------------------------
diff --git a/third_party/gperftools/src/profile-handler.cc b/third_party/gperftools/src/profile-handler.cc
deleted file mode 100644
index 1518ed4..0000000
--- a/third_party/gperftools/src/profile-handler.cc
+++ /dev/null
@@ -1,685 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
-// 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: Sanjay Ghemawat
-//         Nabeel Mian
-//
-// Implements management of profile timers and the corresponding signal handler.
-
-#include "config.h"
-#include "profile-handler.h"
-
-#if !(defined(__CYGWIN__) || defined(__CYGWIN32__))
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/time.h>
-
-#include <list>
-#include <string>
-
-#if HAVE_LINUX_SIGEV_THREAD_ID
-// for timer_{create,settime} and associated typedefs & constants
-#include <time.h>
-// for sys_gettid
-#include "base/linux_syscall_support.h"
-// for perftools_pthread_key_create
-#include "maybe_threads.h"
-#endif
-
-#include "base/dynamic_annotations.h"
-#include "base/googleinit.h"
-#include "base/logging.h"
-#include "base/spinlock.h"
-#include "maybe_threads.h"
-
-using std::list;
-using std::string;
-
-// This structure is used by ProfileHandlerRegisterCallback and
-// ProfileHandlerUnregisterCallback as a handle to a registered callback.
-struct ProfileHandlerToken {
-  // Sets the callback and associated arg.
-  ProfileHandlerToken(ProfileHandlerCallback cb, void* cb_arg)
-      : callback(cb),
-        callback_arg(cb_arg) {
-  }
-
-  // Callback function to be invoked on receiving a profile timer interrupt.
-  ProfileHandlerCallback callback;
-  // Argument for the callback function.
-  void* callback_arg;
-};
-
-// This class manages profile timers and associated signal handler. This is a
-// a singleton.
-class ProfileHandler {
- public:
-  // Registers the current thread with the profile handler. On systems which
-  // have a separate interval timer for each thread, this function starts the
-  // timer for the current thread.
-  //
-  // The function also attempts to determine whether or not timers are shared by
-  // all threads in the process.  (With LinuxThreads, and with NPTL on some
-  // Linux kernel versions, each thread has separate timers.)
-  //
-  // Prior to determining whether timers are shared, this function will
-  // unconditionally start the timer.  However, if this function determines
-  // that timers are shared, then it will stop the timer if no callbacks are
-  // currently registered.
-  void RegisterThread();
-
-  // Registers a callback routine to receive profile timer ticks. The returned
-  // token is to be used when unregistering this callback and must not be
-  // deleted by the caller. Registration of the first callback enables the
-  // SIGPROF handler (or SIGALRM if using ITIMER_REAL).
-  ProfileHandlerToken* RegisterCallback(ProfileHandlerCallback callback,
-                                        void* callback_arg);
-
-  // Unregisters a previously registered callback. Expects the token returned
-  // by the corresponding RegisterCallback routine. Unregistering the last
-  // callback disables the SIGPROF handler (or SIGALRM if using ITIMER_REAL).
-  void UnregisterCallback(ProfileHandlerToken* token)
-      NO_THREAD_SAFETY_ANALYSIS;
-
-  // Unregisters all the callbacks, stops the timer if shared, disables the
-  // SIGPROF (or SIGALRM) handler and clears the timer_sharing_ state.
-  void Reset();
-
-  // Gets the current state of profile handler.
-  void GetState(ProfileHandlerState* state);
-
-  // Initializes and returns the ProfileHandler singleton.
-  static ProfileHandler* Instance();
-
- private:
-  ProfileHandler();
-  ~ProfileHandler();
-
-  // Largest allowed frequency.
-  static const int32 kMaxFrequency = 4000;
-  // Default frequency.
-  static const int32 kDefaultFrequency = 100;
-
-  // ProfileHandler singleton.
-  static ProfileHandler* instance_;
-
-  // pthread_once_t for one time initialization of ProfileHandler singleton.
-  static pthread_once_t once_;
-
-  // Initializes the ProfileHandler singleton via GoogleOnceInit.
-  static void Init();
-
-  // The number of SIGPROF (or SIGALRM for ITIMER_REAL) interrupts received.
-  int64 interrupts_ GUARDED_BY(signal_lock_);
-
-  // SIGPROF/SIGALRM interrupt frequency, read-only after construction.
-  int32 frequency_;
-
-  // ITIMER_PROF (which uses SIGPROF), or ITIMER_REAL (which uses SIGALRM)
-  int timer_type_;
-
-  // Counts the number of callbacks registered.
-  int32 callback_count_ GUARDED_BY(control_lock_);
-
-  // Is profiling allowed at all?
-  bool allowed_;
-
-  bool per_thread_timer_enabled_;
-
-#ifdef HAVE_LINUX_SIGEV_THREAD_ID
-  // this is used to destroy per-thread profiling timers on thread
-  // termination
-  pthread_key_t thread_timer_key;
-#endif
-
-  // Whether or not the threading system provides interval timers that are
-  // shared by all threads in a process.
-  enum {
-    // No timer initialization attempted yet.
-    TIMERS_UNTOUCHED,
-    // First thread has registered and set timer.
-    TIMERS_ONE_SET,
-    // Timers are shared by all threads.
-    TIMERS_SHARED,
-    // Timers are separate in each thread.
-    TIMERS_SEPARATE
-  } timer_sharing_ GUARDED_BY(control_lock_);
-
-  // This lock serializes the registration of threads and protects the
-  // callbacks_ list below.
-  // Locking order:
-  // In the context of a signal handler, acquire signal_lock_ to walk the
-  // callback list. Otherwise, acquire control_lock_, disable the signal
-  // handler and then acquire signal_lock_.
-  SpinLock control_lock_ ACQUIRED_BEFORE(signal_lock_);
-  SpinLock signal_lock_;
-
-  // Holds the list of registered callbacks. We expect the list to be pretty
-  // small. Currently, the cpu profiler (base/profiler) and thread module
-  // (base/thread.h) are the only two components registering callbacks.
-  // Following are the locking requirements for callbacks_:
-  // For read-write access outside the SIGPROF handler:
-  //  - Acquire control_lock_
-  //  - Disable SIGPROF handler.
-  //  - Acquire signal_lock_
-  // For read-only access in the context of SIGPROF handler
-  // (Read-write access is *not allowed* in the SIGPROF handler)
-  //  - Acquire signal_lock_
-  // For read-only access outside SIGPROF handler:
-  //  - Acquire control_lock_
-  typedef list<ProfileHandlerToken*> CallbackList;
-  typedef CallbackList::iterator CallbackIterator;
-  CallbackList callbacks_ GUARDED_BY(signal_lock_);
-
-  // Starts the interval timer.  If the thread library shares timers between
-  // threads, this function starts the shared timer. Otherwise, this will start
-  // the timer in the current thread.
-  void StartTimer() EXCLUSIVE_LOCKS_REQUIRED(control_lock_);
-
-  // Stops the interval timer. If the thread library shares timers between
-  // threads, this fucntion stops the shared timer. Otherwise, this will stop
-  // the timer in the current thread.
-  void StopTimer() EXCLUSIVE_LOCKS_REQUIRED(control_lock_);
-
-  // Returns true if the profile interval timer is enabled in the current
-  // thread.  This actually checks the kernel's interval timer setting.  (It is
-  // used to detect whether timers are shared or separate.)
-  bool IsTimerRunning() EXCLUSIVE_LOCKS_REQUIRED(control_lock_);
-
-  // Sets the timer interrupt signal handler.
-  void EnableHandler() EXCLUSIVE_LOCKS_REQUIRED(control_lock_);
-
-  // Disables (ignores) the timer interrupt signal.
-  void DisableHandler() EXCLUSIVE_LOCKS_REQUIRED(control_lock_);
-
-  // Returns true if the handler is not being used by something else.
-  // This checks the kernel's signal handler table.
-  bool IsSignalHandlerAvailable();
-
-  // SIGPROF/SIGALRM handler. Iterate over and call all the registered callbacks.
-  static void SignalHandler(int sig, siginfo_t* sinfo, void* ucontext);
-
-  DISALLOW_COPY_AND_ASSIGN(ProfileHandler);
-};
-
-ProfileHandler* ProfileHandler::instance_ = NULL;
-pthread_once_t ProfileHandler::once_ = PTHREAD_ONCE_INIT;
-
-const int32 ProfileHandler::kMaxFrequency;
-const int32 ProfileHandler::kDefaultFrequency;
-
-// If we are LD_PRELOAD-ed against a non-pthreads app, then
-// pthread_once won't be defined.  We declare it here, for that
-// case (with weak linkage) which will cause the non-definition to
-// resolve to NULL.  We can then check for NULL or not in Instance.
-extern "C" int pthread_once(pthread_once_t *, void (*)(void))
-    ATTRIBUTE_WEAK;
-
-#if HAVE_LINUX_SIGEV_THREAD_ID
-
-// We use weak alias to timer_create to avoid runtime dependency on
-// -lrt and in turn -lpthread.
-//
-// At runtime we detect if timer_create is available and if so we
-// can enable linux-sigev-thread mode of profiling
-extern "C" {
-  int timer_create(clockid_t clockid, struct sigevent *evp,
-                            timer_t *timerid)
-    ATTRIBUTE_WEAK;
-  int timer_delete(timer_t timerid)
-    ATTRIBUTE_WEAK;
-  int timer_settime(timer_t timerid, int flags,
-                    const struct itimerspec *value,
-                    struct itimerspec *ovalue)
-    ATTRIBUTE_WEAK;
-}
-
-struct timer_id_holder {
-  timer_t timerid;
-  timer_id_holder(timer_t _timerid) : timerid(_timerid) {}
-};
-
-extern "C" {
-  static void ThreadTimerDestructor(void *arg) {
-    if (!arg) {
-      return;
-    }
-    timer_id_holder *holder = static_cast<timer_id_holder *>(arg);
-    timer_delete(holder->timerid);
-    delete holder;
-  }
-}
-
-static void CreateThreadTimerKey(pthread_key_t *pkey) {
-  int rv = perftools_pthread_key_create(pkey, ThreadTimerDestructor);
-  if (rv) {
-    RAW_LOG(FATAL, "aborting due to pthread_key_create error: %s", strerror(rv));
-  }
-}
-
-static void StartLinuxThreadTimer(int timer_type, int32 frequency, pthread_key_t timer_key) {
-  int rv;
-  struct sigevent sevp;
-  timer_t timerid;
-  struct itimerspec its;
-  memset(&sevp, 0, sizeof(sevp));
-  sevp.sigev_notify = SIGEV_THREAD_ID;
-  sevp._sigev_un._tid = sys_gettid();
-  const int signal_number = (timer_type == ITIMER_PROF ? SIGPROF : SIGALRM);
-  sevp.sigev_signo = signal_number;
-  clockid_t clock = CLOCK_THREAD_CPUTIME_ID;
-  if (timer_type == ITIMER_REAL) {
-    clock = CLOCK_MONOTONIC;
-  }
-  rv = timer_create(clock, &sevp, &timerid);
-  if (rv) {
-    RAW_LOG(FATAL, "aborting due to timer_create error: %s", strerror(errno));
-  }
-
-  timer_id_holder *holder = new timer_id_holder(timerid);
-  rv = perftools_pthread_setspecific(timer_key, holder);
-  if (rv) {
-    RAW_LOG(FATAL, "aborting due to pthread_setspecific error: %s", strerror(rv));
-  }
-
-  its.it_interval.tv_sec = 0;
-  its.it_interval.tv_nsec = 1000000000 / frequency;
-  its.it_value = its.it_interval;
-  rv = timer_settime(timerid, 0, &its, 0);
-  if (rv) {
-    RAW_LOG(FATAL, "aborting due to timer_settime error: %s", strerror(errno));
-  }
-}
-#endif
-
-void ProfileHandler::Init() {
-  instance_ = new ProfileHandler();
-}
-
-ProfileHandler* ProfileHandler::Instance() {
-  if (pthread_once) {
-    pthread_once(&once_, Init);
-  }
-  if (instance_ == NULL) {
-    // This will be true on systems that don't link in pthreads,
-    // including on FreeBSD where pthread_once has a non-zero address
-    // (but doesn't do anything) even when pthreads isn't linked in.
-    Init();
-    assert(instance_ != NULL);
-  }
-  return instance_;
-}
-
-ProfileHandler::ProfileHandler()
-    : interrupts_(0),
-      callback_count_(0),
-      allowed_(true),
-      per_thread_timer_enabled_(false),
-      timer_sharing_(TIMERS_UNTOUCHED) {
-  SpinLockHolder cl(&control_lock_);
-
-  timer_type_ = (getenv("CPUPROFILE_REALTIME") ? ITIMER_REAL : ITIMER_PROF);
-
-  // Get frequency of interrupts (if specified)
-  char junk;
-  const char* fr = getenv("CPUPROFILE_FREQUENCY");
-  if (fr != NULL && (sscanf(fr, "%u%c", &frequency_, &junk) == 1) &&
-      (frequency_ > 0)) {
-    // Limit to kMaxFrequency
-    frequency_ = (frequency_ > kMaxFrequency) ? kMaxFrequency : frequency_;
-  } else {
-    frequency_ = kDefaultFrequency;
-  }
-
-  if (!allowed_) {
-    return;
-  }
-
-  // If something else is using the signal handler,
-  // assume it has priority over us and stop.
-  if (!IsSignalHandlerAvailable()) {
-    RAW_LOG(INFO, "Disabling profiler because %s handler is already in use.",
-                    timer_type_ == ITIMER_REAL ? "SIGALRM" : "SIGPROF");
-    allowed_ = false;
-    return;
-  }
-
-  // Ignore signals until we decide to turn profiling on.  (Paranoia;
-  // should already be ignored.)
-  DisableHandler();
-
-#if HAVE_LINUX_SIGEV_THREAD_ID
-  if (getenv("CPUPROFILE_PER_THREAD_TIMERS")) {
-    if (timer_create && pthread_once) {
-      timer_sharing_ = TIMERS_SEPARATE;
-      CreateThreadTimerKey(&thread_timer_key);
-      per_thread_timer_enabled_ = true;
-    } else {
-      RAW_LOG(INFO,
-              "Not enabling linux-per-thread-timers mode due to lack of timer_create."
-              " Preload or link to librt.so for this to work");
-    }
-  }
-#endif
-}
-
-ProfileHandler::~ProfileHandler() {
-  Reset();
-#ifdef HAVE_LINUX_SIGEV_THREAD_ID
-  if (per_thread_timer_enabled_) {
-    perftools_pthread_key_delete(thread_timer_key);
-  }
-#endif
-}
-
-void ProfileHandler::RegisterThread() {
-  SpinLockHolder cl(&control_lock_);
-
-  if (!allowed_) {
-    return;
-  }
-
-  // We try to detect whether timers are being shared by setting a
-  // timer in the first call to this function, then checking whether
-  // it's set in the second call.
-  //
-  // Note that this detection method requires that the first two calls
-  // to RegisterThread must be made from different threads.  (Subsequent
-  // calls will see timer_sharing_ set to either TIMERS_SEPARATE or
-  // TIMERS_SHARED, and won't try to detect the timer sharing type.)
-  //
-  // Also note that if timer settings were inherited across new thread
-  // creation but *not* shared, this approach wouldn't work.  That's
-  // not an issue for any Linux threading implementation, and should
-  // not be a problem for a POSIX-compliant threads implementation.
-  switch (timer_sharing_) {
-    case TIMERS_UNTOUCHED:
-      StartTimer();
-      timer_sharing_ = TIMERS_ONE_SET;
-      break;
-    case TIMERS_ONE_SET:
-      // If the timer is running, that means that the main thread's
-      // timer setup is seen in this (second) thread -- and therefore
-      // that timers are shared.
-      if (IsTimerRunning()) {
-        timer_sharing_ = TIMERS_SHARED;
-        // If callback is already registered, we have to keep the timer
-        // running.  If not, we disable the timer here.
-        if (callback_count_ == 0) {
-          StopTimer();
-        }
-      } else {
-        timer_sharing_ = TIMERS_SEPARATE;
-        StartTimer();
-      }
-      break;
-    case TIMERS_SHARED:
-      // Nothing needed.
-      break;
-    case TIMERS_SEPARATE:
-      StartTimer();
-      break;
-  }
-}
-
-ProfileHandlerToken* ProfileHandler::RegisterCallback(
-    ProfileHandlerCallback callback, void* callback_arg) {
-
-  ProfileHandlerToken* token = new ProfileHandlerToken(callback, callback_arg);
-
-  SpinLockHolder cl(&control_lock_);
-  DisableHandler();
-  {
-    SpinLockHolder sl(&signal_lock_);
-    callbacks_.push_back(token);
-  }
-  // Start the timer if timer is shared and this is a first callback.
-  if ((callback_count_ == 0) && (timer_sharing_ == TIMERS_SHARED)) {
-    StartTimer();
-  }
-  ++callback_count_;
-  EnableHandler();
-  return token;
-}
-
-void ProfileHandler::UnregisterCallback(ProfileHandlerToken* token) {
-  SpinLockHolder cl(&control_lock_);
-  for (CallbackIterator it = callbacks_.begin(); it != callbacks_.end();
-       ++it) {
-    if ((*it) == token) {
-      RAW_CHECK(callback_count_ > 0, "Invalid callback count");
-      DisableHandler();
-      {
-        SpinLockHolder sl(&signal_lock_);
-        delete *it;
-        callbacks_.erase(it);
-      }
-      --callback_count_;
-      if (callback_count_ > 0) {
-        EnableHandler();
-      } else if (timer_sharing_ == TIMERS_SHARED) {
-        StopTimer();
-      }
-      return;
-    }
-  }
-  // Unknown token.
-  RAW_LOG(FATAL, "Invalid token");
-}
-
-void ProfileHandler::Reset() {
-  SpinLockHolder cl(&control_lock_);
-  DisableHandler();
-  {
-    SpinLockHolder sl(&signal_lock_);
-    CallbackIterator it = callbacks_.begin();
-    while (it != callbacks_.end()) {
-      CallbackIterator tmp = it;
-      ++it;
-      delete *tmp;
-      callbacks_.erase(tmp);
-    }
-  }
-  callback_count_ = 0;
-  if (timer_sharing_ == TIMERS_SHARED) {
-    StopTimer();
-  }
-  timer_sharing_ = TIMERS_UNTOUCHED;
-}
-
-void ProfileHandler::GetState(ProfileHandlerState* state) {
-  SpinLockHolder cl(&control_lock_);
-  DisableHandler();
-  {
-    SpinLockHolder sl(&signal_lock_);  // Protects interrupts_.
-    state->interrupts = interrupts_;
-  }
-  if (callback_count_ > 0) {
-    EnableHandler();
-  }
-  state->frequency = frequency_;
-  state->callback_count = callback_count_;
-  state->allowed = allowed_;
-}
-
-void ProfileHandler::StartTimer() {
-  if (!allowed_) {
-    return;
-  }
-
-#if HAVE_LINUX_SIGEV_THREAD_ID
-  if (per_thread_timer_enabled_) {
-    StartLinuxThreadTimer(timer_type_, frequency_, thread_timer_key);
-    return;
-  }
-#endif
-
-  struct itimerval timer;
-  timer.it_interval.tv_sec = 0;
-  timer.it_interval.tv_usec = 1000000 / frequency_;
-  timer.it_value = timer.it_interval;
-  setitimer(timer_type_, &timer, 0);
-}
-
-void ProfileHandler::StopTimer() {
-  if (!allowed_) {
-    return;
-  }
-  if (per_thread_timer_enabled_) {
-    RAW_LOG(FATAL, "StopTimer cannot be called in linux-per-thread-timers mode");
-  }
-
-  struct itimerval timer;
-  memset(&timer, 0, sizeof timer);
-  setitimer(timer_type_, &timer, 0);
-}
-
-bool ProfileHandler::IsTimerRunning() {
-  if (!allowed_) {
-    return false;
-  }
-  if (per_thread_timer_enabled_) {
-    return false;
-  }
-  struct itimerval current_timer;
-  RAW_CHECK(0 == getitimer(timer_type_, &current_timer), "getitimer");
-  return (current_timer.it_value.tv_sec != 0 ||
-          current_timer.it_value.tv_usec != 0);
-}
-
-void ProfileHandler::EnableHandler() {
-  if (!allowed_) {
-    return;
-  }
-  struct sigaction sa;
-  sa.sa_sigaction = SignalHandler;
-  sa.sa_flags = SA_RESTART | SA_SIGINFO;
-  sigemptyset(&sa.sa_mask);
-  const int signal_number = (timer_type_ == ITIMER_PROF ? SIGPROF : SIGALRM);
-  RAW_CHECK(sigaction(signal_number, &sa, NULL) == 0, "sigprof (enable)");
-}
-
-void ProfileHandler::DisableHandler() {
-  if (!allowed_) {
-    return;
-  }
-  struct sigaction sa;
-  sa.sa_handler = SIG_IGN;
-  sa.sa_flags = SA_RESTART;
-  sigemptyset(&sa.sa_mask);
-  const int signal_number = (timer_type_ == ITIMER_PROF ? SIGPROF : SIGALRM);
-  RAW_CHECK(sigaction(signal_number, &sa, NULL) == 0, "sigprof (disable)");
-}
-
-bool ProfileHandler::IsSignalHandlerAvailable() {
-  struct sigaction sa;
-  const int signal_number = (timer_type_ == ITIMER_PROF ? SIGPROF : SIGALRM);
-  RAW_CHECK(sigaction(signal_number, NULL, &sa) == 0, "is-signal-handler avail");
-
-  // We only take over the handler if the current one is unset.
-  // It must be SIG_IGN or SIG_DFL, not some other function.
-  // SIG_IGN must be allowed because when profiling is allowed but
-  // not actively in use, this code keeps the handler set to SIG_IGN.
-  // That setting will be inherited across fork+exec.  In order for
-  // any child to be able to use profiling, SIG_IGN must be treated
-  // as available.
-  return sa.sa_handler == SIG_IGN || sa.sa_handler == SIG_DFL;
-}
-
-void ProfileHandler::SignalHandler(int sig, siginfo_t* sinfo, void* ucontext) {
-  int saved_errno = errno;
-  // At this moment, instance_ must be initialized because the handler is
-  // enabled in RegisterThread or RegisterCallback only after
-  // ProfileHandler::Instance runs.
-  ProfileHandler* instance = ANNOTATE_UNPROTECTED_READ(instance_);
-  RAW_CHECK(instance != NULL, "ProfileHandler is not initialized");
-  {
-    SpinLockHolder sl(&instance->signal_lock_);
-    ++instance->interrupts_;
-    for (CallbackIterator it = instance->callbacks_.begin();
-         it != instance->callbacks_.end();
-         ++it) {
-      (*it)->callback(sig, sinfo, ucontext, (*it)->callback_arg);
-    }
-  }
-  errno = saved_errno;
-}
-
-// This module initializer registers the main thread, so it must be
-// executed in the context of the main thread.
-REGISTER_MODULE_INITIALIZER(profile_main, ProfileHandlerRegisterThread());
-
-extern "C" void ProfileHandlerRegisterThread() {
-  ProfileHandler::Instance()->RegisterThread();
-}
-
-extern "C" ProfileHandlerToken* ProfileHandlerRegisterCallback(
-    ProfileHandlerCallback callback, void* callback_arg) {
-  return ProfileHandler::Instance()->RegisterCallback(callback, callback_arg);
-}
-
-extern "C" void ProfileHandlerUnregisterCallback(ProfileHandlerToken* token) {
-  ProfileHandler::Instance()->UnregisterCallback(token);
-}
-
-extern "C" void ProfileHandlerReset() {
-  return ProfileHandler::Instance()->Reset();
-}
-
-extern "C" void ProfileHandlerGetState(ProfileHandlerState* state) {
-  ProfileHandler::Instance()->GetState(state);
-}
-
-#else  // OS_CYGWIN
-
-// ITIMER_PROF doesn't work under cygwin.  ITIMER_REAL is available, but doesn't
-// work as well for profiling, and also interferes with alarm().  Because of
-// these issues, unless a specific need is identified, profiler support is
-// disabled under Cygwin.
-extern "C" void ProfileHandlerRegisterThread() {
-}
-
-extern "C" ProfileHandlerToken* ProfileHandlerRegisterCallback(
-    ProfileHandlerCallback callback, void* callback_arg) {
-  return NULL;
-}
-
-extern "C" void ProfileHandlerUnregisterCallback(ProfileHandlerToken* token) {
-}
-
-extern "C" void ProfileHandlerReset() {
-}
-
-extern "C" void ProfileHandlerGetState(ProfileHandlerState* state) {
-}
-
-#endif  // OS_CYGWIN

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bb3371c3/third_party/gperftools/src/profile-handler.h
----------------------------------------------------------------------
diff --git a/third_party/gperftools/src/profile-handler.h b/third_party/gperftools/src/profile-handler.h
deleted file mode 100644
index 4f96a18..0000000
--- a/third_party/gperftools/src/profile-handler.h
+++ /dev/null
@@ -1,149 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
-/* 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: Nabeel Mian
- *
- * This module manages the cpu profile timers and the associated interrupt
- * handler. When enabled, all registered threads in the program are profiled.
- * (Note: if using linux 2.4 or earlier, you must use the Thread class, in
- * google3/thread, to ensure all threads are profiled.)
- *
- * Any component interested in receiving a profile timer interrupt can do so by
- * registering a callback. All registered callbacks must be async-signal-safe.
- *
- * Note: This module requires the sole ownership of ITIMER_PROF timer and the
- * SIGPROF signal.
- */
-
-#ifndef BASE_PROFILE_HANDLER_H_
-#define BASE_PROFILE_HANDLER_H_
-
-#include "config.h"
-#include <signal.h>
-#ifdef COMPILER_MSVC
-#include "conflict-signal.h"
-#endif
-#include "base/basictypes.h"
-
-/* All this code should be usable from within C apps. */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Forward declaration. */
-struct ProfileHandlerToken;
-
-/*
- * Callback function to be used with ProfilefHandlerRegisterCallback. This
- * function will be called in the context of SIGPROF signal handler and must
- * be async-signal-safe. The first three arguments are the values provided by
- * the SIGPROF signal handler. We use void* to avoid using ucontext_t on
- * non-POSIX systems.
- *
- * Requirements:
- * - Callback must be async-signal-safe.
- * - None of the functions in ProfileHandler are async-signal-safe. Therefore,
- *   callback function *must* not call any of the ProfileHandler functions.
- * - Callback is not required to be re-entrant. At most one instance of
- *   callback can run at a time.
- *
- * Notes:
- * - The SIGPROF signal handler saves and restores errno, so the callback
- *   doesn't need to.
- * - Callback code *must* not acquire lock(s) to serialize access to data shared
- *   with the code outside the signal handler (callback must be
- *   async-signal-safe). If such a serialization is needed, follow the model
- *   used by profiler.cc:
- *
- *   When code other than the signal handler modifies the shared data it must:
- *   - Acquire lock.
- *   - Unregister the callback with the ProfileHandler.
- *   - Modify shared data.
- *   - Re-register the callback.
- *   - Release lock.
- *   and the callback code gets a lockless, read-write access to the data.
- */
-typedef void (*ProfileHandlerCallback)(int sig, siginfo_t* sig_info,
-                                       void* ucontext, void* callback_arg);
-
-/*
- * Registers a new thread with profile handler and should be called only once
- * per thread. The main thread is registered at program startup. This routine
- * is called by the Thread module in google3/thread whenever a new thread is
- * created. This function is not async-signal-safe.
- */
-void ProfileHandlerRegisterThread();
-
-/*
- * Registers a callback routine. This callback function will be called in the
- * context of SIGPROF handler, so must be async-signal-safe. The returned token
- * is to be used when unregistering this callback via
- * ProfileHandlerUnregisterCallback. Registering the first callback enables
- * the SIGPROF signal handler. Caller must not free the returned token. This
- * function is not async-signal-safe.
- */
-ProfileHandlerToken* ProfileHandlerRegisterCallback(
-    ProfileHandlerCallback callback, void* callback_arg);
-
-/*
- * Unregisters a previously registered callback. Expects the token returned
- * by the corresponding ProfileHandlerRegisterCallback and asserts that the
- * passed token is valid. Unregistering the last callback disables the SIGPROF
- * signal handler. It waits for the currently running callback to
- * complete before returning. This function is not async-signal-safe.
- */
-void ProfileHandlerUnregisterCallback(ProfileHandlerToken* token);
-
-/*
- * FOR TESTING ONLY
- * Unregisters all the callbacks, stops the timers (if shared) and disables the
- * SIGPROF handler. All the threads, including the main thread, need to be
- * re-registered after this call. This function is not async-signal-safe.
- */
-void ProfileHandlerReset();
-
-/*
- * Stores profile handler's current state. This function is not
- * async-signal-safe.
- */
-struct ProfileHandlerState {
-  int32 frequency;  /* Profiling frequency */
-  int32 callback_count;  /* Number of callbacks registered */
-  int64 interrupts;  /* Number of interrupts received */
-  bool allowed; /* Profiling is allowed */
-};
-void ProfileHandlerGetState(struct ProfileHandlerState* state);
-
-#ifdef __cplusplus
-}  /* extern "C" */
-#endif
-
-#endif  /* BASE_PROFILE_HANDLER_H_ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bb3371c3/third_party/gperftools/src/profiledata.cc
----------------------------------------------------------------------
diff --git a/third_party/gperftools/src/profiledata.cc b/third_party/gperftools/src/profiledata.cc
deleted file mode 100644
index 8b05d3a..0000000
--- a/third_party/gperftools/src/profiledata.cc
+++ /dev/null
@@ -1,332 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
-// 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.
-//
-// ---
-// Author: Sanjay Ghemawat
-//         Chris Demetriou (refactoring)
-//
-// Collect profiling data.
-
-#include <config.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <sys/time.h>
-#include <string.h>
-#include <fcntl.h>
-
-#include "profiledata.h"
-
-#include "base/logging.h"
-#include "base/sysinfo.h"
-
-// All of these are initialized in profiledata.h.
-const int ProfileData::kMaxStackDepth;
-const int ProfileData::kAssociativity;
-const int ProfileData::kBuckets;
-const int ProfileData::kBufferLength;
-
-ProfileData::Options::Options()
-    : frequency_(1) {
-}
-
-// This function is safe to call from asynchronous signals (but is not
-// re-entrant).  However, that's not part of its public interface.
-void ProfileData::Evict(const Entry& entry) {
-  const int d = entry.depth;
-  const int nslots = d + 2;     // Number of slots needed in eviction buffer
-  if (num_evicted_ + nslots > kBufferLength) {
-    FlushEvicted();
-    assert(num_evicted_ == 0);
-    assert(nslots <= kBufferLength);
-  }
-  evict_[num_evicted_++] = entry.count;
-  evict_[num_evicted_++] = d;
-  memcpy(&evict_[num_evicted_], entry.stack, d * sizeof(Slot));
-  num_evicted_ += d;
-}
-
-ProfileData::ProfileData()
-    : hash_(0),
-      evict_(0),
-      num_evicted_(0),
-      out_(-1),
-      count_(0),
-      evictions_(0),
-      total_bytes_(0),
-      fname_(0),
-      start_time_(0) {
-}
-
-bool ProfileData::Start(const char* fname,
-                        const ProfileData::Options& options) {
-  if (enabled()) {
-    return false;
-  }
-
-  // Open output file and initialize various data structures
-  int fd = open(fname, O_CREAT | O_WRONLY | O_TRUNC, 0666);
-  if (fd < 0) {
-    // Can't open outfile for write
-    return false;
-  }
-
-  start_time_ = time(NULL);
-  fname_ = strdup(fname);
-
-  // Reset counters
-  num_evicted_ = 0;
-  count_       = 0;
-  evictions_   = 0;
-  total_bytes_ = 0;
-
-  hash_ = new Bucket[kBuckets];
-  evict_ = new Slot[kBufferLength];
-  memset(hash_, 0, sizeof(hash_[0]) * kBuckets);
-
-  // Record special entries
-  evict_[num_evicted_++] = 0;                     // count for header
-  evict_[num_evicted_++] = 3;                     // depth for header
-  evict_[num_evicted_++] = 0;                     // Version number
-  CHECK_NE(0, options.frequency());
-  int period = 1000000 / options.frequency();
-  evict_[num_evicted_++] = period;                // Period (microseconds)
-  evict_[num_evicted_++] = 0;                     // Padding
-
-  out_ = fd;
-
-  return true;
-}
-
-ProfileData::~ProfileData() {
-  Stop();
-}
-
-// Dump /proc/maps data to fd.  Copied from heap-profile-table.cc.
-#define NO_INTR(fn)  do {} while ((fn) < 0 && errno == EINTR)
-
-static void FDWrite(int fd, const char* buf, size_t len) {
-  while (len > 0) {
-    ssize_t r;
-    NO_INTR(r = write(fd, buf, len));
-    RAW_CHECK(r >= 0, "write failed");
-    buf += r;
-    len -= r;
-  }
-}
-
-static void DumpProcSelfMaps(int fd) {
-  ProcMapsIterator::Buffer iterbuf;
-  ProcMapsIterator it(0, &iterbuf);   // 0 means "current pid"
-
-  uint64 start, end, offset;
-  int64 inode;
-  char *flags, *filename;
-  ProcMapsIterator::Buffer linebuf;
-  while (it.Next(&start, &end, &flags, &offset, &inode, &filename)) {
-    int written = it.FormatLine(linebuf.buf_, sizeof(linebuf.buf_),
-                                start, end, flags, offset, inode, filename,
-                                0);
-    FDWrite(fd, linebuf.buf_, written);
-  }
-}
-
-void ProfileData::Stop() {
-  if (!enabled()) {
-    return;
-  }
-
-  // Move data from hash table to eviction buffer
-  for (int b = 0; b < kBuckets; b++) {
-    Bucket* bucket = &hash_[b];
-    for (int a = 0; a < kAssociativity; a++) {
-      if (bucket->entry[a].count > 0) {
-        Evict(bucket->entry[a]);
-      }
-    }
-  }
-
-  if (num_evicted_ + 3 > kBufferLength) {
-    // Ensure there is enough room for end of data marker
-    FlushEvicted();
-  }
-
-  // Write end of data marker
-  evict_[num_evicted_++] = 0;         // count
-  evict_[num_evicted_++] = 1;         // depth
-  evict_[num_evicted_++] = 0;         // end of data marker
-  FlushEvicted();
-
-  // Dump "/proc/self/maps" so we get list of mapped shared libraries
-  DumpProcSelfMaps(out_);
-
-  Reset();
-  fprintf(stderr, "PROFILE: interrupts/evictions/bytes = %d/%d/%" PRIuS "\n",
-          count_, evictions_, total_bytes_);
-}
-
-void ProfileData::Reset() {
-  if (!enabled()) {
-    return;
-  }
-
-  // Don't reset count_, evictions_, or total_bytes_ here.  They're used
-  // by Stop to print information about the profile after reset, and are
-  // cleared by Start when starting a new profile.
-  close(out_);
-  delete[] hash_;
-  hash_ = 0;
-  delete[] evict_;
-  evict_ = 0;
-  num_evicted_ = 0;
-  free(fname_);
-  fname_ = 0;
-  start_time_ = 0;
-
-  out_ = -1;
-}
-
-// This function is safe to call from asynchronous signals (but is not
-// re-entrant).  However, that's not part of its public interface.
-void ProfileData::GetCurrentState(State* state) const {
-  if (enabled()) {
-    state->enabled = true;
-    state->start_time = start_time_;
-    state->samples_gathered = count_;
-    int buf_size = sizeof(state->profile_name);
-    strncpy(state->profile_name, fname_, buf_size);
-    state->profile_name[buf_size-1] = '\0';
-  } else {
-    state->enabled = false;
-    state->start_time = 0;
-    state->samples_gathered = 0;
-    state->profile_name[0] = '\0';
-  }
-}
-
-// This function is safe to call from asynchronous signals (but is not
-// re-entrant).  However, that's not part of its public interface.
-void ProfileData::FlushTable() {
-  if (!enabled()) {
-    return;
-  }
-
-  // Move data from hash table to eviction buffer
-  for (int b = 0; b < kBuckets; b++) {
-    Bucket* bucket = &hash_[b];
-    for (int a = 0; a < kAssociativity; a++) {
-      if (bucket->entry[a].count > 0) {
-        Evict(bucket->entry[a]);
-        bucket->entry[a].depth = 0;
-        bucket->entry[a].count = 0;
-      }
-    }
-  }
-
-  // Write out all pending data
-  FlushEvicted();
-}
-
-void ProfileData::Add(int depth, const void* const* stack) {
-  if (!enabled()) {
-    return;
-  }
-
-  if (depth > kMaxStackDepth) depth = kMaxStackDepth;
-  RAW_CHECK(depth > 0, "ProfileData::Add depth <= 0");
-
-  // Make hash-value
-  Slot h = 0;
-  for (int i = 0; i < depth; i++) {
-    Slot slot = reinterpret_cast<Slot>(stack[i]);
-    h = (h << 8) | (h >> (8*(sizeof(h)-1)));
-    h += (slot * 31) + (slot * 7) + (slot * 3);
-  }
-
-  count_++;
-
-  // See if table already has an entry for this trace
-  bool done = false;
-  Bucket* bucket = &hash_[h % kBuckets];
-  for (int a = 0; a < kAssociativity; a++) {
-    Entry* e = &bucket->entry[a];
-    if (e->depth == depth) {
-      bool match = true;
-      for (int i = 0; i < depth; i++) {
-        if (e->stack[i] != reinterpret_cast<Slot>(stack[i])) {
-          match = false;
-          break;
-        }
-      }
-      if (match) {
-        e->count++;
-        done = true;
-        break;
-      }
-    }
-  }
-
-  if (!done) {
-    // Evict entry with smallest count
-    Entry* e = &bucket->entry[0];
-    for (int a = 1; a < kAssociativity; a++) {
-      if (bucket->entry[a].count < e->count) {
-        e = &bucket->entry[a];
-      }
-    }
-    if (e->count > 0) {
-      evictions_++;
-      Evict(*e);
-    }
-
-    // Use the newly evicted entry
-    e->depth = depth;
-    e->count = 1;
-    for (int i = 0; i < depth; i++) {
-      e->stack[i] = reinterpret_cast<Slot>(stack[i]);
-    }
-  }
-}
-
-// This function is safe to call from asynchronous signals (but is not
-// re-entrant).  However, that's not part of its public interface.
-void ProfileData::FlushEvicted() {
-  if (num_evicted_ > 0) {
-    const char* buf = reinterpret_cast<char*>(evict_);
-    size_t bytes = sizeof(evict_[0]) * num_evicted_;
-    total_bytes_ += bytes;
-    FDWrite(out_, buf, bytes);
-  }
-  num_evicted_ = 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bb3371c3/third_party/gperftools/src/profiledata.h
----------------------------------------------------------------------
diff --git a/third_party/gperftools/src/profiledata.h b/third_party/gperftools/src/profiledata.h
deleted file mode 100644
index 44033f0..0000000
--- a/third_party/gperftools/src/profiledata.h
+++ /dev/null
@@ -1,184 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
-// 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.
-//
-// ---
-// Author: Sanjay Ghemawat
-//         Chris Demetriou (refactoring)
-//
-// Collect profiling data.
-//
-// The profile data file format is documented in
-// doc/cpuprofile-fileformat.html
-
-
-#ifndef BASE_PROFILEDATA_H_
-#define BASE_PROFILEDATA_H_
-
-#include <config.h>
-#include <time.h>   // for time_t
-#include <stdint.h>
-#include "base/basictypes.h"
-
-// A class that accumulates profile samples and writes them to a file.
-//
-// Each sample contains a stack trace and a count.  Memory usage is
-// reduced by combining profile samples that have the same stack trace
-// by adding up the associated counts.
-//
-// Profile data is accumulated in a bounded amount of memory, and will
-// flushed to a file as necessary to stay within the memory limit.
-//
-// Use of this class assumes external synchronization.  The exact
-// requirements of that synchronization are that:
-//
-//  - 'Add' may be called from asynchronous signals, but is not
-//    re-entrant.
-//
-//  - None of 'Start', 'Stop', 'Reset', 'Flush', and 'Add' may be
-//    called at the same time.
-//
-//  - 'Start', 'Stop', or 'Reset' should not be called while 'Enabled'
-//     or 'GetCurrent' are running, and vice versa.
-//
-// A profiler which uses asyncronous signals to add samples will
-// typically use two locks to protect this data structure:
-//
-//  - A SpinLock which is held over all calls except for the 'Add'
-//    call made from the signal handler.
-//
-//  - A SpinLock which is held over calls to 'Start', 'Stop', 'Reset',
-//    'Flush', and 'Add'.  (This SpinLock should be acquired after
-//    the first SpinLock in all cases where both are needed.)
-class ProfileData {
- public:
-  struct State {
-    bool     enabled;             // Is profiling currently enabled?
-    time_t   start_time;          // If enabled, when was profiling started?
-    char     profile_name[1024];  // Name of file being written, or '\0'
-    int      samples_gathered;    // Number of samples gathered to far (or 0)
-  };
-
-  class Options {
-   public:
-    Options();
-
-    // Get and set the sample frequency.
-    int frequency() const {
-      return frequency_;
-    }
-    void set_frequency(int frequency) {
-      frequency_ = frequency;
-    }
-
-   private:
-    int      frequency_;                  // Sample frequency.
-  };
-
-  static const int kMaxStackDepth = 64;  // Max stack depth stored in profile
-
-  ProfileData();
-  ~ProfileData();
-
-  // If data collection is not already enabled start to collect data
-  // into fname.  Parameters related to this profiling run are specified
-  // by 'options'.
-  //
-  // Returns true if data collection could be started, otherwise (if an
-  // error occurred or if data collection was already enabled) returns
-  // false.
-  bool Start(const char *fname, const Options& options);
-
-  // If data collection is enabled, stop data collection and write the
-  // data to disk.
-  void Stop();
-
-  // Stop data collection without writing anything else to disk, and
-  // discard any collected data.
-  void Reset();
-
-  // If data collection is enabled, record a sample with 'depth'
-  // entries from 'stack'.  (depth must be > 0.)  At most
-  // kMaxStackDepth stack entries will be recorded, starting with
-  // stack[0].
-  //
-  // This function is safe to call from asynchronous signals (but is
-  // not re-entrant).
-  void Add(int depth, const void* const* stack);
-
-  // If data collection is enabled, write the data to disk (and leave
-  // the collector enabled).
-  void FlushTable();
-
-  // Is data collection currently enabled?
-  bool enabled() const { return out_ >= 0; }
-
-  // Get the current state of the data collector.
-  void GetCurrentState(State* state) const;
-
- private:
-  static const int kAssociativity = 4;          // For hashtable
-  static const int kBuckets = 1 << 10;          // For hashtable
-  static const int kBufferLength = 1 << 18;     // For eviction buffer
-
-  // Type of slots: each slot can be either a count, or a PC value
-  typedef uintptr_t Slot;
-
-  // Hash-table/eviction-buffer entry (a.k.a. a sample)
-  struct Entry {
-    Slot count;                  // Number of hits
-    Slot depth;                  // Stack depth
-    Slot stack[kMaxStackDepth];  // Stack contents
-  };
-
-  // Hash table bucket
-  struct Bucket {
-    Entry entry[kAssociativity];
-  };
-
-  Bucket*       hash_;          // hash table
-  Slot*         evict_;         // evicted entries
-  int           num_evicted_;   // how many evicted entries?
-  int           out_;           // fd for output file.
-  int           count_;         // How many samples recorded
-  int           evictions_;     // How many evictions
-  size_t        total_bytes_;   // How much output
-  char*         fname_;         // Profile file name
-  time_t        start_time_;    // Start time, or 0
-
-  // Move 'entry' to the eviction buffer.
-  void Evict(const Entry& entry);
-
-  // Write contents of eviction buffer to disk.
-  void FlushEvicted();
-
-  DISALLOW_COPY_AND_ASSIGN(ProfileData);
-};
-
-#endif  // BASE_PROFILEDATA_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bb3371c3/third_party/gperftools/src/profiler.cc
----------------------------------------------------------------------
diff --git a/third_party/gperftools/src/profiler.cc b/third_party/gperftools/src/profiler.cc
deleted file mode 100644
index b862ae6..0000000
--- a/third_party/gperftools/src/profiler.cc
+++ /dev/null
@@ -1,431 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
-// Copyright (c) 2005, 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: Sanjay Ghemawat
-//         Chris Demetriou (refactoring)
-//
-// Profile current program by sampling stack-trace every so often
-
-#include "config.h"
-#include "getpc.h"      // should be first to get the _GNU_SOURCE dfn
-#include <signal.h>
-#include <assert.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>  // for getpid()
-#endif
-#if defined(HAVE_SYS_UCONTEXT_H)
-#include <sys/ucontext.h>
-#elif defined(HAVE_UCONTEXT_H)
-#include <ucontext.h>
-#elif defined(HAVE_CYGWIN_SIGNAL_H)
-#include <cygwin/signal.h>
-typedef ucontext ucontext_t;
-#else
-typedef int ucontext_t;   // just to quiet the compiler, mostly
-#endif
-#include <sys/time.h>
-#include <string>
-#include <gperftools/profiler.h>
-#include <gperftools/stacktrace.h>
-#include "base/commandlineflags.h"
-#include "base/logging.h"
-#include "base/googleinit.h"
-#include "base/spinlock.h"
-#include "base/sysinfo.h"             /* for GetUniquePathFromEnv, etc */
-#include "profiledata.h"
-#include "profile-handler.h"
-#ifdef HAVE_CONFLICT_SIGNAL_H
-#include "conflict-signal.h"          /* used on msvc machines */
-#endif
-
-using std::string;
-
-DEFINE_bool(cpu_profiler_unittest,
-            EnvToBool("PERFTOOLS_UNITTEST", true),
-            "Determines whether or not we are running under the \
-             control of a unit test. This allows us to include or \
-			 exclude certain behaviours.");
-
-// Collects up all profile data. This is a singleton, which is
-// initialized by a constructor at startup. If no cpu profiler
-// signal is specified then the profiler lifecycle is either
-// manaully controlled via the API or attached to the scope of
-// the singleton (program scope). Otherwise the cpu toggle is
-// used to allow for user selectable control via signal generation.
-// This is very useful for profiling a daemon process without
-// having to start and stop the daemon or having to modify the
-// source code to use the cpu profiler API.
-class CpuProfiler {
- public:
-  CpuProfiler();
-  ~CpuProfiler();
-
-  // Start profiler to write profile info into fname
-  bool Start(const char* fname, const ProfilerOptions* options);
-
-  // Stop profiling and write the data to disk.
-  void Stop();
-
-  // Write the data to disk (and continue profiling).
-  void FlushTable();
-
-  bool Enabled();
-
-  void GetCurrentState(ProfilerState* state);
-
-  static CpuProfiler instance_;
-
- private:
-  // This lock implements the locking requirements described in the ProfileData
-  // documentation, specifically:
-  //
-  // lock_ is held all over all collector_ method calls except for the 'Add'
-  // call made from the signal handler, to protect against concurrent use of
-  // collector_'s control routines. Code other than signal handler must
-  // unregister the signal handler before calling any collector_ method.
-  // 'Add' method in the collector is protected by a guarantee from
-  // ProfileHandle that only one instance of prof_handler can run at a time.
-  SpinLock      lock_;
-  ProfileData   collector_;
-
-  // Filter function and its argument, if any.  (NULL means include all
-  // samples).  Set at start, read-only while running.  Written while holding
-  // lock_, read and executed in the context of SIGPROF interrupt.
-  int           (*filter_)(void*);
-  void*         filter_arg_;
-
-  // Opaque token returned by the profile handler. To be used when calling
-  // ProfileHandlerUnregisterCallback.
-  ProfileHandlerToken* prof_handler_token_;
-
-  // Sets up a callback to receive SIGPROF interrupt.
-  void EnableHandler();
-
-  // Disables receiving SIGPROF interrupt.
-  void DisableHandler();
-
-  // Signal handler that records the interrupted pc in the profile data.
-  static void prof_handler(int sig, siginfo_t*, void* signal_ucontext,
-                           void* cpu_profiler);
-};
-
-// Signal handler that is registered when a user selectable signal
-// number is defined in the environment variable CPUPROFILESIGNAL.
-static void CpuProfilerSwitch(int signal_number)
-{
-    bool static started = false;
-	static unsigned profile_count = 0;
-    static char base_profile_name[1024] = "\0";
-
-	if (base_profile_name[0] == '\0') {
-    	if (!GetUniquePathFromEnv("CPUPROFILE", base_profile_name)) {
-        	RAW_LOG(FATAL,"Cpu profiler switch is registered but no CPUPROFILE is defined");
-        	return;
-    	}
-	}
-    if (!started) 
-    {
-    	char full_profile_name[1024];
-
-		snprintf(full_profile_name, sizeof(full_profile_name), "%s.%u",
-                 base_profile_name, profile_count++);
-
-        if(!ProfilerStart(full_profile_name))
-        {
-            RAW_LOG(FATAL, "Can't turn on cpu profiling for '%s': %s\n",
-                    full_profile_name, strerror(errno));
-        }
-    }
-    else    
-    {
-        ProfilerStop();
-    }
-    started = !started;
-}
-
-// Profile data structure singleton: Constructor will check to see if
-// profiling should be enabled.  Destructor will write profile data
-// out to disk.
-CpuProfiler CpuProfiler::instance_;
-
-// Initialize profiling: activated if getenv("CPUPROFILE") exists.
-CpuProfiler::CpuProfiler()
-    : prof_handler_token_(NULL) {
-  // TODO(cgd) Move this code *out* of the CpuProfile constructor into a
-  // separate object responsible for initialization. With ProfileHandler there
-  // is no need to limit the number of profilers.
-  if (getenv("CPUPROFILE") == NULL) {
-    if (!FLAGS_cpu_profiler_unittest) {
-      RAW_LOG(WARNING, "CPU profiler linked but no valid CPUPROFILE environment variable found\n");
-    }
-    return;
-  }
-
-  // We don't enable profiling if setuid -- it's a security risk
-#ifdef HAVE_GETEUID
-  if (getuid() != geteuid()) {
-    if (!FLAGS_cpu_profiler_unittest) {
-      RAW_LOG(WARNING, "Cannot perform CPU profiling when running with setuid\n");
-    }
-    return;
-  }
-#endif
-
-  char *signal_number_str = getenv("CPUPROFILESIGNAL");
-  if (signal_number_str != NULL) {
-    long int signal_number = strtol(signal_number_str, NULL, 10);
-    if (signal_number >= 1 && signal_number <= 64) {
-      intptr_t old_signal_handler = reinterpret_cast<intptr_t>(signal(signal_number, CpuProfilerSwitch));
-      if (old_signal_handler == 0) {
-        RAW_LOG(INFO,"Using signal %d as cpu profiling switch", signal_number);
-      } else {
-        RAW_LOG(FATAL, "Signal %d already in use\n", signal_number);
-      }
-    } else {
-      RAW_LOG(FATAL, "Signal number %s is invalid\n", signal_number_str);
-    }
-  } else {
-    char fname[PATH_MAX];
-    if (!GetUniquePathFromEnv("CPUPROFILE", fname)) {
-      if (!FLAGS_cpu_profiler_unittest) {
-        RAW_LOG(WARNING, "CPU profiler linked but no valid CPUPROFILE environment variable found\n");
-      }
-      return;
-	}
-
-    if (!Start(fname, NULL)) {
-      RAW_LOG(FATAL, "Can't turn on cpu profiling for '%s': %s\n",
-              fname, strerror(errno));
-    }
-  }
-}
-
-bool CpuProfiler::Start(const char* fname, const ProfilerOptions* options) {
-  SpinLockHolder cl(&lock_);
-
-  if (collector_.enabled()) {
-    return false;
-  }
-
-  ProfileHandlerState prof_handler_state;
-  ProfileHandlerGetState(&prof_handler_state);
-
-  ProfileData::Options collector_options;
-  collector_options.set_frequency(prof_handler_state.frequency);
-  if (!collector_.Start(fname, collector_options)) {
-    return false;
-  }
-
-  filter_ = NULL;
-  if (options != NULL && options->filter_in_thread != NULL) {
-    filter_ = options->filter_in_thread;
-    filter_arg_ = options->filter_in_thread_arg;
-  }
-
-  // Setup handler for SIGPROF interrupts
-  EnableHandler();
-
-  return true;
-}
-
-CpuProfiler::~CpuProfiler() {
-  Stop();
-}
-
-// Stop profiling and write out any collected profile data
-void CpuProfiler::Stop() {
-  SpinLockHolder cl(&lock_);
-
-  if (!collector_.enabled()) {
-    return;
-  }
-
-  // Unregister prof_handler to stop receiving SIGPROF interrupts before
-  // stopping the collector.
-  DisableHandler();
-
-  // DisableHandler waits for the currently running callback to complete and
-  // guarantees no future invocations. It is safe to stop the collector.
-  collector_.Stop();
-}
-
-void CpuProfiler::FlushTable() {
-  SpinLockHolder cl(&lock_);
-
-  if (!collector_.enabled()) {
-    return;
-  }
-
-  // Unregister prof_handler to stop receiving SIGPROF interrupts before
-  // flushing the profile data.
-  DisableHandler();
-
-  // DisableHandler waits for the currently running callback to complete and
-  // guarantees no future invocations. It is safe to flush the profile data.
-  collector_.FlushTable();
-
-  EnableHandler();
-}
-
-bool CpuProfiler::Enabled() {
-  SpinLockHolder cl(&lock_);
-  return collector_.enabled();
-}
-
-void CpuProfiler::GetCurrentState(ProfilerState* state) {
-  ProfileData::State collector_state;
-  {
-    SpinLockHolder cl(&lock_);
-    collector_.GetCurrentState(&collector_state);
-  }
-
-  state->enabled = collector_state.enabled;
-  state->start_time = static_cast<time_t>(collector_state.start_time);
-  state->samples_gathered = collector_state.samples_gathered;
-  int buf_size = sizeof(state->profile_name);
-  strncpy(state->profile_name, collector_state.profile_name, buf_size);
-  state->profile_name[buf_size-1] = '\0';
-}
-
-void CpuProfiler::EnableHandler() {
-  RAW_CHECK(prof_handler_token_ == NULL, "SIGPROF handler already registered");
-  prof_handler_token_ = ProfileHandlerRegisterCallback(prof_handler, this);
-  RAW_CHECK(prof_handler_token_ != NULL, "Failed to set up SIGPROF handler");
-}
-
-void CpuProfiler::DisableHandler() {
-  RAW_CHECK(prof_handler_token_ != NULL, "SIGPROF handler is not registered");
-  ProfileHandlerUnregisterCallback(prof_handler_token_);
-  prof_handler_token_ = NULL;
-}
-
-// Signal handler that records the pc in the profile-data structure. We do no
-// synchronization here.  profile-handler.cc guarantees that at most one
-// instance of prof_handler() will run at a time. All other routines that
-// access the data touched by prof_handler() disable this signal handler before
-// accessing the data and therefore cannot execute concurrently with
-// prof_handler().
-void CpuProfiler::prof_handler(int sig, siginfo_t*, void* signal_ucontext,
-                               void* cpu_profiler) {
-  CpuProfiler* instance = static_cast<CpuProfiler*>(cpu_profiler);
-
-  if (instance->filter_ == NULL ||
-      (*instance->filter_)(instance->filter_arg_)) {
-    void* stack[ProfileData::kMaxStackDepth];
-
-    // Under frame-pointer-based unwinding at least on x86, the
-    // top-most active routine doesn't show up as a normal frame, but
-    // as the "pc" value in the signal handler context.
-    stack[0] = GetPC(*reinterpret_cast<ucontext_t*>(signal_ucontext));
-
-    // We skip the top three stack trace entries (this function,
-    // SignalHandler::SignalHandler and one signal handler frame)
-    // since they are artifacts of profiling and should not be
-    // measured.  Other profiling related frames may be removed by
-    // "pprof" at analysis time.  Instead of skipping the top frames,
-    // we could skip nothing, but that would increase the profile size
-    // unnecessarily.
-    int depth = GetStackTraceWithContext(stack + 1, arraysize(stack) - 1,
-                                         3, signal_ucontext);
-
-    void **used_stack;
-    if (stack[1] == stack[0]) {
-      // in case of non-frame-pointer-based unwinding we will get
-      // duplicate of PC in stack[1], which we don't want
-      used_stack = stack + 1;
-    } else {
-      used_stack = stack;
-      depth++;  // To account for pc value in stack[0];
-    }
-
-    instance->collector_.Add(depth, used_stack);
-  }
-}
-
-#if !(defined(__CYGWIN__) || defined(__CYGWIN32__))
-
-extern "C" PERFTOOLS_DLL_DECL void ProfilerRegisterThread() {
-  ProfileHandlerRegisterThread();
-}
-
-extern "C" PERFTOOLS_DLL_DECL void ProfilerFlush() {
-  CpuProfiler::instance_.FlushTable();
-}
-
-extern "C" PERFTOOLS_DLL_DECL int ProfilingIsEnabledForAllThreads() {
-  return CpuProfiler::instance_.Enabled();
-}
-
-extern "C" PERFTOOLS_DLL_DECL int ProfilerStart(const char* fname) {
-  return CpuProfiler::instance_.Start(fname, NULL);
-}
-
-extern "C" PERFTOOLS_DLL_DECL int ProfilerStartWithOptions(
-    const char *fname, const ProfilerOptions *options) {
-  return CpuProfiler::instance_.Start(fname, options);
-}
-
-extern "C" PERFTOOLS_DLL_DECL void ProfilerStop() {
-  CpuProfiler::instance_.Stop();
-}
-
-extern "C" PERFTOOLS_DLL_DECL void ProfilerGetCurrentState(
-    ProfilerState* state) {
-  CpuProfiler::instance_.GetCurrentState(state);
-}
-
-#else  // OS_CYGWIN
-
-// ITIMER_PROF doesn't work under cygwin.  ITIMER_REAL is available, but doesn't
-// work as well for profiling, and also interferes with alarm().  Because of
-// these issues, unless a specific need is identified, profiler support is
-// disabled under Cygwin.
-extern "C" void ProfilerRegisterThread() { }
-extern "C" void ProfilerFlush() { }
-extern "C" int ProfilingIsEnabledForAllThreads() { return 0; }
-extern "C" int ProfilerStart(const char* fname) { return 0; }
-extern "C" int ProfilerStartWithOptions(const char *fname,
-                                        const ProfilerOptions *options) {
-  return 0;
-}
-extern "C" void ProfilerStop() { }
-extern "C" void ProfilerGetCurrentState(ProfilerState* state) {
-  memset(state, 0, sizeof(*state));
-}
-
-#endif  // OS_CYGWIN
-
-// DEPRECATED routines
-extern "C" PERFTOOLS_DLL_DECL void ProfilerEnable() { }
-extern "C" PERFTOOLS_DLL_DECL void ProfilerDisable() { }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bb3371c3/third_party/gperftools/src/raw_printer.cc
----------------------------------------------------------------------
diff --git a/third_party/gperftools/src/raw_printer.cc b/third_party/gperftools/src/raw_printer.cc
deleted file mode 100644
index 3cf028e..0000000
--- a/third_party/gperftools/src/raw_printer.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
-// Copyright (c) 2008, 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: sanjay@google.com (Sanjay Ghemawat)
-
-#include <config.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include "raw_printer.h"
-#include "base/logging.h"
-
-namespace base {
-
-RawPrinter::RawPrinter(char* buf, int length)
-    : base_(buf),
-      ptr_(buf),
-      limit_(buf + length - 1) {
-  RAW_DCHECK(length > 0, "");
-  *ptr_ = '\0';
-  *limit_ = '\0';
-}
-
-void RawPrinter::Printf(const char* format, ...) {
-  if (limit_ > ptr_) {
-    va_list ap;
-    va_start(ap, format);
-    int avail = limit_ - ptr_;
-    // We pass avail+1 to vsnprintf() since that routine needs room
-    // to store the trailing \0.
-    const int r = perftools_vsnprintf(ptr_, avail+1, format, ap);
-    va_end(ap);
-    if (r < 0) {
-      // Perhaps an old glibc that returns -1 on truncation?
-      ptr_ = limit_;
-    } else if (r > avail) {
-      // Truncation
-      ptr_ = limit_;
-    } else {
-      ptr_ += r;
-    }
-  }
-}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bb3371c3/third_party/gperftools/src/raw_printer.h
----------------------------------------------------------------------
diff --git a/third_party/gperftools/src/raw_printer.h b/third_party/gperftools/src/raw_printer.h
deleted file mode 100644
index 9288bb5..0000000
--- a/third_party/gperftools/src/raw_printer.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
-// Copyright (c) 2008, 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: Sanjay Ghemawat
-//
-// A printf() wrapper that writes into a fixed length buffer.
-// Useful in low-level code that does not want to use allocating
-// routines like StringPrintf().
-//
-// The implementation currently uses vsnprintf().  This seems to
-// be fine for use in many low-level contexts, but we may need to
-// rethink this decision if we hit a problem with it calling
-// down into malloc() etc.
-
-#ifndef BASE_RAW_PRINTER_H_
-#define BASE_RAW_PRINTER_H_
-
-#include <config.h>
-#include "base/basictypes.h"
-
-namespace base {
-
-class RawPrinter {
- public:
-  // REQUIRES: "length > 0"
-  // Will printf any data added to this into "buf[0,length-1]" and
-  // will arrange to always keep buf[] null-terminated.
-  RawPrinter(char* buf, int length);
-
-  // Return the number of bytes that have been appended to the string
-  // so far.  Does not count any bytes that were dropped due to overflow.
-  int length() const { return (ptr_ - base_); }
-
-  // Return the number of bytes that can be added to this.
-  int space_left() const { return (limit_ - ptr_); }
-
-  // Format the supplied arguments according to the "format" string
-  // and append to this.  Will silently truncate the output if it does
-  // not fit.
-  void Printf(const char* format, ...)
-#ifdef HAVE___ATTRIBUTE__
-  __attribute__ ((__format__ (__printf__, 2, 3)))
-#endif
-;
-
- private:
-  // We can write into [ptr_ .. limit_-1].
-  // *limit_ is also writable, but reserved for a terminating \0
-  // in case we overflow.
-  //
-  // Invariants: *ptr_ == \0
-  // Invariants: *limit_ == \0
-  char* base_;          // Initial pointer
-  char* ptr_;           // Where should we write next
-  char* limit_;         // One past last non-\0 char we can write
-
-  DISALLOW_COPY_AND_ASSIGN(RawPrinter);
-};
-
-}
-
-#endif  // BASE_RAW_PRINTER_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bb3371c3/third_party/gperftools/src/sampler.cc
----------------------------------------------------------------------
diff --git a/third_party/gperftools/src/sampler.cc b/third_party/gperftools/src/sampler.cc
deleted file mode 100755
index cc71112..0000000
--- a/third_party/gperftools/src/sampler.cc
+++ /dev/null
@@ -1,131 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
-// Copyright (c) 2008, 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.
-//
-// Author: Daniel Ford
-
-#include "sampler.h"
-
-#include <algorithm>  // For min()
-#include <math.h>
-#include "base/commandlineflags.h"
-
-using std::min;
-
-// The approximate gap in bytes between sampling actions.
-// I.e., we take one sample approximately once every
-// tcmalloc_sample_parameter bytes of allocation
-// i.e. about once every 512KB if value is 1<<19.
-#ifdef NO_TCMALLOC_SAMPLES
-DEFINE_int64(tcmalloc_sample_parameter, 0,
-             "Unused: code is compiled with NO_TCMALLOC_SAMPLES");
-#else
-DEFINE_int64(tcmalloc_sample_parameter,
-             EnvToInt64("TCMALLOC_SAMPLE_PARAMETER", 0),
-             "The approximate gap in bytes between sampling actions. "
-             "This must be between 1 and 2^58.");
-#endif
-
-namespace tcmalloc {
-
-// Statics for Sampler
-double Sampler::log_table_[1<<kFastlogNumBits];
-
-// Populate the lookup table for FastLog2.
-// This approximates the log2 curve with a step function.
-// Steps have height equal to log2 of the mid-point of the step.
-void Sampler::PopulateFastLog2Table() {
-  for (int i = 0; i < (1<<kFastlogNumBits); i++) {
-    log_table_[i] = (log(1.0 + static_cast<double>(i+0.5)/(1<<kFastlogNumBits))
-                     / log(2.0));
-  }
-}
-
-int Sampler::GetSamplePeriod() {
-  return FLAGS_tcmalloc_sample_parameter;
-}
-
-// Run this before using your sampler
-void Sampler::Init(uint32_t seed) {
-  // Initialize PRNG
-  if (seed != 0) {
-    rnd_ = seed;
-  } else {
-    rnd_ = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(this));
-    if (rnd_ == 0) {
-      rnd_ = 1;
-    }
-  }
-  // Step it forward 20 times for good measure
-  for (int i = 0; i < 20; i++) {
-    rnd_ = NextRandom(rnd_);
-  }
-  // Initialize counter
-  bytes_until_sample_ = PickNextSamplingPoint();
-}
-
-// Initialize the Statics for the Sampler class
-void Sampler::InitStatics() {
-  PopulateFastLog2Table();
-}
-
-// Generates a geometric variable with the specified mean (512K by default).
-// This is done by generating a random number between 0 and 1 and applying
-// the inverse cumulative distribution function for an exponential.
-// Specifically: Let m be the inverse of the sample period, then
-// the probability distribution function is m*exp(-mx) so the CDF is
-// p = 1 - exp(-mx), so
-// q = 1 - p = exp(-mx)
-// log_e(q) = -mx
-// -log_e(q)/m = x
-// log_2(q) * (-log_e(2) * 1/m) = x
-// In the code, q is actually in the range 1 to 2**26, hence the -26 below
-size_t Sampler::PickNextSamplingPoint() {
-  rnd_ = NextRandom(rnd_);
-  // Take the top 26 bits as the random number
-  // (This plus the 1<<58 sampling bound give a max possible step of
-  // 5194297183973780480 bytes.)
-  const uint64_t prng_mod_power = 48;  // Number of bits in prng
-  // The uint32_t cast is to prevent a (hard-to-reproduce) NAN
-  // under piii debug for some binaries.
-  double q = static_cast<uint32_t>(rnd_ >> (prng_mod_power - 26)) + 1.0;
-  // Put the computed p-value through the CDF of a geometric.
-  // For faster performance (save ~1/20th exec time), replace
-  // min(0.0, FastLog2(q) - 26)  by  (Fastlog2(q) - 26.000705)
-  // The value 26.000705 is used rather than 26 to compensate
-  // for inaccuracies in FastLog2 which otherwise result in a
-  // negative answer.
-  return static_cast<size_t>(min(0.0, (FastLog2(q) - 26)) * (-log(2.0)
-                             * FLAGS_tcmalloc_sample_parameter) + 1);
-}
-
-}  // namespace tcmalloc

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bb3371c3/third_party/gperftools/src/sampler.h
----------------------------------------------------------------------
diff --git a/third_party/gperftools/src/sampler.h b/third_party/gperftools/src/sampler.h
deleted file mode 100755
index eb316d7..0000000
--- a/third_party/gperftools/src/sampler.h
+++ /dev/null
@@ -1,180 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
-// Copyright (c) 2008, 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.
-//
-// Author: Daniel Ford
-
-#ifndef TCMALLOC_SAMPLER_H_
-#define TCMALLOC_SAMPLER_H_
-
-#include "config.h"
-#include <stddef.h>                     // for size_t
-#ifdef HAVE_STDINT_H
-#include <stdint.h>                     // for uint64_t, uint32_t, int32_t
-#endif
-#include <string.h>                     // for memcpy
-#include "base/basictypes.h"  // for ASSERT
-#include "internal_logging.h"  // for ASSERT
-
-namespace tcmalloc {
-
-//-------------------------------------------------------------------
-// Sampler to decide when to create a sample trace for an allocation
-// Not thread safe: Each thread should have it's own sampler object.
-// Caller must use external synchronization if used
-// from multiple threads.
-//
-// With 512K average sample step (the default):
-//  the probability of sampling a 4K allocation is about 0.00778
-//  the probability of sampling a 1MB allocation is about 0.865
-//  the probability of sampling a 1GB allocation is about 1.00000
-// In general, the probablity of sampling is an allocation of size X
-// given a flag value of Y (default 1M) is:
-//  1 - e^(-X/Y)
-//
-// With 128K average sample step:
-//  the probability of sampling a 1MB allocation is about 0.99966
-//  the probability of sampling a 1GB allocation is about 1.0
-//  (about 1 - 2**(-26))
-// With 1M average sample step:
-//  the probability of sampling a 4K allocation is about 0.00390
-//  the probability of sampling a 1MB allocation is about 0.632
-//  the probability of sampling a 1GB allocation is about 1.0
-//
-// The sampler works by representing memory as a long stream from
-// which allocations are taken. Some of the bytes in this stream are
-// marked and if an allocation includes a marked byte then it is
-// sampled. Bytes are marked according to a Poisson point process
-// with each byte being marked independently with probability
-// p = 1/tcmalloc_sample_parameter.  This makes the probability
-// of sampling an allocation of X bytes equal to the CDF of
-// a geometric with mean tcmalloc_sample_parameter. (ie. the
-// probability that at least one byte in the range is marked). This
-// is accurately given by the CDF of the corresponding exponential
-// distribution : 1 - e^(X/tcmalloc_sample_parameter_)
-// Independence of the byte marking ensures independence of
-// the sampling of each allocation.
-//
-// This scheme is implemented by noting that, starting from any
-// fixed place, the number of bytes until the next marked byte
-// is geometrically distributed. This number is recorded as
-// bytes_until_sample_.  Every allocation subtracts from this
-// number until it is less than 0. When this happens the current
-// allocation is sampled.
-//
-// When an allocation occurs, bytes_until_sample_ is reset to
-// a new independtly sampled geometric number of bytes. The
-// memoryless property of the point process means that this may
-// be taken as the number of bytes after the end of the current
-// allocation until the next marked byte. This ensures that
-// very large allocations which would intersect many marked bytes
-// only result in a single call to PickNextSamplingPoint.
-//-------------------------------------------------------------------
-
-class PERFTOOLS_DLL_DECL Sampler {
- public:
-  // Initialize this sampler.
-  // Passing a seed of 0 gives a non-deterministic
-  // seed value given by casting the object ("this")
-  void Init(uint32_t seed);
-  void Cleanup();
-
-  // Record allocation of "k" bytes.  Return true iff allocation
-  // should be sampled
-  bool SampleAllocation(size_t k);
-
-  // Generate a geometric with mean 512K (or FLAG_tcmalloc_sample_parameter)
-  size_t PickNextSamplingPoint();
-
-  // Initialize the statics for the Sampler class
-  static void InitStatics();
-
-  // Returns the current sample period
-  int GetSamplePeriod();
-
-  // The following are public for the purposes of testing
-  static uint64_t NextRandom(uint64_t rnd_);  // Returns the next prng value
-  static double FastLog2(const double & d);  // Computes Log2(x) quickly
-  static void PopulateFastLog2Table();  // Populate the lookup table
-
- private:
-  size_t        bytes_until_sample_;    // Bytes until we sample next
-  uint64_t      rnd_;                   // Cheap random number generator
-
-  // Statics for the fast log
-  // Note that this code may not depend on anything in //util
-  // hence the duplication of functionality here
-  static const int kFastlogNumBits = 10;
-  static const int kFastlogMask = (1 << kFastlogNumBits) - 1;
-  static double log_table_[1<<kFastlogNumBits];  // Constant
-};
-
-inline bool Sampler::SampleAllocation(size_t k) {
-  if (bytes_until_sample_ < k) {
-    bytes_until_sample_ = PickNextSamplingPoint();
-    return true;
-  } else {
-    bytes_until_sample_ -= k;
-    return false;
-  }
-}
-
-// Inline functions which are public for testing purposes
-
-// Returns the next prng value.
-// pRNG is: aX+b mod c with a = 0x5DEECE66D, b =  0xB, c = 1<<48
-// This is the lrand64 generator.
-inline uint64_t Sampler::NextRandom(uint64_t rnd) {
-  const uint64_t prng_mult = 0x5DEECE66DLL;
-  const uint64_t prng_add = 0xB;
-  const uint64_t prng_mod_power = 48;
-  const uint64_t prng_mod_mask =
-                ~((~static_cast<uint64_t>(0)) << prng_mod_power);
-  return (prng_mult * rnd + prng_add) & prng_mod_mask;
-}
-
-// Adapted from //util/math/fastmath.[h|cc] by Noam Shazeer
-// This mimics the VeryFastLog2 code in those files
-inline double Sampler::FastLog2(const double & d) {
-  ASSERT(d>0);
-  COMPILE_ASSERT(sizeof(d) == sizeof(uint64_t), DoubleMustBe64Bits);
-  uint64_t x;
-  memcpy(&x, &d, sizeof(x));   // we depend on the compiler inlining this
-  const uint32_t x_high = x >> 32;
-  const uint32_t y = x_high >> (20 - kFastlogNumBits) & kFastlogMask;
-  const int32_t exponent = ((x_high >> 20) & 0x7FF) - 1023;
-  return exponent + log_table_[y];
-}
-
-}  // namespace tcmalloc
-
-#endif  // TCMALLOC_SAMPLER_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bb3371c3/third_party/gperftools/src/solaris/libstdc++.la
----------------------------------------------------------------------
diff --git a/third_party/gperftools/src/solaris/libstdc++.la b/third_party/gperftools/src/solaris/libstdc++.la
deleted file mode 100644
index 3edf425..0000000
--- a/third_party/gperftools/src/solaris/libstdc++.la
+++ /dev/null
@@ -1,51 +0,0 @@
-# libstdc++.la - a libtool library file
-# Generated by ltmain.sh - GNU libtool 1.4a-GCC3.0 (1.641.2.256 2001/05/28 20:09:07 with GCC-local changes)
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# ---
-# NOTE: This file lives in /usr/sfw/lib on Solaris 10.  Unfortunately,
-# due to an apparent bug in the Solaris 10 6/06 release,
-# /usr/sfw/lib/libstdc++.la is empty.  Below is the correct content,
-# according to
-#    http://forum.java.sun.com/thread.jspa?threadID=5073150
-# By passing LDFLAGS='-Lsrc/solaris' to configure, make will pick up
-# this copy of the file rather than the empty copy in /usr/sfw/lib.
-#
-# Also see
-#   http://www.technicalarticles.org/index.php/Compiling_MySQL_5.0_on_Solaris_10
-#
-# Note: this is for 32-bit systems.  If you have a 64-bit system,
-# uncomment the appropriate dependency_libs line below.
-# ----
-
-# The name that we can dlopen(3).
-dlname='libstdc++.so.6'
-
-# Names of this library.
-library_names='libstdc++.so.6.0.3 libstdc++.so.6 libstdc++.so'
-
-# The name of the static archive.
-old_library='libstdc++.a'
-
-# Libraries that this one depends upon.
-# 32-bit version:
-dependency_libs='-lc -lm -L/usr/sfw/lib -lgcc_s'
-# 64-bit version:
-#dependency_libs='-L/lib/64 -lc -lm -L/usr/sfw/lib/64 -lgcc_s'
-
-# Version information for libstdc++.
-current=6
-age=0
-revision=3
-
-# Is this an already installed library?
-installed=yes
-
-# Files to dlopen/dlpreopen
-dlopen=''
-dlpreopen=''
-
-# Directory that this library needs to be installed in:
-libdir='/usr/sfw/lib'

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bb3371c3/third_party/gperftools/src/span.cc
----------------------------------------------------------------------
diff --git a/third_party/gperftools/src/span.cc b/third_party/gperftools/src/span.cc
deleted file mode 100644
index 4d08964..0000000
--- a/third_party/gperftools/src/span.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
-// Copyright (c) 2008, 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: Sanjay Ghemawat <opensource@google.com>
-
-#include <config.h>
-#include "span.h"
-
-#include <string.h>                     // for NULL, memset
-
-#include "internal_logging.h"  // for ASSERT
-#include "page_heap_allocator.h"  // for PageHeapAllocator
-#include "static_vars.h"       // for Static
-
-namespace tcmalloc {
-
-#ifdef SPAN_HISTORY
-void Event(Span* span, char op, int v = 0) {
-  span->history[span->nexthistory] = op;
-  span->value[span->nexthistory] = v;
-  span->nexthistory++;
-  if (span->nexthistory == sizeof(span->history)) span->nexthistory = 0;
-}
-#endif
-
-Span* NewSpan(PageID p, Length len) {
-  Span* result = Static::span_allocator()->New();
-  memset(result, 0, sizeof(*result));
-  result->start = p;
-  result->length = len;
-#ifdef SPAN_HISTORY
-  result->nexthistory = 0;
-#endif
-  return result;
-}
-
-void DeleteSpan(Span* span) {
-#ifndef NDEBUG
-  // In debug mode, trash the contents of deleted Spans
-  memset(span, 0x3f, sizeof(*span));
-#endif
-  Static::span_allocator()->Delete(span);
-}
-
-void DLL_Init(Span* list) {
-  list->next = list;
-  list->prev = list;
-}
-
-void DLL_Remove(Span* span) {
-  span->prev->next = span->next;
-  span->next->prev = span->prev;
-  span->prev = NULL;
-  span->next = NULL;
-}
-
-int DLL_Length(const Span* list) {
-  int result = 0;
-  for (Span* s = list->next; s != list; s = s->next) {
-    result++;
-  }
-  return result;
-}
-
-void DLL_Prepend(Span* list, Span* span) {
-  ASSERT(span->next == NULL);
-  ASSERT(span->prev == NULL);
-  span->next = list->next;
-  span->prev = list;
-  list->next->prev = span;
-  list->next = span;
-}
-
-}  // namespace tcmalloc



Mime
View raw message