diff options
-rw-r--r-- | absl/base/internal/direct_mmap.h | 4 | ||||
-rw-r--r-- | absl/base/internal/low_level_alloc.cc | 2 | ||||
-rw-r--r-- | absl/debugging/failure_signal_handler.cc | 4 | ||||
-rw-r--r-- | absl/debugging/symbolize_elf.inc | 4 |
4 files changed, 14 insertions, 0 deletions
diff --git a/absl/base/internal/direct_mmap.h b/absl/base/internal/direct_mmap.h index 3e5368db46f5..654a60072703 100644 --- a/absl/base/internal/direct_mmap.h +++ b/absl/base/internal/direct_mmap.h @@ -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; diff --git a/absl/base/internal/low_level_alloc.cc b/absl/base/internal/low_level_alloc.cc index 015edf8dadb9..4af9c05da0d1 100644 --- a/absl/base/internal/low_level_alloc.cc +++ b/absl/base/internal/low_level_alloc.cc @@ -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 diff --git a/absl/debugging/failure_signal_handler.cc b/absl/debugging/failure_signal_handler.cc index 6cecd93f9ba1..c2e56f9d819c 100644 --- a/absl/debugging/failure_signal_handler.cc +++ b/absl/debugging/failure_signal_handler.cc @@ -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) diff --git a/absl/debugging/symbolize_elf.inc b/absl/debugging/symbolize_elf.inc index b31362e6f552..97d767abf11d 100644 --- a/absl/debugging/symbolize_elf.inc +++ b/absl/debugging/symbolize_elf.inc @@ -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; } |