Export of internal Abseil changes.

--
5278e56bd7d322ecf161eaf29fd7fa3941d7431b by Greg Falcon <gfalcon@google.com>:

internal change

PiperOrigin-RevId: 222078614
GitOrigin-RevId: 5278e56bd7d322ecf161eaf29fd7fa3941d7431b
Change-Id: I1e86bef2e3733c81148a1a42dccd8182fe3f7fae
This commit is contained in:
Abseil Team 2018-11-19 08:14:58 -08:00 committed by Derek Mauro
parent f6ae816808
commit 3088e76c59
4 changed files with 14 additions and 0 deletions

View file

@ -75,7 +75,11 @@ inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd,
// On these architectures, implement mmap with mmap2.
static int pagesize = 0;
if (pagesize == 0) {
#if defined(__wasm__) || defined(__asmjs__)
pagesize = getpagesize();
#else
pagesize = sysconf(_SC_PAGESIZE);
#endif
}
if (offset < 0 || offset % pagesize != 0) {
errno = EINVAL;

View file

@ -324,6 +324,8 @@ size_t GetPageSize() {
SYSTEM_INFO system_info;
GetSystemInfo(&system_info);
return std::max(system_info.dwPageSize, system_info.dwAllocationGranularity);
#elif defined(__wasm__) || defined(__asmjs__)
return getpagesize();
#else
return sysconf(_SC_PAGESIZE);
#endif

View file

@ -119,7 +119,11 @@ const char* FailureSignalToString(int signo) {
#ifndef _WIN32
static bool SetupAlternateStackOnce() {
#if defined(__wasm__) || defined (__asjms__)
const size_t page_mask = getpagesize() - 1;
#else
const size_t page_mask = sysconf(_SC_PAGESIZE) - 1;
#endif
size_t stack_size = (std::max(SIGSTKSZ, 65536) + page_mask) & ~page_mask;
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER)

View file

@ -333,7 +333,11 @@ static std::atomic<Symbolizer *> g_cached_symbolizer;
} // namespace
static int SymbolizerSize() {
#if defined(__wasm__) || defined(__asmjs__)
int pagesize = getpagesize();
#else
int pagesize = sysconf(_SC_PAGESIZE);
#endif
return ((sizeof(Symbolizer) - 1) / pagesize + 1) * pagesize;
}