diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/sys_info.h | 5 | ||||
-rw-r--r-- | base/sys_info_posix.cc | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/base/sys_info.h b/base/sys_info.h index 581720d..5469da54 100644 --- a/base/sys_info.h +++ b/base/sys_info.h @@ -65,6 +65,11 @@ class SysInfo { // allocate. static size_t VMAllocationGranularity(); +#if defined(OS_LINUX) + // Returns the maximum SysV shared memory segment size. + static size_t MaxSharedMemorySize(); +#endif + #if defined(OS_CHROMEOS) // Returns the name of the version entry we wish to look up in the // Linux Standard Base release information file. diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc index 388ccba..23156e2 100644 --- a/base/sys_info_posix.cc +++ b/base/sys_info_posix.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/file_util.h" #include "base/sys_info.h" #include "base/basictypes.h" @@ -150,4 +151,21 @@ size_t SysInfo::VMAllocationGranularity() { return getpagesize(); } +#if defined(OS_LINUX) +// static +size_t SysInfo::MaxSharedMemorySize() { + static size_t limit; + static bool limit_valid = false; + + if (!limit_valid) { + std::string contents; + file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents); + limit = strtoul(contents.c_str(), NULL, 0); + limit_valid = true; + } + + return limit; +} +#endif + } // namespace base |