]> granicus.if.org Git - llvm/commitdiff
Make naming in Host.h in line with coding standards.
authorKristof Beyls <kristof.beyls@arm.com>
Fri, 31 Mar 2017 13:06:40 +0000 (13:06 +0000)
committerKristof Beyls <kristof.beyls@arm.com>
Fri, 31 Mar 2017 13:06:40 +0000 (13:06 +0000)
Based on post-commit review comments by Chandler Carruth on
https://reviews.llvm.org/D31236. Thanks!

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

include/llvm/Support/Host.h
include/llvm/Support/MathExtras.h
lib/Support/Chrono.cpp
lib/Support/Host.cpp
unittests/Support/Host.cpp

index 22a61f760648f1fcb55320f20abf0f84e3dc9534..89986fdae9713d23546e50c9d29e87ebebb14f7f 100644 (file)
@@ -77,11 +77,11 @@ constexpr bool IsBigEndianHost = false;
   /// Returns -1 if unknown for the current host system.
   int getHostNumPhysicalCores();
 
-  /// helper functions to extract HostCPUName from /proc/cpuinfo on linux.
-  namespace LinuxReadCpuInfo {
-  StringRef getHostCPUName_powerpc(const StringRef &ProcCpuinfoContent);
-  StringRef getHostCPUName_arm(const StringRef &ProcCpuinfoContent);
-  StringRef getHostCPUName_s390x(const StringRef &ProcCpuinfoContent);
+  namespace detail {
+  /// Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
+  StringRef getHostCPUNameForPowerPC(const StringRef &ProcCpuinfoContent);
+  StringRef getHostCPUNameForARM(const StringRef &ProcCpuinfoContent);
+  StringRef getHostCPUNameForS390x(const StringRef &ProcCpuinfoContent);
   }
 }
 }
index 77970f487112a031eb6759e2ad02be95bcbe7a09..19380b23d9d24768b8312a8fa56fb525c28ef41e 100644 (file)
@@ -112,7 +112,7 @@ std::size_t countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
   static_assert(std::numeric_limits<T>::is_integer &&
                     !std::numeric_limits<T>::is_signed,
                 "Only unsigned integral types are allowed.");
-  return detail::TrailingZerosCounter<T, sizeof(T)>::count(Val, ZB);
+  return llvm::detail::TrailingZerosCounter<T, sizeof(T)>::count(Val, ZB);
 }
 
 namespace detail {
@@ -181,7 +181,7 @@ std::size_t countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
   static_assert(std::numeric_limits<T>::is_integer &&
                     !std::numeric_limits<T>::is_signed,
                 "Only unsigned integral types are allowed.");
-  return detail::LeadingZerosCounter<T, sizeof(T)>::count(Val, ZB);
+  return llvm::detail::LeadingZerosCounter<T, sizeof(T)>::count(Val, ZB);
 }
 
 /// \brief Get the index of the first set bit starting from the least
index ca748f5c046c0cdf9a1b478fd3d804bb1dc0b75e..daccaf1fc103d58e4590afb32dcade88663649a7 100644 (file)
@@ -16,12 +16,12 @@ namespace llvm {
 
 using namespace sys;
 
-const char detail::unit<std::ratio<3600>>::value[] = "h";
-const char detail::unit<std::ratio<60>>::value[] = "m";
-const char detail::unit<std::ratio<1>>::value[] = "s";
-const char detail::unit<std::milli>::value[] = "ms";
-const char detail::unit<std::micro>::value[] = "us";
-const char detail::unit<std::nano>::value[] = "ns";
+const char llvm::detail::unit<std::ratio<3600>>::value[] = "h";
+const char llvm::detail::unit<std::ratio<60>>::value[] = "m";
+const char llvm::detail::unit<std::ratio<1>>::value[] = "s";
+const char llvm::detail::unit<std::milli>::value[] = "ms";
+const char llvm::detail::unit<std::micro>::value[] = "us";
+const char llvm::detail::unit<std::nano>::value[] = "ns";
 
 static inline struct tm getStructTM(TimePoint<> TP) {
   struct tm Storage;
index 230d0921184a208fb358d1f9567e346dabe49e1d..54fbb558c432d1f5f675ade231f69b7b7d2e15a6 100644 (file)
@@ -64,7 +64,7 @@ static std::unique_ptr<llvm::MemoryBuffer>
   return std::move(*Text);
 }
 
-StringRef sys::LinuxReadCpuInfo::getHostCPUName_powerpc(
+StringRef sys::detail::getHostCPUNameForPowerPC(
     const StringRef &ProcCpuinfoContent) {
   // Access to the Processor Version Register (PVR) on PowerPC is privileged,
   // and so we must use an operating-system interface to determine the current
@@ -144,7 +144,7 @@ StringRef sys::LinuxReadCpuInfo::getHostCPUName_powerpc(
       .Default(generic);
 }
 
-StringRef sys::LinuxReadCpuInfo::getHostCPUName_arm(
+StringRef sys::detail::getHostCPUNameForARM(
     const StringRef &ProcCpuinfoContent) {
   // The cpuid register on arm is not accessible from user space. On Linux,
   // it is exposed through the /proc/cpuinfo file.
@@ -195,7 +195,7 @@ StringRef sys::LinuxReadCpuInfo::getHostCPUName_arm(
   return "generic";
 }
 
-StringRef sys::LinuxReadCpuInfo::getHostCPUName_s390x(
+StringRef sys::detail::getHostCPUNameForS390x(
     const StringRef &ProcCpuinfoContent) {
   // STIDP is a privileged operation, so use /proc/cpuinfo instead.
 
@@ -1197,19 +1197,19 @@ StringRef sys::getHostCPUName() {
 StringRef sys::getHostCPUName() {
   std::unique_ptr<llvm::MemoryBuffer> P = getProcCpuinfoContent();
   const StringRef& Content = P ? P->getBuffer() : "";
-  return LinuxReadCpuInfo::getHostCPUName_powerpc(Content);
+  return detail::getHostCPUNameForPowerPC(Content);
 }
 #elif defined(__linux__) && defined(__arm__)
 StringRef sys::getHostCPUName() {
   std::unique_ptr<llvm::MemoryBuffer> P = getProcCpuinfoContent();
   const StringRef& Content = P ? P->getBuffer() : "";
-  return LinuxReadCpuInfo::getHostCPUName_arm(Content);
+  return detail::getHostCPUNameForARM(Content);
 }
 #elif defined(__linux__) && defined(__s390x__)
 StringRef sys::getHostCPUName() {
   std::unique_ptr<llvm::MemoryBuffer> P = getProcCpuinfoContent();
   const StringRef& Content = P ? P->getBuffer() : "";
-  return LinuxReadCpuInfo::getHostCPUName_s390x(Content);
+  return detail::getHostCPUNameForS390x(Content);
 }
 #else
 StringRef sys::getHostCPUName() { return "generic"; }
index 0d22ba8ca79585d2710ab8e9740e34111645c8d9..48f021e54275cd85a0a4582efeb47ba05038c560 100644 (file)
@@ -66,19 +66,16 @@ Revision        : 0000
 Serial          : 0000000000000000
 )";
 
-  EXPECT_EQ(sys::LinuxReadCpuInfo::getHostCPUName_arm(CortexA9ProcCpuinfo),
+  EXPECT_EQ(sys::detail::getHostCPUNameForARM(CortexA9ProcCpuinfo),
             "cortex-a9");
-  EXPECT_EQ(
-      sys::LinuxReadCpuInfo::getHostCPUName_arm("CPU implementer : 0x41\n"
-                                                "CPU part        : 0xc0f"),
-      "cortex-a15");
+  EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x41\n"
+                                              "CPU part        : 0xc0f"),
+            "cortex-a15");
   // Verify that both CPU implementer and CPU part are checked:
-  EXPECT_EQ(
-      sys::LinuxReadCpuInfo::getHostCPUName_arm("CPU implementer : 0x40\n"
-                                                "CPU part        : 0xc0f"),
-      "generic");
-  EXPECT_EQ(
-      sys::LinuxReadCpuInfo::getHostCPUName_arm("CPU implementer : 0x51\n"
-                                                "CPU part        : 0x06f"),
-      "krait");
+  EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x40\n"
+                                              "CPU part        : 0xc0f"),
+            "generic");
+  EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x51\n"
+                                              "CPU part        : 0x06f"),
+            "krait");
 }