From ca878c943bd7035e9ae52a5d9eafc167c00e7b9f Mon Sep 17 00:00:00 2001 From: Kristof Beyls Date: Thu, 30 Mar 2017 09:31:59 +0000 Subject: [PATCH] Make naming in Host.h in line with coding standards. Based on post-commit review comments by Chandler Carruth on https://reviews.llvm.org/D31236. Thanks! llvm-svn: 299062 --- llvm/include/llvm/Support/Host.h | 10 +++++----- llvm/lib/Support/Chrono.cpp | 12 ++++++------ llvm/lib/Support/Host.cpp | 12 ++++++------ llvm/unittests/Support/Host.cpp | 23 ++++++++++------------- 4 files changed, 27 insertions(+), 30 deletions(-) diff --git a/llvm/include/llvm/Support/Host.h b/llvm/include/llvm/Support/Host.h index 22a61f7..89986fd 100644 --- a/llvm/include/llvm/Support/Host.h +++ b/llvm/include/llvm/Support/Host.h @@ -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); } } } diff --git a/llvm/lib/Support/Chrono.cpp b/llvm/lib/Support/Chrono.cpp index ca748f5..daccaf1 100644 --- a/llvm/lib/Support/Chrono.cpp +++ b/llvm/lib/Support/Chrono.cpp @@ -16,12 +16,12 @@ namespace llvm { using namespace sys; -const char detail::unit>::value[] = "h"; -const char detail::unit>::value[] = "m"; -const char detail::unit>::value[] = "s"; -const char detail::unit::value[] = "ms"; -const char detail::unit::value[] = "us"; -const char detail::unit::value[] = "ns"; +const char llvm::detail::unit>::value[] = "h"; +const char llvm::detail::unit>::value[] = "m"; +const char llvm::detail::unit>::value[] = "s"; +const char llvm::detail::unit::value[] = "ms"; +const char llvm::detail::unit::value[] = "us"; +const char llvm::detail::unit::value[] = "ns"; static inline struct tm getStructTM(TimePoint<> TP) { struct tm Storage; diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp index 230d092..54fbb55 100644 --- a/llvm/lib/Support/Host.cpp +++ b/llvm/lib/Support/Host.cpp @@ -64,7 +64,7 @@ static std::unique_ptr 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 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 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 P = getProcCpuinfoContent(); const StringRef& Content = P ? P->getBuffer() : ""; - return LinuxReadCpuInfo::getHostCPUName_s390x(Content); + return detail::getHostCPUNameForS390x(Content); } #else StringRef sys::getHostCPUName() { return "generic"; } diff --git a/llvm/unittests/Support/Host.cpp b/llvm/unittests/Support/Host.cpp index 0d22ba8..48f021e 100644 --- a/llvm/unittests/Support/Host.cpp +++ b/llvm/unittests/Support/Host.cpp @@ -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"); } -- 2.7.4