diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-10-28 09:23:51 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-10-28 21:21:45 +0300 |
commit | d4c81638d9087f5c344b0e86de6b2b3827c84f58 (patch) | |
tree | 5a18846c33701c8346d98fcd4066916f92876f66 /tests | |
parent | a37cdaa3b7a0c1ac4acc9213bb0a5fa4b4f852e9 (diff) | |
download | bdwgc-d4c81638d9087f5c344b0e86de6b2b3827c84f58.tar.gz |
Define public GC_[p]valloc() and redirect to them in leak_detector.h
Issue #495 (bdwgc).
* doc/README.macros (GC_NO_VALLOC): Document.
* doc/leak.md: Mention GNU valloc and pvalloc functions.
* include/gc/gc.h (GC_memalign): Remove comment that it is not tested;
add comment describing the functionality and a note.
* include/gc/gc.h [!GC_NO_VALLOC] (GC_valloc, GC_pvalloc): Declare
new API function.
* include/gc/leak_detector.h [!GC_NO_VALLOC] (valloc, pvalloc):
Redefine to the corresponding GC_ function.
* include/private/gc_priv.h (GC_page_size): Add comment.
* include/private/gc_priv.h (GC_real_page_size): Declare new variable
(or as a macro).
* include/private/gcconfig.h [NACL] (GETPAGESIZE): Add TODO item.
* mallocx.c (GC_memalign): Likewise.
* tests/gctest.c (run_one_test): Likewise.
* include/private/gcconfig.h [CYGWIN32 && (MPROTECT_VDB || USE_MUNMAP)
|| !MSWIN32 && !MSWINCE && !CYGWIN32 && (GC_DISABLE_INCREMENTAL
|| DEFAULT_VDB) && !USE_MMAP] (ALT_PAGESIZE_USED): Define macro.
* include/private/gcconfig.h [CYGWIN32 && (MPROTECT_VDB || USE_MUNMAP)
|| !MSWIN32 && !MSWINCE && !CYGWIN32 && (GC_DISABLE_INCREMENTAL
|| DEFAULT_VDB) && !USE_MMAP && !GC_NO_VALLOC] (REAL_PAGESIZE_NEEDED):
Likewise.
* mallocx.c (GC_strdup): Reformat comment.
* mallocx.c [!GC_NO_VALLOC] (GC_valloc, GC_pvalloc): Implement.
* os_dep.c [REAL_PAGESIZE_NEEDED] (GC_real_page_size): Define variable.
* os_dep.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_setpagesize): Replace
CYGWIN32&&(MPROTECT_VDB||USE_MUNMAP) to ALT_PAGESIZE_USED; remove
comment that a separate variable could be added; reformat comment;
assert about GC_pagesize only if REAL_PAGESIZE_NEEDED.
* os_dep.c [ALT_PAGESIZE_USED && REAL_PAGESIZE_NEEDED]
(GC_setpagesize): Set GC_real_page_size.
* os_dep.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_setpagesize):
Replace MPROTECT_VDB||PROC_VDB||SOFT_VDB||USE_MMAP to
!ALT_PAGESIZE_USED.
* tests/gctest.c [!GC_NO_VALLOC] (run_one_test): Call GC_valloc() and
GC_pvalloc().
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gctest.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/gctest.c b/tests/gctest.c index aefbaf93..86b448fe 100644 --- a/tests/gctest.c +++ b/tests/gctest.c @@ -1542,11 +1542,25 @@ void run_one_test(void) (void)GC_malloc(17); AO_fetch_and_add1(&collectable_count); + /* TODO: GC_memalign and friends are not tested well. */ for (i = sizeof(GC_word); i < 512; i *= 2) { GC_word result = (GC_word) GC_memalign(i, 17); if (result % i != 0 || result == 0 || *(int *)result != 0) FAIL; } } +# ifndef GC_NO_VALLOC + { + void *p = GC_valloc(78); + + if (NULL == p || ((GC_word)p & 0x1ff /* at least */) != 0 + || *(int *)p != 0) + FAIL; + p = GC_pvalloc(123); + /* Note: cannot check GC_size() result. */ + if (NULL == p || ((GC_word)p & 0x1ff) != 0 || *(int *)p != 0) + FAIL; + } +# endif # ifndef ALL_INTERIOR_POINTERS # if defined(POWERPC) if (!TEST_FAIL_COUNT(1)) |