(a cherry-pick of commit
4c0e58d from 'unity-release-7_4-incremental')
* alloc.c (min_bytes_allocd_minimum): New static variable.
* alloc.c (GC_set_min_bytes_allocd, GC_get_min_bytes_allocd): New API
function definition (to set/get min_bytes_allocd_minimum).
* alloc.c (min_bytes_allocd): Return min_bytes_allocd_minimum if
result is less than min_bytes_allocd_minimum.
* include/gc.h (GC_set_min_bytes_allocd, GC_get_min_bytes_allocd): New
API function declaration.
* tests/test.c [GC_PTHREADS] (main): Call GC_set_min_bytes_allocd()
and GC_get_min_bytes_allocd().
GC_INNER word GC_total_stacksize = 0; /* updated on every push_all_stacks */
#endif
+static size_t min_bytes_allocd_minimum = 1;
+ /* The lowest value returned by min_bytes_allocd(). */
+
+GC_API void GC_CALL GC_set_min_bytes_allocd(size_t value)
+{
+ GC_ASSERT(value > 0);
+ min_bytes_allocd_minimum = value;
+}
+
+GC_API size_t GC_CALL GC_get_min_bytes_allocd(void)
+{
+ return min_bytes_allocd_minimum;
+}
+
/* Return the minimum number of bytes that must be allocated between */
/* collections to amortize the collection cost. Should be non-zero. */
static word min_bytes_allocd(void)
if (GC_incremental) {
result /= 2;
}
- return result > 0 ? result : 1;
+ return result > min_bytes_allocd_minimum
+ ? result : min_bytes_allocd_minimum;
}
STATIC word GC_non_gc_bytes_at_gc = 0;
/* use or need synchronization (i.e. acquiring the allocator lock). */
GC_API int GC_CALL GC_get_pages_executable(void);
+/* The setter and getter of the minimum value returned by the internal */
+/* min_bytes_allocd(). The value should not be zero; the default value */
+/* is one. Not synchronized. */
+GC_API void GC_CALL GC_set_min_bytes_allocd(size_t);
+GC_API size_t GC_CALL GC_get_min_bytes_allocd(void);
+
/* Overrides the default handle-fork mode. Non-zero value means GC */
/* should install proper pthread_atfork handlers. Has effect only if */
/* called before GC_INIT. Clients should invoke GC_set_handle_fork */
"Emulating dirty bits with mprotect/signals\n");
}
# endif
+ GC_set_min_bytes_allocd(1);
+ if (GC_get_min_bytes_allocd() != 1)
+ FAIL;
GC_set_warn_proc(warn_proc);
if ((code = pthread_key_create(&fl_key, 0)) != 0) {
GC_printf("Key creation failed %d\n", code);