diff options
author | Peter Zhu <peter@peterzhu.ca> | 2021-05-05 16:20:40 +0000 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2021-05-05 15:31:30 -0400 |
commit | 23a98237df28ad01d17b163eb650dfbd321b13ba (patch) | |
tree | 5fb24b61788114b3a83bece3d1561f9555dc7b0d /configure.ac | |
parent | 192150051144c0242ee44df26952dfe31b83cac2 (diff) |
Fix PAGE_SIZE macro detection in autoconf
The current fix for PAGE_SIZE macro detection in autoconf does not work
correctly. I see the following output with running configure on Linux:
```
checking PAGE_SIZE is defined... no
```
Linux has PAGE_SIZE macro. This is happening because the macro exists in
sys/user.h and not in the malloc headers.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4461
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac index 1eb4be412c..e49c128a45 100644 --- a/configure.ac +++ b/configure.ac @@ -2727,23 +2727,26 @@ main(int argc, char *argv[]) test x$rb_cv_fork_with_pthread = xyes || AC_DEFINE(CANNOT_FORK_WITH_PTHREAD) ]) -AS_IF([test "x$ac_cv_func_mmap" = xyes], [ - malloc_headers=`sed -n '/MALLOC_HEADERS_BEGIN/,/MALLOC_HEADERS_END/p' ${srcdir}/gc.c` +AC_CHECK_HEADERS([sys/user.h]) +AS_IF([test "x$ac_cv_func_mmap:$ac_cv_header_sys_user_h" = xyes:yes], [ AC_CACHE_CHECK([PAGE_SIZE is defined], rb_cv_page_size, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[${malloc_headers} + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + @%:@include <sys/user.h> typedef char conftest_page[PAGE_SIZE]; ]], [[]])], [rb_cv_page_size=const], - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[${malloc_headers}]], [[ + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + @%:@include <sys/user.h> + ]], [[ int page_size = (int)PAGE_SIZE; (void)page_size; ]])], [rb_cv_page_size=variable], [rb_cv_page_size=no])])]) - AS_CASE([$rb_cv_page_size], - [const], [AC_DEFINE(USE_MMAP_ALIGNED_ALLOC, [(PAGE_SIZE <= HEAP_PAGE_SIZE)])], - [no], [AC_DEFINE(USE_MMAP_ALIGNED_ALLOC, 1)], + AS_IF([test "x$rb_cv_page_size" = xconst], + [AC_DEFINE(HAVE_CONST_PAGE_SIZE, 1)], + [AC_DEFINE(HAVE_CONST_PAGE_SIZE, 0)] ) -], [AC_DEFINE(USE_MMAP_ALIGNED_ALLOC, 0)]) +], [AC_DEFINE(HAVE_CONST_PAGE_SIZE, 0)]) } : "runtime section" && { |