Refix PAGE_SIZE

* honor actually used headers
* include sys/user.h only when `PAGE_SIZE` is not defined
This commit is contained in:
Nobuyoshi Nakada 2021-05-14 09:33:20 +09:00
parent a168c47728
commit 7cf90f99f5
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6
2 changed files with 11 additions and 11 deletions

View File

@ -2732,14 +2732,11 @@ main(int argc, char *argv[])
test x$rb_cv_fork_with_pthread = xyes || AC_DEFINE(CANNOT_FORK_WITH_PTHREAD) test x$rb_cv_fork_with_pthread = xyes || AC_DEFINE(CANNOT_FORK_WITH_PTHREAD)
]) ])
AS_CASE([$target_os], AC_CHECK_HEADERS([sys/user.h])
[darwin*], [ac_cv_header_sys_user_h=no], dnl LIST_HEAD conflicts with sys/queue.h AS_IF([test "x$ac_cv_func_mmap" = xyes], [
[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([whether PAGE_SIZE is compile-time const], rb_cv_const_page_size, AC_CACHE_CHECK([whether PAGE_SIZE is compile-time const], rb_cv_const_page_size,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ [malloc_headers=`sed -n '/MALLOC_HEADERS_BEGIN/,/MALLOC_HEADERS_END/p' ${srcdir}/gc.c`
@%:@include <sys/user.h> AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$malloc_headers
typedef char conftest_page[PAGE_SIZE]; typedef char conftest_page[PAGE_SIZE];
]], [[]])], ]], [[]])],
[rb_cv_const_page_size=yes], [rb_cv_const_page_size=yes],

11
gc.c
View File

@ -32,6 +32,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
/* MALLOC_HEADERS_BEGIN */
#ifndef HAVE_MALLOC_USABLE_SIZE #ifndef HAVE_MALLOC_USABLE_SIZE
# ifdef _WIN32 # ifdef _WIN32
# define HAVE_MALLOC_USABLE_SIZE # define HAVE_MALLOC_USABLE_SIZE
@ -54,6 +55,12 @@
# endif # endif
#endif #endif
#if !defined(PAGE_SIZE) && defined(HAVE_SYS_USER_H)
/* LIST_HEAD conflicts with sys/queue.h on macOS */
# include <sys/user.h>
#endif
/* MALLOC_HEADERS_END */
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H
# include <sys/time.h> # include <sys/time.h>
#endif #endif
@ -71,10 +78,6 @@
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_SYS_USER_H
# include <sys/user.h>
#endif
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
#include <emscripten.h> #include <emscripten.h>
#endif #endif