diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2014-03-30 11:24:12 +0400 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2014-03-30 11:24:12 +0400 |
commit | 5a4bcb2aa28f7af312922b1ecbb2f729c94caab1 (patch) | |
tree | 9a8ca423774aef14a795fdd8c68c00db86cc9b0d /headers.c | |
parent | ff6c3d9fb8e7065ffe74cb780b2c1f54868152e2 (diff) | |
download | bdwgc-5a4bcb2aa28f7af312922b1ecbb2f729c94caab1.tar.gz |
Define ROUNDUP_PAGESIZE, ROUNDUP_GRANULE_SIZE macros (code refactoring)
* alloc.c (GC_expand_hp_inner): Use ROUNDUP_PAGESIZE().
* checksums.c (GC_record_fault, GC_was_faulted): Likewise.
* os_dep.c (GC_unix_mmap_get_mem, GC_wince_get_mem, GC_unmap_start,
GC_remove_protection): Likewise.
* headers.c (GC_scratch_alloc): Use ROUNDUP_GRANULE_SIZE().
* malloc.c (GC_alloc_large): Likewise.
* mallocx.c (GC_malloc_many): Likewise.
* headers.c (GC_scratch_alloc): Use ROUNDUP_PAGESIZE() (only if
USE_MMAP).
* include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDUP_PAGESIZE):
Define macro to round up a value to a multiple of a granule or a page,
respectively.
Diffstat (limited to 'headers.c')
-rw-r--r-- | headers.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -119,8 +119,7 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes) { register ptr_t result = scratch_free_ptr; - bytes += GRANULE_BYTES-1; - bytes &= ~(GRANULE_BYTES-1); + bytes = ROUNDUP_GRANULE_SIZE(bytes); scratch_free_ptr += bytes; if ((word)scratch_free_ptr <= (word)GC_scratch_end_ptr) { return(result); @@ -132,8 +131,7 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes) /* Undo the damage, and get memory directly */ bytes_to_get = bytes; # ifdef USE_MMAP - bytes_to_get += GC_page_size - 1; - bytes_to_get &= ~(GC_page_size - 1); + bytes_to_get = ROUNDUP_PAGESIZE(bytes_to_get); # endif result = (ptr_t)GET_MEM(bytes_to_get); GC_add_to_our_memory(result, bytes_to_get); @@ -148,8 +146,7 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes) scratch_free_ptr -= bytes; bytes_to_get = bytes; # ifdef USE_MMAP - bytes_to_get += GC_page_size - 1; - bytes_to_get &= ~(GC_page_size - 1); + bytes_to_get = ROUNDUP_PAGESIZE(bytes_to_get); # endif result = (ptr_t)GET_MEM(bytes_to_get); GC_add_to_our_memory(result, bytes_to_get); |