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|
21
21
set (HAVE_MACH_MACH_H 0 )
22
22
set (HAVE_MALLOC_MALLOC_H 0 )
23
23
set (HAVE_PTHREAD_H 1 )
24
+ set (HAVE_SYS_AUXV_H 1 )
24
25
set (HAVE_SYS_MMAN_H 1 )
25
26
set (HAVE_SYSEXITS_H 1 )
26
27
set (HAVE_UNISTD_H 1 )
52
53
check_include_file (mach/mach.h HAVE_MACH_MACH_H )
53
54
check_include_file (malloc/malloc.h HAVE_MALLOC_MALLOC_H )
54
55
check_include_file (pthread.h HAVE_PTHREAD_H )
56
+ check_include_file (sys/auxv.h HAVE_SYS_AUXV_H )
55
57
check_include_file (sys/mman.h HAVE_SYS_MMAN_H )
56
58
check_include_file (sysexits.h HAVE_SYSEXITS_H )
57
59
check_include_file (unistd.h HAVE_UNISTD_H )
Original file line number Diff line number Diff line change 295
295
296
296
#cmakedefine HAVE_BUILTIN_THREAD_POINTER ${HAVE_BUILTIN_THREAD_POINTER}
297
297
298
+ #cmakedefine HAVE_SYS_AUXV_H ${HAVE_SYS_AUXV_H}
299
+
298
300
#endif
Original file line number Diff line number Diff line change 31
31
#ifdef HAVE_MALLOC_MALLOC_H
32
32
#include < malloc/malloc.h>
33
33
#endif
34
+ #ifdef HAVE_SYS_AUXV_H
35
+ #include < sys/auxv.h>
36
+ #endif
34
37
35
38
// ===----------------------------------------------------------------------===//
36
39
// === WARNING: Implementation here must contain only generic UNIX code that
@@ -63,7 +66,9 @@ Process::Pid Process::getProcessId() {
63
66
// On Cygwin, getpagesize() returns 64k(AllocationGranularity) and
64
67
// offset in mmap(3) should be aligned to the AllocationGranularity.
65
68
Expected<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)
67
72
static const int page_size = ::getpagesize ();
68
73
#elif defined(HAVE_SYSCONF)
69
74
static long page_size = ::sysconf (_SC_PAGE_SIZE);
@@ -73,6 +78,8 @@ Expected<unsigned> Process::getPageSize() {
73
78
if (page_size == -1 )
74
79
return errorCodeToError (errnoAsErrorCode ());
75
80
81
+ assert (page_size > 0 && " Page size cannot be 0" );
82
+ assert ((page_size % 1024 ) == 0 && " Page size must be aligned by 1024" );
76
83
return static_cast <unsigned >(page_size);
77
84
}
78
85
You can’t perform that action at this time.
0 commit comments