Commit 731c16df authored by arun manickam's avatar arun manickam Committed by Commit Bot

[Fuchsia] Stop using the POSIX SysInfo implementation.

Adding Fuchsia specific SysInfo APIs and removing OS_FUCHSIA conditions from POXIS SysInfo Implementation (Code Clean-up)

Bug: b/136176387

Test: base_unittests

Change-Id: I90a431bae3fe814d1aa7f14071a0ac68a1dce8f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1693741
Commit-Queue: Arun Manickam <arunmanickam@google.com>
Reviewed-by: default avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678958}
parent b4717783
...@@ -1549,7 +1549,6 @@ jumbo_component("base") { ...@@ -1549,7 +1549,6 @@ jumbo_component("base") {
"synchronization/waitable_event_posix.cc", "synchronization/waitable_event_posix.cc",
"synchronization/waitable_event_watcher_posix.cc", "synchronization/waitable_event_watcher_posix.cc",
"system/sys_info_fuchsia.cc", "system/sys_info_fuchsia.cc",
"system/sys_info_posix.cc",
"task/thread_pool/task_tracker_posix.cc", "task/thread_pool/task_tracker_posix.cc",
"task/thread_pool/task_tracker_posix.h", "task/thread_pool/task_tracker_posix.h",
"threading/platform_thread_fuchsia.cc", "threading/platform_thread_fuchsia.cc",
......
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
#include "base/system/sys_info.h" #include "base/system/sys_info.h"
#include <sys/utsname.h>
#include <zircon/syscalls.h> #include <zircon/syscalls.h>
#include "base/logging.h" #include "base/logging.h"
#include "base/threading/scoped_blocking_call.h"
namespace base { namespace base {
...@@ -17,7 +19,8 @@ int64_t SysInfo::AmountOfPhysicalMemoryImpl() { ...@@ -17,7 +19,8 @@ int64_t SysInfo::AmountOfPhysicalMemoryImpl() {
// static // static
int64_t SysInfo::AmountOfAvailablePhysicalMemoryImpl() { int64_t SysInfo::AmountOfAvailablePhysicalMemoryImpl() {
// TODO(fuchsia): https://crbug.com/706592 This is not exposed. // TODO(https://crbug.com/706592): This method doesn't have an Fuchsia API to
// consume it
NOTREACHED(); NOTREACHED();
return 0; return 0;
} }
...@@ -37,4 +40,68 @@ std::string SysInfo::OperatingSystemName() { ...@@ -37,4 +40,68 @@ std::string SysInfo::OperatingSystemName() {
return "Fuchsia"; return "Fuchsia";
} }
// static
int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
NOTIMPLEMENTED_LOG_ONCE();
return -1;
}
// static
int64_t SysInfo::AmountOfTotalDiskSpace(const FilePath& path) {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
NOTIMPLEMENTED_LOG_ONCE();
return -1;
}
// static
std::string SysInfo::OperatingSystemVersion() {
struct utsname info;
if (uname(&info) < 0) {
NOTREACHED();
return std::string();
}
return std::string(info.release);
}
// static
void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version,
int32_t* minor_version,
int32_t* bugfix_version) {
struct utsname info;
if (uname(&info) < 0) {
*major_version = 0;
*minor_version = 0;
*bugfix_version = 0;
return;
}
int num_read = sscanf(info.release, "%d.%d.%d", major_version, minor_version,
bugfix_version);
if (num_read < 1)
*major_version = 0;
if (num_read < 2)
*minor_version = 0;
if (num_read < 3)
*bugfix_version = 0;
}
// static
std::string SysInfo::OperatingSystemArchitecture() {
struct utsname info;
if (uname(&info) < 0) {
NOTREACHED();
return std::string();
}
return info.machine;
}
// static
size_t SysInfo::VMAllocationGranularity() {
return getpagesize();
}
} // namespace base } // namespace base
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/resource.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <unistd.h> #include <unistd.h>
...@@ -20,10 +21,6 @@ ...@@ -20,10 +21,6 @@
#include "base/threading/scoped_blocking_call.h" #include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h" #include "build/build_config.h"
#if !defined(OS_FUCHSIA)
#include <sys/resource.h>
#endif
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include <sys/vfs.h> #include <sys/vfs.h>
#define statvfs statfs // Android uses a statvfs-like statfs struct and call. #define statvfs statfs // Android uses a statvfs-like statfs struct and call.
...@@ -38,7 +35,7 @@ ...@@ -38,7 +35,7 @@
namespace { namespace {
#if !defined(OS_OPENBSD) && !defined(OS_FUCHSIA) #if !defined(OS_OPENBSD)
int NumberOfProcessors() { int NumberOfProcessors() {
// sysconf returns the number of "logical" (not "physical") processors on both // sysconf returns the number of "logical" (not "physical") processors on both
// Mac and Linux. So we get the number of max available "logical" processors. // Mac and Linux. So we get the number of max available "logical" processors.
...@@ -64,9 +61,8 @@ int NumberOfProcessors() { ...@@ -64,9 +61,8 @@ int NumberOfProcessors() {
base::LazyInstance<base::internal::LazySysInfoValue<int, NumberOfProcessors>>:: base::LazyInstance<base::internal::LazySysInfoValue<int, NumberOfProcessors>>::
Leaky g_lazy_number_of_processors = LAZY_INSTANCE_INITIALIZER; Leaky g_lazy_number_of_processors = LAZY_INSTANCE_INITIALIZER;
#endif // !defined(OS_OPENBSD) && !defined(OS_FUCHSIA) #endif // !defined(OS_OPENBSD)
#if !defined(OS_FUCHSIA)
int64_t AmountOfVirtualMemory() { int64_t AmountOfVirtualMemory() {
struct rlimit limit; struct rlimit limit;
int result = getrlimit(RLIMIT_DATA, &limit); int result = getrlimit(RLIMIT_DATA, &limit);
...@@ -80,7 +76,6 @@ int64_t AmountOfVirtualMemory() { ...@@ -80,7 +76,6 @@ int64_t AmountOfVirtualMemory() {
base::LazyInstance< base::LazyInstance<
base::internal::LazySysInfoValue<int64_t, AmountOfVirtualMemory>>::Leaky base::internal::LazySysInfoValue<int64_t, AmountOfVirtualMemory>>::Leaky
g_lazy_virtual_memory = LAZY_INSTANCE_INITIALIZER; g_lazy_virtual_memory = LAZY_INSTANCE_INITIALIZER;
#endif // !defined(OS_FUCHSIA)
#if defined(OS_LINUX) #if defined(OS_LINUX)
bool IsStatsZeroIfUnlimited(const base::FilePath& path) { bool IsStatsZeroIfUnlimited(const base::FilePath& path) {
...@@ -97,7 +92,7 @@ bool IsStatsZeroIfUnlimited(const base::FilePath& path) { ...@@ -97,7 +92,7 @@ bool IsStatsZeroIfUnlimited(const base::FilePath& path) {
} }
return false; return false;
} }
#endif #endif // defined(OS_LINUX)
bool GetDiskSpaceInfo(const base::FilePath& path, bool GetDiskSpaceInfo(const base::FilePath& path,
int64_t* available_bytes, int64_t* available_bytes,
...@@ -132,18 +127,16 @@ bool GetDiskSpaceInfo(const base::FilePath& path, ...@@ -132,18 +127,16 @@ bool GetDiskSpaceInfo(const base::FilePath& path,
namespace base { namespace base {
#if !defined(OS_OPENBSD) && !defined(OS_FUCHSIA) #if !defined(OS_OPENBSD)
int SysInfo::NumberOfProcessors() { int SysInfo::NumberOfProcessors() {
return g_lazy_number_of_processors.Get().value(); return g_lazy_number_of_processors.Get().value();
} }
#endif #endif // !defined(OS_OPENBSD)
#if !defined(OS_FUCHSIA)
// static // static
int64_t SysInfo::AmountOfVirtualMemory() { int64_t SysInfo::AmountOfVirtualMemory() {
return g_lazy_virtual_memory.Get().value(); return g_lazy_virtual_memory.Get().value();
} }
#endif
// static // static
int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
...@@ -167,7 +160,7 @@ int64_t SysInfo::AmountOfTotalDiskSpace(const FilePath& path) { ...@@ -167,7 +160,7 @@ int64_t SysInfo::AmountOfTotalDiskSpace(const FilePath& path) {
return total; return total;
} }
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_FUCHSIA) #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
// static // static
std::string SysInfo::OperatingSystemName() { std::string SysInfo::OperatingSystemName() {
struct utsname info; struct utsname info;
...@@ -177,7 +170,7 @@ std::string SysInfo::OperatingSystemName() { ...@@ -177,7 +170,7 @@ std::string SysInfo::OperatingSystemName() {
} }
return std::string(info.sysname); return std::string(info.sysname);
} }
#endif #endif //! defined(OS_MACOSX) && !defined(OS_ANDROID)
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
// static // static
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment