]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/commitdiff
Remove dead code. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 4 Dec 2014 16:59:36 +0000 (16:59 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 4 Dec 2014 16:59:36 +0000 (16:59 +0000)
This interface was added 2 years ago but users never developed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223368 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Process.h
lib/Support/MemoryBuffer.cpp
lib/Support/Process.cpp
lib/Support/Unix/Memory.inc
lib/Support/Unix/Path.inc
lib/Support/Unix/Process.inc
lib/Support/Windows/Process.inc
unittests/Support/MemoryTest.cpp
unittests/Support/ProcessTest.cpp

index 861667927d8a9bb8dc9587525c9f1b2625b8ad98..cfdd06c62f33eb6652cfe99dc5c6137c1d7028a3 100644 (file)
@@ -38,111 +38,13 @@ class StringRef;
 
 namespace sys {
 
-class self_process;
-
-/// \brief Generic base class which exposes information about an operating
-/// system process.
-///
-/// This base class is the core interface behind any OS process. It exposes
-/// methods to query for generic information about a particular process.
-///
-/// Subclasses implement this interface based on the mechanisms available, and
-/// can optionally expose more interfaces unique to certain process kinds.
-class process {
-protected:
-  /// \brief Only specific subclasses of process objects can be destroyed.
-  virtual ~process();
-
-public:
-  /// \brief Operating system specific type to identify a process.
-  ///
-  /// Note that the windows one is defined to 'unsigned long' as this is the
-  /// documented type for DWORD on windows, and we don't want to pull in the
-  /// Windows headers here.
-#if defined(LLVM_ON_UNIX)
-  typedef pid_t id_type;
-#elif defined(LLVM_ON_WIN32)
-  typedef unsigned long id_type; // Must match the type of DWORD.
-#else
-#error Unsupported operating system.
-#endif
-
-  /// \brief Get the operating system specific identifier for this process.
-  virtual id_type get_id() = 0;
-
-  /// \brief Get the user time consumed by this process.
-  ///
-  /// Note that this is often an approximation and may be zero on platforms
-  /// where we don't have good support for the functionality.
-  virtual TimeValue get_user_time() const = 0;
-
-  /// \brief Get the system time consumed by this process.
-  ///
-  /// Note that this is often an approximation and may be zero on platforms
-  /// where we don't have good support for the functionality.
-  virtual TimeValue get_system_time() const = 0;
-
-  /// \brief Get the wall time consumed by this process.
-  ///
-  /// Note that this is often an approximation and may be zero on platforms
-  /// where we don't have good support for the functionality.
-  virtual TimeValue get_wall_time() const = 0;
-
-  /// \name Static factory routines for processes.
-  /// @{
-
-  /// \brief Get the process object for the current process.
-  static self_process *get_self();
-
-  /// @}
-
-};
-
-/// \brief The specific class representing the current process.
-///
-/// The current process can both specialize the implementation of the routines
-/// and can expose certain information not available for other OS processes.
-class self_process : public process {
-  friend class process;
-
-  /// \brief Private destructor, as users shouldn't create objects of this
-  /// type.
-  virtual ~self_process();
-
-public:
-  id_type get_id() override;
-  TimeValue get_user_time() const override;
-  TimeValue get_system_time() const override;
-  TimeValue get_wall_time() const override;
-
-  /// \name Process configuration (sysconf on POSIX)
-  /// @{
-
-  /// \brief Get the virtual memory page size.
-  ///
-  /// Query the operating system for this process's page size.
-  size_t page_size() const { return PageSize; };
-
-  /// @}
-
-private:
-  /// \name Cached process state.
-  /// @{
-
-  /// \brief Cached page size, this cannot vary during the life of the process.
-  size_t PageSize;
-
-  /// @}
-
-  /// \brief Constructor, used by \c process::get_self() only.
-  self_process();
-};
-
 
 /// \brief A collection of legacy interfaces for querying information about the
 /// current executing process.
 class Process {
 public:
+  static unsigned getPageSize();
+
   /// \brief Return process memory usage.
   /// This static function will return the total amount of memory allocated
   /// by the process. This only counts the memory allocated via the malloc,
index 7eb0752c22201d44d79fedcbb8f3fe4782d586aa..539b6c3e754e74ba51a000f3a546d015452c4081 100644 (file)
@@ -330,7 +330,7 @@ static ErrorOr<std::unique_ptr<MemoryBuffer>>
 getOpenFileImpl(int FD, const Twine &Filename, uint64_t FileSize,
                 uint64_t MapSize, int64_t Offset, bool RequiresNullTerminator,
                 bool IsVolatileSize) {
-  static int PageSize = sys::process::get_self()->page_size();
+  static int PageSize = sys::Process::getPageSize();
 
   // Default is to map the full file.
   if (MapSize == uint64_t(-1)) {
index 0d42e0e35b92e7e3691d7b6eb7092375efe03978..ad67e1b10b48b95241a1bcd42f4118f47995e57a 100644 (file)
@@ -26,25 +26,6 @@ using namespace sys;
 //===          independent code.
 //===----------------------------------------------------------------------===//
 
-// Empty virtual destructor to anchor the vtable for the process class.
-process::~process() {}
-
-self_process *process::get_self() {
-  // Use a function local static for thread safe initialization and allocate it
-  // as a raw pointer to ensure it is never destroyed.
-  static self_process *SP = new self_process();
-
-  return SP;
-}
-
-// The destructor for the self_process subclass must never actually be
-// executed. There should be at most one instance of this class, and that
-// instance should live until the process terminates to avoid the potential for
-// racy accesses during shutdown.
-self_process::~self_process() {
-  llvm_unreachable("This destructor must never be executed!");
-}
-
 /// \brief A helper function to compute the elapsed wall-time since the program
 /// started.
 ///
@@ -63,12 +44,6 @@ static TimeValue getElapsedWallTime() {
 /// create race conditions during program startup or shutdown.
 static volatile TimeValue DummyTimeValue = getElapsedWallTime();
 
-// Implement this routine by using the static helpers above. They're already
-// portable.
-TimeValue self_process::get_wall_time() const {
-  return getElapsedWallTime();
-}
-
 Optional<std::string> Process::FindInEnvPath(const std::string& EnvName,
                                              const std::string& FileName)
 {
index c9d89a82474dece46a4a2ffd80e958da183343a0..7ccde463459dd7a390b0db1f92f5ea9dfbe4f2d2 100644 (file)
@@ -88,7 +88,7 @@ Memory::allocateMappedMemory(size_t NumBytes,
   if (NumBytes == 0)
     return MemoryBlock();
 
-  static const size_t PageSize = process::get_self()->page_size();
+  static const size_t PageSize = Process::getPageSize();
   const size_t NumPages = (NumBytes+PageSize-1)/PageSize;
 
   int fd = -1;
@@ -181,7 +181,7 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock,
                     std::string *ErrMsg) {
   if (NumBytes == 0) return MemoryBlock();
 
-  size_t PageSize = process::get_self()->page_size();
+  size_t PageSize = Process::getPageSize();
   size_t NumPages = (NumBytes+PageSize-1)/PageSize;
 
   int fd = -1;
index 634d4049d7decbeadefcb6ccabaaa208e8f189bc..82b207eecaf52f2d76db96a2b6bdb3af310b06cb 100644 (file)
@@ -550,7 +550,7 @@ const char *mapped_file_region::const_data() const {
 }
 
 int mapped_file_region::alignment() {
-  return process::get_self()->page_size();
+  return Process::getPageSize();
 }
 
 std::error_code detail::directory_iterator_construct(detail::DirIterState &it,
index a429bb3984c888a81bafe78031102c08686910ad..530f86cf90702d236077c0fabccb52b3653e056d 100644 (file)
 using namespace llvm;
 using namespace sys;
 
-process::id_type self_process::get_id() {
-  return getpid();
-}
-
 static std::pair<TimeValue, TimeValue> getRUsageTimes() {
 #if defined(HAVE_GETRUSAGE)
   struct rusage RU;
@@ -80,43 +76,19 @@ static std::pair<TimeValue, TimeValue> getRUsageTimes() {
 #endif
 }
 
-TimeValue self_process::get_user_time() const {
-#if _POSIX_TIMERS > 0 && _POSIX_CPUTIME > 0
-  // Try to get a high resolution CPU timer.
-  struct timespec TS;
-  if (::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &TS) == 0)
-    return TimeValue(static_cast<TimeValue::SecondsType>(TS.tv_sec),
-                     static_cast<TimeValue::NanoSecondsType>(TS.tv_nsec));
-#endif
-
-  // Otherwise fall back to rusage based timing.
-  return getRUsageTimes().first;
-}
-
-TimeValue self_process::get_system_time() const {
-  // We can only collect system time by inspecting the results of getrusage.
-  return getRUsageTimes().second;
-}
-
 // On Cygwin, getpagesize() returns 64k(AllocationGranularity) and
 // offset in mmap(3) should be aligned to the AllocationGranularity.
-static unsigned getPageSize() {
+unsigned Process::getPageSize() {
 #if defined(HAVE_GETPAGESIZE)
-  const int page_size = ::getpagesize();
+  static const int page_size = ::getpagesize();
 #elif defined(HAVE_SYSCONF)
-  long page_size = ::sysconf(_SC_PAGE_SIZE);
+  static long page_size = ::sysconf(_SC_PAGE_SIZE);
 #else
 #warning Cannot get the page size on this machine
 #endif
   return static_cast<unsigned>(page_size);
 }
 
-// This constructor guaranteed to be run exactly once on a single thread, and
-// sets up various process invariants that can be queried cheaply from then on.
-self_process::self_process() : PageSize(getPageSize()) {
-}
-
-
 size_t Process::GetMallocUsage() {
 #if defined(HAVE_MALLINFO)
   struct mallinfo mi;
index 3819e638c72eed6c5c6857305e4cc9ccef71d5fc..854eac73f230a120e2d77451a0aaa5e760c572f9 100644 (file)
 using namespace llvm;
 using namespace sys;
 
-process::id_type self_process::get_id() {
-  return GetCurrentProcessId();
-}
-
 static TimeValue getTimeValueFromFILETIME(FILETIME Time) {
   ULARGE_INTEGER TimeInteger;
   TimeInteger.LowPart = Time.dwLowDateTime;
@@ -65,28 +61,10 @@ static TimeValue getTimeValueFromFILETIME(FILETIME Time) {
           (TimeInteger.QuadPart % 10000000) * 100));
 }
 
-TimeValue self_process::get_user_time() const {
-  FILETIME ProcCreate, ProcExit, KernelTime, UserTime;
-  if (GetProcessTimes(GetCurrentProcess(), &ProcCreate, &ProcExit, &KernelTime,
-                      &UserTime) == 0)
-    return TimeValue();
-
-  return getTimeValueFromFILETIME(UserTime);
-}
-
-TimeValue self_process::get_system_time() const {
-  FILETIME ProcCreate, ProcExit, KernelTime, UserTime;
-  if (GetProcessTimes(GetCurrentProcess(), &ProcCreate, &ProcExit, &KernelTime,
-                      &UserTime) == 0)
-    return TimeValue();
-
-  return getTimeValueFromFILETIME(KernelTime);
-}
-
 // This function retrieves the page size using GetNativeSystemInfo() and is
 // present solely so it can be called once to initialize the self_process member
 // below.
-static unsigned getPageSize() {
+static unsigned computePageSize() {
   // GetNativeSystemInfo() provides the physical page size which may differ
   // from GetSystemInfo() in 32-bit applications running under WOW64.
   SYSTEM_INFO info;
@@ -96,12 +74,11 @@ static unsigned getPageSize() {
   return static_cast<unsigned>(info.dwPageSize);
 }
 
-// This constructor guaranteed to be run exactly once on a single thread, and
-// sets up various process invariants that can be queried cheaply from then on.
-self_process::self_process() : PageSize(getPageSize()) {
+unsigned Process::getPageSize() {
+  static unsigned Ret = computePageSize();
+  return Ret;
 }
 
-
 size_t
 Process::GetMallocUsage()
 {
index 8ad90e045de9c7732299844d0063e7222dc5bf99..f439cb2af9b109911bd543176bd65343d0af7e99 100644 (file)
@@ -21,7 +21,7 @@ class MappedMemoryTest : public ::testing::TestWithParam<unsigned> {
 public:
   MappedMemoryTest() {
     Flags = GetParam();
-    PageSize = sys::process::get_self()->page_size();
+    PageSize = sys::Process::getPageSize();
   }
 
 protected:
index 3045c305bc58c02750870b0b5ee3e12d4c5efe0c..298a0a373234e21da53a3970e9e0fb1c69fe9aa7 100644 (file)
@@ -19,26 +19,6 @@ namespace {
 using namespace llvm;
 using namespace sys;
 
-TEST(ProcessTest, SelfProcess) {
-  EXPECT_TRUE(process::get_self());
-  EXPECT_EQ(process::get_self(), process::get_self());
-
-#if defined(LLVM_ON_UNIX)
-  EXPECT_EQ(getpid(), process::get_self()->get_id());
-#elif defined(LLVM_ON_WIN32)
-  EXPECT_EQ(GetCurrentProcessId(), process::get_self()->get_id());
-#endif
-
-  EXPECT_LT(1u, process::get_self()->page_size());
-
-  EXPECT_LT(TimeValue::MinTime(), process::get_self()->get_user_time());
-  EXPECT_GT(TimeValue::MaxTime(), process::get_self()->get_user_time());
-  EXPECT_LT(TimeValue::MinTime(), process::get_self()->get_system_time());
-  EXPECT_GT(TimeValue::MaxTime(), process::get_self()->get_system_time());
-  EXPECT_LT(TimeValue::MinTime(), process::get_self()->get_wall_time());
-  EXPECT_GT(TimeValue::MaxTime(), process::get_self()->get_wall_time());
-}
-
 TEST(ProcessTest, GetRandomNumberTest) {
   const unsigned r1 = Process::GetRandomNumber();
   const unsigned r2 = Process::GetRandomNumber();