Reuse sysconf result
This commit is contained in:
parent
0dd9ac7721
commit
f941dd5a9f
28
gc.c
28
gc.c
@ -3213,20 +3213,6 @@ Init_heap(void)
|
||||
{
|
||||
rb_objspace_t *objspace = &rb_objspace;
|
||||
|
||||
#if defined(HAVE_MMAP) && !HAVE_CONST_PAGE_SIZE && !defined(PAGE_MAX_SIZE)
|
||||
/* Need to determine if we can use mmap at runtime. */
|
||||
# ifdef PAGE_SIZE
|
||||
/* If the PAGE_SIZE macro can be used. */
|
||||
use_mmap_aligned_alloc = PAGE_SIZE <= HEAP_PAGE_SIZE;
|
||||
# elif defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
|
||||
/* If we can use sysconf to determine the page size. */
|
||||
use_mmap_aligned_alloc = sysconf(_SC_PAGE_SIZE) <= HEAP_PAGE_SIZE;
|
||||
# else
|
||||
/* Otherwise we can't determine the system page size, so don't use mmap. */
|
||||
use_mmap_aligned_alloc = FALSE;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
|
||||
/* If Ruby's heap pages are not a multiple of the system page size, we
|
||||
* cannot use mprotect for the read barrier, so we must disable automatic
|
||||
@ -3238,6 +3224,20 @@ Init_heap(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_MMAP) && !HAVE_CONST_PAGE_SIZE && !defined(PAGE_MAX_SIZE)
|
||||
/* Need to determine if we can use mmap at runtime. */
|
||||
# ifdef PAGE_SIZE
|
||||
/* If the PAGE_SIZE macro can be used. */
|
||||
use_mmap_aligned_alloc = PAGE_SIZE <= HEAP_PAGE_SIZE;
|
||||
# elif defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
|
||||
/* If we can use sysconf to determine the page size. */
|
||||
use_mmap_aligned_alloc = pagesize <= HEAP_PAGE_SIZE;
|
||||
# else
|
||||
/* Otherwise we can't determine the system page size, so don't use mmap. */
|
||||
use_mmap_aligned_alloc = FALSE;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
objspace->next_object_id = INT2FIX(OBJ_ID_INITIAL);
|
||||
objspace->id_to_obj_tbl = st_init_table(&object_id_hash_type);
|
||||
objspace->obj_to_id_tbl = st_init_numtable();
|
||||
|
Loading…
x
Reference in New Issue
Block a user