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:
@@ -8,7 +8,7 @@ struct p##_test_s { \
|
||||
}; \
|
||||
typedef struct p##_test_s p##_test_t;
|
||||
|
||||
#define TEST_BODY(p, t, tc, ta, PRI) do { \
|
||||
#define TEST_BODY(p, t, tc, ta, FMT) do { \
|
||||
const p##_test_t tests[] = { \
|
||||
{(t)-1, (t)-1, (t)-2}, \
|
||||
{(t)-1, (t) 0, (t)-2}, \
|
||||
@@ -38,7 +38,7 @@ typedef struct p##_test_s p##_test_t;
|
||||
\
|
||||
assert_##ta##_eq(atomic_add_##p(&accum, tests[i].x), \
|
||||
(t)((tc)tests[i].accum0 + (tc)tests[i].x), \
|
||||
"i=%u, accum=%"PRI", x=%"PRI, \
|
||||
"i=%u, accum=%"FMT", x=%"FMT, \
|
||||
i, tests[i].accum0, tests[i].x); \
|
||||
assert_##ta##_eq(atomic_read_##p(&accum), accum, \
|
||||
"Erroneous add, i=%u", i); \
|
||||
@@ -46,7 +46,7 @@ typedef struct p##_test_s p##_test_t;
|
||||
accum = tests[i].accum0; \
|
||||
assert_##ta##_eq(atomic_sub_##p(&accum, tests[i].x), \
|
||||
(t)((tc)tests[i].accum0 - (tc)tests[i].x), \
|
||||
"i=%u, accum=%"PRI", x=%"PRI, \
|
||||
"i=%u, accum=%"FMT", x=%"FMT, \
|
||||
i, tests[i].accum0, tests[i].x); \
|
||||
assert_##ta##_eq(atomic_read_##p(&accum), accum, \
|
||||
"Erroneous sub, i=%u", i); \
|
||||
@@ -72,7 +72,7 @@ TEST_BEGIN(test_atomic_uint64)
|
||||
#if !(LG_SIZEOF_PTR == 3 || LG_SIZEOF_INT == 3)
|
||||
test_skip("64-bit atomic operations not supported");
|
||||
#else
|
||||
TEST_BODY(uint64, uint64_t, uint64_t, u64, PRIx64);
|
||||
TEST_BODY(uint64, uint64_t, uint64_t, u64, FMTx64);
|
||||
#endif
|
||||
}
|
||||
TEST_END
|
||||
@@ -81,7 +81,7 @@ TEST_STRUCT(uint32, uint32_t)
|
||||
TEST_BEGIN(test_atomic_uint32)
|
||||
{
|
||||
|
||||
TEST_BODY(uint32, uint32_t, uint32_t, u32, "#"PRIx32);
|
||||
TEST_BODY(uint32, uint32_t, uint32_t, u32, "#"FMTx32);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
@@ -97,7 +97,7 @@ TEST_STRUCT(z, size_t)
|
||||
TEST_BEGIN(test_atomic_z)
|
||||
{
|
||||
|
||||
TEST_BODY(z, size_t, size_t, zu, "#"PRIzx);
|
||||
TEST_BODY(z, size_t, size_t, zu, "#zx");
|
||||
}
|
||||
TEST_END
|
||||
|
||||
|
||||
Reference in New Issue
Block a user