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") {
"synchronization/waitable_event_posix.cc",
"synchronization/waitable_event_watcher_posix.cc",
"system/sys_info_fuchsia.cc",
"system/sys_info_posix.cc",
"task/thread_pool/task_tracker_posix.cc",
"task/thread_pool/task_tracker_posix.h",
"threading/platform_thread_fuchsia.cc",
......
......@@ -4,9 +4,11 @@
#include "base/system/sys_info.h"
#include <sys/utsname.h>
#include <zircon/syscalls.h>
#include "base/logging.h"
#include "base/threading/scoped_blocking_call.h"
namespace base {
......@@ -17,7 +19,8 @@ int64_t SysInfo::AmountOfPhysicalMemoryImpl() {
// static
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();
return 0;
}
......@@ -37,4 +40,68 @@ std::string SysInfo::OperatingSystemName() {
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
......@@ -9,6 +9,7 @@
#include <stdint.h>
#include <string.h>
#include <sys/param.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <unistd.h>
......@@ -20,10 +21,6 @@
#include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h"
#if !defined(OS_FUCHSIA)
#include <sys/resource.h>
#endif
#if defined(OS_ANDROID)
#include <sys/vfs.h>
#define statvfs statfs // Android uses a statvfs-like statfs struct and call.
......@@ -38,7 +35,7 @@
namespace {
#if !defined(OS_OPENBSD) && !defined(OS_FUCHSIA)
#if !defined(OS_OPENBSD)
int NumberOfProcessors() {
// sysconf returns the number of "logical" (not "physical") processors on both
// Mac and Linux. So we get the number of max available "logical" processors.
......@@ -64,9 +61,8 @@ int NumberOfProcessors() {
base::LazyInstance<base::internal::LazySysInfoValue<int, NumberOfProcessors>>::
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() {
struct rlimit limit;
int result = getrlimit(RLIMIT_DATA, &limit);
......@@ -80,7 +76,6 @@ int64_t AmountOfVirtualMemory() {
base::LazyInstance<
base::internal::LazySysInfoValue<int64_t, AmountOfVirtualMemory>>::Leaky
g_lazy_virtual_memory = LAZY_INSTANCE_INITIALIZER;
#endif // !defined(OS_FUCHSIA)
#if defined(OS_LINUX)
bool IsStatsZeroIfUnlimited(const base::FilePath& path) {
......@@ -97,7 +92,7 @@ bool IsStatsZeroIfUnlimited(const base::FilePath& path) {
}
return false;
}
#endif
#endif // defined(OS_LINUX)
bool GetDiskSpaceInfo(const base::FilePath& path,
int64_t* available_bytes,
......@@ -132,18 +127,16 @@ bool GetDiskSpaceInfo(const base::FilePath& path,
namespace base {
#if !defined(OS_OPENBSD) && !defined(OS_FUCHSIA)
#if !defined(OS_OPENBSD)
int SysInfo::NumberOfProcessors() {
return g_lazy_number_of_processors.Get().value();
}
#endif
#endif // !defined(OS_OPENBSD)
#if !defined(OS_FUCHSIA)
// static
int64_t SysInfo::AmountOfVirtualMemory() {
return g_lazy_virtual_memory.Get().value();
}
#endif
// static
int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
......@@ -167,7 +160,7 @@ int64_t SysInfo::AmountOfTotalDiskSpace(const FilePath& path) {
return total;
}
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_FUCHSIA)
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
// static
std::string SysInfo::OperatingSystemName() {
struct utsname info;
......@@ -177,7 +170,7 @@ std::string SysInfo::OperatingSystemName() {
}
return std::string(info.sysname);
}
#endif
#endif //! defined(OS_MACOSX) && !defined(OS_ANDROID)
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
// 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