File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ if (ANDROID OR CYGWIN OR CMAKE_SYSTEM_NAME MATCHES "AIX|DragonFly|FreeBSD|Haiku|
2121 set (HAVE_MACH_MACH_H 0)
2222 set (HAVE_MALLOC_MALLOC_H 0)
2323 set (HAVE_PTHREAD_H 1)
24+ set (HAVE_SYS_AUXV_H 1)
2425 set (HAVE_SYS_MMAN_H 1)
2526 set (HAVE_SYSEXITS_H 1)
2627 set (HAVE_UNISTD_H 1)
5253 check_include_file(mach/mach.h HAVE_MACH_MACH_H)
5354 check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
5455 check_include_file(pthread.h HAVE_PTHREAD_H)
56+ check_include_file(sys/auxv.h HAVE_SYS_AUXV_H)
5557 check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
5658 check_include_file(sysexits.h HAVE_SYSEXITS_H)
5759 check_include_file(unistd.h HAVE_UNISTD_H)
Original file line number Diff line number Diff line change 295295
296296#cmakedefine HAVE_BUILTIN_THREAD_POINTER ${HAVE_BUILTIN_THREAD_POINTER}
297297
298+ #cmakedefine HAVE_SYS_AUXV_H ${HAVE_SYS_AUXV_H}
299+
298300#endif
Original file line number Diff line number Diff line change 3131#ifdef HAVE_MALLOC_MALLOC_H
3232#include < malloc/malloc.h>
3333#endif
34+ #ifdef HAVE_SYS_AUXV_H
35+ #include < sys/auxv.h>
36+ #endif
3437
3538// ===----------------------------------------------------------------------===//
3639// === WARNING: Implementation here must contain only generic UNIX code that
@@ -63,7 +66,9 @@ Process::Pid Process::getProcessId() {
6366// On Cygwin, getpagesize() returns 64k(AllocationGranularity) and
6467// offset in mmap(3) should be aligned to the AllocationGranularity.
6568Expected<unsigned > Process::getPageSize () {
66- #if defined(HAVE_GETPAGESIZE)
69+ #if defined(HAVE_SYS_AUXV_H)
70+ static const int page_size = ::getauxval (AT_PAGESZ);
71+ #elif defined(HAVE_GETPAGESIZE)
6772 static const int page_size = ::getpagesize ();
6873#elif defined(HAVE_SYSCONF)
6974 static long page_size = ::sysconf (_SC_PAGE_SIZE);
@@ -73,6 +78,8 @@ Expected<unsigned> Process::getPageSize() {
7378 if (page_size == -1 )
7479 return errorCodeToError (errnoAsErrorCode ());
7580
81+ assert (page_size > 0 && " Page size cannot be 0" );
82+ assert ((page_size % 1024 ) == 0 && " Page size must be aligned by 1024" );
7683 return static_cast <unsigned >(page_size);
7784}
7885
You can’t perform that action at this time.
0 commit comments