diff options
author | Nobuyoshi Nakada <[email protected]> | 2021-05-06 12:09:57 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2021-05-06 12:10:58 +0900 |
commit | f941dd5a9f80616fc1461625bead4774da8ab9ae (patch) | |
tree | c51b536d086fd1de05b0293fc1ec4cbbbedc4835 /gc.c | |
parent | 0dd9ac7721fe2754670b7b30aaed33e95f6ca7d1 (diff) |
Reuse sysconf result
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -3213,6 +3213,17 @@ Init_heap(void) { rb_objspace_t *objspace = &rb_objspace; +#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 + * compaction. */ + int pagesize; + pagesize = (int)sysconf(_SC_PAGE_SIZE); + if ((HEAP_PAGE_SIZE % pagesize) != 0) { + ruby_enable_autocompact = 0; + } +#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 @@ -3220,24 +3231,13 @@ Init_heap(void) 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; + 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 -#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 - * compaction. */ - int pagesize; - pagesize = (int)sysconf(_SC_PAGE_SIZE); - if ((HEAP_PAGE_SIZE % pagesize) != 0) { - ruby_enable_autocompact = 0; - } -#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(); |