mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 21:23:06 +00:00
Fix MinGW-related portability issues.
Create and use FMT* macros that are equivalent to the PRI* macros that inttypes.h defines. This allows uniform use of the Unix-specific format specifiers, e.g. "%zu", as well as avoiding Windows-specific definitions of e.g. PRIu64. Add ffs()/ffsl() support for compiling with gcc. Extract compatibility definitions of ENOENT, EINVAL, EAGAIN, EPERM, ENOMEM, and ENORANGE into include/msvc_compat/windows_extra.h and use the file for tests as well as for core jemalloc code.
This commit is contained in:
@@ -35,15 +35,15 @@ TEST_BEGIN(test_count_insert_search_remove)
|
||||
assert_false(ckh_new(tsd, &ckh, 2, ckh_string_hash, ckh_string_keycomp),
|
||||
"Unexpected ckh_new() error");
|
||||
assert_zu_eq(ckh_count(&ckh), 0,
|
||||
"ckh_count() should return %"PRIzu", but it returned %"PRIzu, ZU(0),
|
||||
"ckh_count() should return %zu, but it returned %zu", ZU(0),
|
||||
ckh_count(&ckh));
|
||||
|
||||
/* Insert. */
|
||||
for (i = 0; i < sizeof(strs)/sizeof(const char *); i++) {
|
||||
ckh_insert(tsd, &ckh, strs[i], strs[i]);
|
||||
assert_zu_eq(ckh_count(&ckh), i+1,
|
||||
"ckh_count() should return %"PRIzu", but it returned "
|
||||
"%"PRIzu, i+1, ckh_count(&ckh));
|
||||
"ckh_count() should return %zu, but it returned %zu", i+1,
|
||||
ckh_count(&ckh));
|
||||
}
|
||||
|
||||
/* Search. */
|
||||
@@ -64,10 +64,10 @@ TEST_BEGIN(test_count_insert_search_remove)
|
||||
|
||||
ks = (i & 1) ? strs[i] : (const char *)NULL;
|
||||
vs = (i & 2) ? strs[i] : (const char *)NULL;
|
||||
assert_ptr_eq((void *)ks, (void *)k.s,
|
||||
"Key mismatch, i=%"PRIzu, i);
|
||||
assert_ptr_eq((void *)vs, (void *)v.s,
|
||||
"Value mismatch, i=%"PRIzu, i);
|
||||
assert_ptr_eq((void *)ks, (void *)k.s, "Key mismatch, i=%zu",
|
||||
i);
|
||||
assert_ptr_eq((void *)vs, (void *)v.s, "Value mismatch, i=%zu",
|
||||
i);
|
||||
}
|
||||
assert_true(ckh_search(&ckh, missing, NULL, NULL),
|
||||
"Unexpected ckh_search() success");
|
||||
@@ -90,14 +90,14 @@ TEST_BEGIN(test_count_insert_search_remove)
|
||||
|
||||
ks = (i & 1) ? strs[i] : (const char *)NULL;
|
||||
vs = (i & 2) ? strs[i] : (const char *)NULL;
|
||||
assert_ptr_eq((void *)ks, (void *)k.s,
|
||||
"Key mismatch, i=%"PRIzu, i);
|
||||
assert_ptr_eq((void *)vs, (void *)v.s,
|
||||
"Value mismatch, i=%"PRIzu, i);
|
||||
assert_ptr_eq((void *)ks, (void *)k.s, "Key mismatch, i=%zu",
|
||||
i);
|
||||
assert_ptr_eq((void *)vs, (void *)v.s, "Value mismatch, i=%zu",
|
||||
i);
|
||||
assert_zu_eq(ckh_count(&ckh),
|
||||
sizeof(strs)/sizeof(const char *) - i - 1,
|
||||
"ckh_count() should return %"PRIzu", but it returned "
|
||||
"%"PRIzu, sizeof(strs)/sizeof(const char *) - i - 1,
|
||||
"ckh_count() should return %zu, but it returned %zu",
|
||||
sizeof(strs)/sizeof(const char *) - i - 1,
|
||||
ckh_count(&ckh));
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ TEST_BEGIN(test_insert_iter_remove)
|
||||
}
|
||||
|
||||
assert_zu_eq(ckh_count(&ckh), NITEMS,
|
||||
"ckh_count() should return %"PRIzu", but it returned "
|
||||
"%"PRIzu, NITEMS, ckh_count(&ckh));
|
||||
"ckh_count() should return %zu, but it returned %zu",
|
||||
NITEMS, ckh_count(&ckh));
|
||||
|
||||
for (j = i + 1; j < NITEMS; j++) {
|
||||
assert_false(ckh_search(&ckh, p[j], NULL, NULL),
|
||||
@@ -167,20 +167,17 @@ TEST_BEGIN(test_insert_iter_remove)
|
||||
for (k = 0; k < NITEMS; k++) {
|
||||
if (p[k] == q) {
|
||||
assert_false(seen[k],
|
||||
"Item %"PRIzu" already "
|
||||
"seen", k);
|
||||
"Item %zu already seen", k);
|
||||
seen[k] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < i + 1; j++) {
|
||||
assert_true(seen[j], "Item %"PRIzu" not seen",
|
||||
j);
|
||||
}
|
||||
for (j = 0; j < i + 1; j++)
|
||||
assert_true(seen[j], "Item %zu not seen", j);
|
||||
for (; j < NITEMS; j++)
|
||||
assert_false(seen[j], "Item %"PRIzu" seen", j);
|
||||
assert_false(seen[j], "Item %zu seen", j);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +196,7 @@ TEST_BEGIN(test_insert_iter_remove)
|
||||
}
|
||||
|
||||
assert_zu_eq(ckh_count(&ckh), 0,
|
||||
"ckh_count() should return %"PRIzu", but it returned %"PRIzu,
|
||||
"ckh_count() should return %zu, but it returned %zu",
|
||||
ZU(0), ckh_count(&ckh));
|
||||
ckh_delete(tsd, &ckh);
|
||||
#undef NITEMS
|
||||
|
||||
Reference in New Issue
Block a user