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:
Jason Evans
2015-07-23 13:56:25 -07:00
parent e475ff1600
commit 5fae7dc1b3
18 changed files with 224 additions and 494 deletions

View File

@@ -61,7 +61,7 @@ timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen)
int n;
/* Whole. */
n = malloc_snprintf(&buf[i], buflen-i, "%"PRIu64, t0 / t1);
n = malloc_snprintf(&buf[i], buflen-i, "%"FMTu64, t0 / t1);
i += n;
if (i >= buflen)
return;
@@ -78,7 +78,7 @@ timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen)
uint64_t round = (i+1 == buflen-1 && ((t0 * mult * 10 / t1) % 10
>= 5)) ? 1 : 0;
n = malloc_snprintf(&buf[i], buflen-i,
"%"PRIu64, (t0 * mult / t1) % 10 + round);
"%"FMTu64, (t0 * mult / t1) % 10 + round);
i += n;
mult *= 10;
}