module rt.gc.cdgc.opts;
+//debug = PRINTF;
+
import cstdlib = tango.stdc.stdlib;
import cstring = tango.stdc.string;
import cerrno = tango.stdc.errno;
+debug (PRINTF) import tango.stdc.stdio: printf;
private:
bool conservative = false;
bool fork = true;
bool eager_alloc = true;
- uint min_free = 15; // percent of the heap (0-100)
+ uint min_free = 5; // percent of the heap (0-100)
size_t prealloc_psize = 0;
size_t prealloc_npools = 0;
}
package Options options;
+debug (PRINTF)
+void print_options()
+{
+ int b(bool v) { return v; }
+ with (options)
+ printf("rt.gc.cdgc.opts: verbose=%u, log_file='%s', "
+ "malloc_stats_file='%s', collect_stats_file='%s', sentinel=%d, "
+ "mem_stomp=%d, conservative=%d, fork=%d, eager_alloc=%d, "
+ "early_collect=%d, min_free=%u, prealloc_psize=%lu, "
+ "prealloc_npools=%lu\n", verbose, log_file.ptr,
+ malloc_stats_file.ptr, collect_stats_file.ptr, b(sentinel),
+ b(mem_stomp), b(conservative), b(fork), b(eager_alloc),
+ b(early_collect), min_free, prealloc_psize, prealloc_npools);
+}
+
+
bool cstr_eq(char* s1, char* s2)
{
return cstring.strcmp(s1, s2) == 0;
opt_value[0] = '\0';
char* curr = opt_name.ptr;
size_t i = 0;
- if (opts_string is null)
+ if (opts_string is null) {
+ debug (PRINTF) printf("rt.gc.cdgc.opts: no options overriden\n");
return;
+ }
for (; *opts_string != '\0'; opts_string++)
{
char c = *opts_string;
i--;
curr[i] = '\0';
process_option(opt_name.ptr, opt_value.ptr);
+ debug (PRINTF) print_options();
}
assert (eager_alloc == true);
assert (prealloc_psize == 0);
assert (prealloc_npools == 0);
- assert (min_free == 15);
+ assert (min_free == 5);
}
parse("mem_stomp");
with (options) {
assert (eager_alloc == true);
assert (prealloc_psize == 0);
assert (prealloc_npools == 0);
- assert (min_free == 15);
+ assert (min_free == 5);
}
parse("mem_stomp=0:verbose=2:conservative:fork=0:eager_alloc=0");
with (options) {
assert (eager_alloc == false);
assert (prealloc_psize == 0);
assert (prealloc_npools == 0);
- assert (min_free == 15);
+ assert (min_free == 5);
}
parse("log_file=12345 67890:verbose=1:sentinel=4:mem_stomp=1");
with (options) {
assert (eager_alloc == false);
assert (prealloc_psize == 0);
assert (prealloc_npools == 0);
+ assert (min_free == 5);
}
parse("pre_alloc:min_free=30");
with (options) {