[PATCH] Replace %z in format strings with configure-time determined printf length modifier

Mike Hommey mh+jemalloc at glandium.org
Wed Apr 11 05:27:27 PDT 2012


From: Mike Hommey <mh at glandium.org>

---
 configure.ac                        |   14 +++++++++
 include/jemalloc/jemalloc_defs.h.in |    8 ++++++
 src/prof.c                          |    2 +-
 src/stats.c                         |   54 +++++++++++++++++------------------
 test/aligned_alloc.c                |   14 ++++-----
 test/allocm.c                       |   22 +++++++-------
 test/mremap.c                       |    6 ++--
 test/posix_memalign.c               |   14 ++++-----
 test/rallocm.c                      |   16 +++++------
 9 files changed, 86 insertions(+), 64 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8e94b5c..d6fa40b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,6 +168,20 @@ else
 fi
 AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T])
 
+AC_CHECK_SIZEOF([size_t])
+if test "x${ac_cv_sizeof_size_t}" = "x4" ; then
+  PRI_z=""
+elif test "x${ac_cv_sizeof_size_t}" = "x8" ; then
+  if test "x${ac_cv_sizeof_long}" = "x4" ; then
+    PRI_z="ll"
+  else
+    PRI_z="l"
+  fi
+else
+  AC_MSG_ERROR([Unsupported size_t size: ${ac_cv_sizeof_size_t}])
+fi
+AC_DEFINE_UNQUOTED([PRI_z], ["$PRI_z"])
+
 AC_CANONICAL_HOST
 dnl CPU-specific settings.
 CPU_SPINWAIT=""
diff --git a/include/jemalloc/jemalloc_defs.h.in b/include/jemalloc/jemalloc_defs.h.in
index 8e7442d..5bfd7fa 100644
--- a/include/jemalloc/jemalloc_defs.h.in
+++ b/include/jemalloc/jemalloc_defs.h.in
@@ -215,3 +215,11 @@
 
 /* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */
 #undef LG_SIZEOF_INTMAX_T
+
+/* Length modifier to use in printf for size_t */
+#undef PRI_z
+
+/* Macros similar to inttypes.h's PRI* macros, for size_t */
+#define PRIuz PRI_z "u"
+#define PRIdz PRI_z "d"
+#define PRIxz PRI_z "x"
diff --git a/src/prof.c b/src/prof.c
index b509aae..7fa228e 100644
--- a/src/prof.c
+++ b/src/prof.c
@@ -899,7 +899,7 @@ prof_dump(bool propagate_err, const char *filename, bool leakcheck)
 
 	if (leakcheck && cnt_all.curbytes != 0) {
 		malloc_printf("<jemalloc>: Leak summary: %"PRId64" byte%s, %"
-		    PRId64" object%s, %zu context%s\n",
+		    PRId64" object%s, %"PRIuz" context%s\n",
 		    cnt_all.curbytes, (cnt_all.curbytes != 1) ? "s" : "",
 		    cnt_all.curobjs, (cnt_all.curobjs != 1) ? "s" : "",
 		    leak_nctx, (leak_nctx != 1) ? "s" : "");
diff --git a/src/stats.c b/src/stats.c
index 0cd70b0..1e73b16 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -125,18 +125,18 @@ stats_arena_bins_print(void (*write_cb)(void *, const char *), void *cbopaque,
 			    size_t);
 			if (config_tcache) {
 				malloc_cprintf(write_cb, cbopaque,
-				    "%13u %5zu %4u %3zu %12zu %12"PRIu64
+				    "%13u %5"PRIuz" %4u %3"PRIuz" %12"PRIuz" %12"PRIu64
 				    " %12"PRIu64" %12"PRIu64" %12"PRIu64
 				    " %12"PRIu64" %12"PRIu64" %12"PRIu64
-				    " %12zu\n",
+				    " %12"PRIuz"\n",
 				    j, reg_size, nregs, run_size / page,
 				    allocated, nmalloc, ndalloc, nrequests,
 				    nfills, nflushes, nruns, reruns, curruns);
 			} else {
 				malloc_cprintf(write_cb, cbopaque,
-				    "%13u %5zu %4u %3zu %12zu %12"PRIu64
+				    "%13u %5"PRIuz" %4u %3"PRIuz" %12"PRIuz" %12"PRIu64
 				    " %12"PRIu64" %12"PRIu64" %12"PRIu64
-				    " %12zu\n",
+				    " %12"PRIuz"\n",
 				    j, reg_size, nregs, run_size / page,
 				    allocated, nmalloc, ndalloc, nruns, reruns,
 				    curruns);
@@ -186,19 +186,19 @@ stats_arena_lruns_print(void (*write_cb)(void *, const char *), void *cbopaque,
 			CTL_IJ_GET("stats.arenas.0.lruns.0.curruns", &curruns,
 			    size_t);
 			if (gap_start != -1) {
-				malloc_cprintf(write_cb, cbopaque, "[%zu]\n",
+				malloc_cprintf(write_cb, cbopaque, "[%"PRIuz"]\n",
 				    j - gap_start);
 				gap_start = -1;
 			}
 			malloc_cprintf(write_cb, cbopaque,
-			    "%13zu %5zu %12"PRIu64" %12"PRIu64" %12"PRIu64
-			    " %12zu\n",
+			    "%13"PRIuz" %5"PRIuz" %12"PRIu64" %12"PRIu64" %12"PRIu64
+			    " %12"PRIuz"\n",
 			    run_size, run_size / page, nmalloc, ndalloc,
 			    nrequests, curruns);
 		}
 	}
 	if (gap_start != -1)
-		malloc_cprintf(write_cb, cbopaque, "[%zu]\n", j - gap_start);
+		malloc_cprintf(write_cb, cbopaque, "[%"PRIuz"]\n", j - gap_start);
 }
 
 static void
@@ -224,7 +224,7 @@ stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque,
 	CTL_I_GET("stats.arenas.0.nmadvise", &nmadvise, uint64_t);
 	CTL_I_GET("stats.arenas.0.purged", &purged, uint64_t);
 	malloc_cprintf(write_cb, cbopaque,
-	    "dirty pages: %zu:%zu active:dirty, %"PRIu64" sweep%s,"
+	    "dirty pages: %"PRIuz":%"PRIuz" active:dirty, %"PRIu64" sweep%s,"
 	    " %"PRIu64" madvise%s, %"PRIu64" purged\n",
 	    pactive, pdirty, npurge, npurge == 1 ? "" : "s",
 	    nmadvise, nmadvise == 1 ? "" : "s", purged);
@@ -236,24 +236,24 @@ stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque,
 	CTL_I_GET("stats.arenas.0.small.ndalloc", &small_ndalloc, uint64_t);
 	CTL_I_GET("stats.arenas.0.small.nrequests", &small_nrequests, uint64_t);
 	malloc_cprintf(write_cb, cbopaque,
-	    "small:   %12zu %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
+	    "small:   %12"PRIuz" %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
 	    small_allocated, small_nmalloc, small_ndalloc, small_nrequests);
 	CTL_I_GET("stats.arenas.0.large.allocated", &large_allocated, size_t);
 	CTL_I_GET("stats.arenas.0.large.nmalloc", &large_nmalloc, uint64_t);
 	CTL_I_GET("stats.arenas.0.large.ndalloc", &large_ndalloc, uint64_t);
 	CTL_I_GET("stats.arenas.0.large.nrequests", &large_nrequests, uint64_t);
 	malloc_cprintf(write_cb, cbopaque,
-	    "large:   %12zu %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
+	    "large:   %12"PRIuz" %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
 	    large_allocated, large_nmalloc, large_ndalloc, large_nrequests);
 	malloc_cprintf(write_cb, cbopaque,
-	    "total:   %12zu %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
+	    "total:   %12"PRIuz" %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
 	    small_allocated + large_allocated,
 	    small_nmalloc + large_nmalloc,
 	    small_ndalloc + large_ndalloc,
 	    small_nrequests + large_nrequests);
-	malloc_cprintf(write_cb, cbopaque, "active:  %12zu\n", pactive * page);
+	malloc_cprintf(write_cb, cbopaque, "active:  %12"PRIuz"\n", pactive * page);
 	CTL_I_GET("stats.arenas.0.mapped", &mapped, size_t);
-	malloc_cprintf(write_cb, cbopaque, "mapped:  %12zu\n", mapped);
+	malloc_cprintf(write_cb, cbopaque, "mapped:  %12"PRIuz"\n", mapped);
 
 	if (bins)
 		stats_arena_bins_print(write_cb, cbopaque, i);
@@ -360,13 +360,13 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
 		if ((err = je_mallctl("opt."#n, &sv, &ssz, NULL, 0))	\
 		    == 0) {						\
 			malloc_cprintf(write_cb, cbopaque,		\
-			"  opt."#n": %zu\n", sv);			\
+			"  opt."#n": %"PRIuz"\n", sv);			\
 		}
 #define OPT_WRITE_SSIZE_T(n)						\
 		if ((err = je_mallctl("opt."#n, &ssv, &sssz, NULL, 0))	\
 		    == 0) {						\
 			malloc_cprintf(write_cb, cbopaque,		\
-			    "  opt."#n": %zd\n", ssv);			\
+			    "  opt."#n": %"PRIdz"\n", ssv);			\
 		}
 #define OPT_WRITE_CHAR_P(n)						\
 		if ((err = je_mallctl("opt."#n, &cpv, &cpsz, NULL, 0))	\
@@ -406,14 +406,14 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
 		CTL_GET("arenas.narenas", &uv, unsigned);
 		malloc_cprintf(write_cb, cbopaque, "Max arenas: %u\n", uv);
 
-		malloc_cprintf(write_cb, cbopaque, "Pointer size: %zu\n",
+		malloc_cprintf(write_cb, cbopaque, "Pointer size: %"PRIuz"\n",
 		    sizeof(void *));
 
 		CTL_GET("arenas.quantum", &sv, size_t);
-		malloc_cprintf(write_cb, cbopaque, "Quantum size: %zu\n", sv);
+		malloc_cprintf(write_cb, cbopaque, "Quantum size: %"PRIuz"\n", sv);
 
 		CTL_GET("arenas.page", &sv, size_t);
-		malloc_cprintf(write_cb, cbopaque, "Page size: %zu\n", sv);
+		malloc_cprintf(write_cb, cbopaque, "Page size: %"PRIuz"\n", sv);
 
 		CTL_GET("opt.lg_dirty_mult", &ssv, ssize_t);
 		if (ssv >= 0) {
@@ -427,20 +427,20 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
 		if ((err = je_mallctl("arenas.tcache_max", &sv, &ssz, NULL, 0))
 		    == 0) {
 			malloc_cprintf(write_cb, cbopaque,
-			    "Maximum thread-cached size class: %zu\n", sv);
+			    "Maximum thread-cached size class: %"PRIuz"\n", sv);
 		}
 		if ((err = je_mallctl("opt.prof", &bv, &bsz, NULL, 0)) == 0 &&
 		    bv) {
 			CTL_GET("opt.lg_prof_sample", &sv, size_t);
 			malloc_cprintf(write_cb, cbopaque,
 			    "Average profile sample interval: %"PRIu64
-			    " (2^%zu)\n", (((uint64_t)1U) << sv), sv);
+			    " (2^%"PRIuz")\n", (((uint64_t)1U) << sv), sv);
 
 			CTL_GET("opt.lg_prof_interval", &ssv, ssize_t);
 			if (ssv >= 0) {
 				malloc_cprintf(write_cb, cbopaque,
 				    "Average profile dump interval: %"PRIu64
-				    " (2^%zd)\n",
+				    " (2^%"PRIdz")\n",
 				    (((uint64_t)1U) << ssv), ssv);
 			} else {
 				write_cb(cbopaque,
@@ -448,7 +448,7 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
 			}
 		}
 		CTL_GET("opt.lg_chunk", &sv, size_t);
-		malloc_cprintf(write_cb, cbopaque, "Chunk size: %zu (2^%zu)\n",
+		malloc_cprintf(write_cb, cbopaque, "Chunk size: %"PRIuz" (2^%"PRIuz")\n",
 		    (ZU(1) << sv), sv);
 	}
 
@@ -465,10 +465,10 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
 		CTL_GET("stats.active", &active, size_t);
 		CTL_GET("stats.mapped", &mapped, size_t);
 		malloc_cprintf(write_cb, cbopaque,
-		    "Allocated: %zu, active: %zu, mapped: %zu\n",
+		    "Allocated: %"PRIuz", active: %"PRIuz", mapped: %"PRIuz"\n",
 		    allocated, active, mapped);
 		malloc_cprintf(write_cb, cbopaque,
-		    "Current active ceiling: %zu\n", atomic_read_z(cactive));
+		    "Current active ceiling: %"PRIuz"\n", atomic_read_z(cactive));
 
 		/* Print chunk stats. */
 		CTL_GET("stats.chunks.total", &chunks_total, uint64_t);
@@ -476,7 +476,7 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
 		CTL_GET("stats.chunks.current", &chunks_current, size_t);
 		malloc_cprintf(write_cb, cbopaque, "chunks: nchunks   "
 		    "highchunks    curchunks\n");
-		malloc_cprintf(write_cb, cbopaque, "  %13"PRIu64"%13zu%13zu\n",
+		malloc_cprintf(write_cb, cbopaque, "  %13"PRIu64"%13"PRIuz"%13"PRIuz"\n",
 		    chunks_total, chunks_high, chunks_current);
 
 		/* Print huge stats. */
@@ -486,7 +486,7 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
 		malloc_cprintf(write_cb, cbopaque,
 		    "huge: nmalloc      ndalloc    allocated\n");
 		malloc_cprintf(write_cb, cbopaque,
-		    " %12"PRIu64" %12"PRIu64" %12zu\n",
+		    " %12"PRIu64" %12"PRIu64" %12"PRIuz"\n",
 		    huge_nmalloc, huge_ndalloc, huge_allocated);
 
 		if (merged) {
diff --git a/test/aligned_alloc.c b/test/aligned_alloc.c
index 2a95604..8aa87ca 100644
--- a/test/aligned_alloc.c
+++ b/test/aligned_alloc.c
@@ -28,7 +28,7 @@ main(void)
 	p = aligned_alloc(alignment, 1);
 	if (p != NULL || errno != EINVAL) {
 		fprintf(stderr,
-		    "Expected error for invalid alignment %zu\n", alignment);
+		    "Expected error for invalid alignment %"PRIuz"\n", alignment);
 	}
 
 	for (alignment = sizeof(size_t); alignment < MAXALIGN;
@@ -37,7 +37,7 @@ main(void)
 		p = aligned_alloc(alignment + 1, 1);
 		if (p != NULL || errno != EINVAL) {
 			fprintf(stderr,
-			    "Expected error for invalid alignment %zu\n",
+			    "Expected error for invalid alignment %"PRIuz"\n",
 			    alignment + 1);
 		}
 	}
@@ -53,7 +53,7 @@ main(void)
 	p = aligned_alloc(alignment, size);
 	if (p != NULL || errno != ENOMEM) {
 		fprintf(stderr,
-		    "Expected error for aligned_alloc(%zu, %zu)\n",
+		    "Expected error for aligned_alloc(%"PRIuz", %"PRIuz")\n",
 		    alignment, size);
 	}
 
@@ -68,7 +68,7 @@ main(void)
 	p = aligned_alloc(alignment, size);
 	if (p != NULL || errno != ENOMEM) {
 		fprintf(stderr,
-		    "Expected error for aligned_alloc(%zu, %zu)\n",
+		    "Expected error for aligned_alloc(%"PRIuz", %"PRIuz")\n",
 		    alignment, size);
 	}
 
@@ -82,7 +82,7 @@ main(void)
 	p = aligned_alloc(alignment, size);
 	if (p != NULL || errno != ENOMEM) {
 		fprintf(stderr,
-		    "Expected error for aligned_alloc(&p, %zu, %zu)\n",
+		    "Expected error for aligned_alloc(&p, %"PRIuz", %"PRIuz")\n",
 		    alignment, size);
 	}
 
@@ -93,7 +93,7 @@ main(void)
 	    alignment <= MAXALIGN;
 	    alignment <<= 1) {
 		total = 0;
-		fprintf(stderr, "Alignment: %zu\n", alignment);
+		fprintf(stderr, "Alignment: %"PRIuz"\n", alignment);
 		for (size = 1;
 		    size < 3 * alignment && size < (1U << 31);
 		    size += (alignment >> (LG_SIZEOF_PTR-1)) - 1) {
@@ -101,7 +101,7 @@ main(void)
 				ps[i] = aligned_alloc(alignment, size);
 				if (ps[i] == NULL) {
 					fprintf(stderr,
-					    "Error for size %zu (%#zx): %s\n",
+					    "Error for size %"PRIuz" (%#"PRIxz"): %s\n",
 					    size, size, strerror(errno));
 					exit(1);
 				}
diff --git a/test/allocm.c b/test/allocm.c
index 3aa0fd2..4f8b908 100644
--- a/test/allocm.c
+++ b/test/allocm.c
@@ -77,14 +77,14 @@ main(void)
 	r = nallocm(&nsz, sz, ALLOCM_ALIGN(alignment));
 	if (r == ALLOCM_SUCCESS) {
 		fprintf(stderr,
-		    "Expected error for nallocm(&nsz, %zu, %#x)\n",
+		    "Expected error for nallocm(&nsz, %"PRIuz", %#x)\n",
 		    sz, ALLOCM_ALIGN(alignment));
 	}
 	rsz = 0;
 	r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
 	if (r == ALLOCM_SUCCESS) {
 		fprintf(stderr,
-		    "Expected error for allocm(&p, %zu, %#x)\n",
+		    "Expected error for allocm(&p, %"PRIuz", %#x)\n",
 		    sz, ALLOCM_ALIGN(alignment));
 	}
 	if (nsz != rsz)
@@ -105,7 +105,7 @@ main(void)
 	r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
 	if (r == ALLOCM_SUCCESS) {
 		fprintf(stderr,
-		    "Expected error for allocm(&p, %zu, %#x)\n",
+		    "Expected error for allocm(&p, %"PRIuz", %#x)\n",
 		    sz, ALLOCM_ALIGN(alignment));
 	}
 
@@ -119,14 +119,14 @@ main(void)
 	r = nallocm(&nsz, sz, ALLOCM_ALIGN(alignment));
 	if (r == ALLOCM_SUCCESS) {
 		fprintf(stderr,
-		    "Expected error for nallocm(&nsz, %zu, %#x)\n",
+		    "Expected error for nallocm(&nsz, %"PRIuz", %#x)\n",
 		    sz, ALLOCM_ALIGN(alignment));
 	}
 	rsz = 0;
 	r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
 	if (r == ALLOCM_SUCCESS) {
 		fprintf(stderr,
-		    "Expected error for allocm(&p, %zu, %#x)\n",
+		    "Expected error for allocm(&p, %"PRIuz", %#x)\n",
 		    sz, ALLOCM_ALIGN(alignment));
 	}
 	if (nsz != rsz)
@@ -139,7 +139,7 @@ main(void)
 	    alignment <= MAXALIGN;
 	    alignment <<= 1) {
 		total = 0;
-		fprintf(stderr, "Alignment: %zu\n", alignment);
+		fprintf(stderr, "Alignment: %"PRIuz"\n", alignment);
 		for (sz = 1;
 		    sz < 3 * alignment && sz < (1U << 31);
 		    sz += (alignment >> (LG_SIZEOF_PTR-1)) - 1) {
@@ -149,8 +149,8 @@ main(void)
 				    ALLOCM_ALIGN(alignment) | ALLOCM_ZERO);
 				if (r != ALLOCM_SUCCESS) {
 					fprintf(stderr,
-					    "nallocm() error for size %zu"
-					    " (%#zx): %d\n",
+					    "nallocm() error for size %"PRIuz""
+					    " (%#"PRIxz"): %d\n",
 					    sz, sz, r);
 					exit(1);
 				}
@@ -159,8 +159,8 @@ main(void)
 				    ALLOCM_ALIGN(alignment) | ALLOCM_ZERO);
 				if (r != ALLOCM_SUCCESS) {
 					fprintf(stderr,
-					    "allocm() error for size %zu"
-					    " (%#zx): %d\n",
+					    "allocm() error for size %"PRIuz""
+					    " (%#"PRIxz"): %d\n",
 					    sz, sz, r);
 					exit(1);
 				}
@@ -177,7 +177,7 @@ main(void)
 				if ((uintptr_t)p & (alignment-1)) {
 					fprintf(stderr,
 					    "%p inadequately aligned for"
-					    " alignment: %zu\n", p, alignment);
+					    " alignment: %"PRIuz"\n", p, alignment);
 				}
 				sallocm(ps[i], &rsz, 0);
 				total += rsz;
diff --git a/test/mremap.c b/test/mremap.c
index cac3bd8..969fc77 100644
--- a/test/mremap.c
+++ b/test/mremap.c
@@ -28,7 +28,7 @@ main(void)
 
 	p = (char *)malloc(chunksize);
 	if (p == NULL) {
-		fprintf(stderr, "malloc(%zu) --> %p\n", chunksize, p);
+		fprintf(stderr, "malloc(%"PRIuz") --> %p\n", chunksize, p);
 		ret = 1;
 		goto label_return;
 	}
@@ -36,7 +36,7 @@ main(void)
 
 	q = (char *)realloc(p, chunksize * 2);
 	if (q == NULL) {
-		fprintf(stderr, "realloc(%p, %zu) --> %p\n", p, chunksize * 2,
+		fprintf(stderr, "realloc(%p, %"PRIuz") --> %p\n", p, chunksize * 2,
 		    q);
 		ret = 1;
 		goto label_return;
@@ -49,7 +49,7 @@ main(void)
 
 	q = (char *)realloc(p, chunksize);
 	if (q == NULL) {
-		fprintf(stderr, "realloc(%p, %zu) --> %p\n", p, chunksize, q);
+		fprintf(stderr, "realloc(%p, %"PRIuz") --> %p\n", p, chunksize, q);
 		ret = 1;
 		goto label_return;
 	}
diff --git a/test/posix_memalign.c b/test/posix_memalign.c
index 0ea35c8..f096fd2 100644
--- a/test/posix_memalign.c
+++ b/test/posix_memalign.c
@@ -28,7 +28,7 @@ main(void)
 		err = posix_memalign(&p, alignment, 1);
 		if (err != EINVAL) {
 			fprintf(stderr,
-			    "Expected error for invalid alignment %zu\n",
+			    "Expected error for invalid alignment %"PRIuz"\n",
 			    alignment);
 		}
 	}
@@ -38,7 +38,7 @@ main(void)
 		err = posix_memalign(&p, alignment + 1, 1);
 		if (err == 0) {
 			fprintf(stderr,
-			    "Expected error for invalid alignment %zu\n",
+			    "Expected error for invalid alignment %"PRIuz"\n",
 			    alignment + 1);
 		}
 	}
@@ -53,7 +53,7 @@ main(void)
 	err = posix_memalign(&p, alignment, size);
 	if (err == 0) {
 		fprintf(stderr,
-		    "Expected error for posix_memalign(&p, %zu, %zu)\n",
+		    "Expected error for posix_memalign(&p, %"PRIuz", %"PRIuz")\n",
 		    alignment, size);
 	}
 
@@ -67,7 +67,7 @@ main(void)
 	err = posix_memalign(&p, alignment, size);
 	if (err == 0) {
 		fprintf(stderr,
-		    "Expected error for posix_memalign(&p, %zu, %zu)\n",
+		    "Expected error for posix_memalign(&p, %"PRIuz", %"PRIuz")\n",
 		    alignment, size);
 	}
 
@@ -80,7 +80,7 @@ main(void)
 	err = posix_memalign(&p, alignment, size);
 	if (err == 0) {
 		fprintf(stderr,
-		    "Expected error for posix_memalign(&p, %zu, %zu)\n",
+		    "Expected error for posix_memalign(&p, %"PRIuz", %"PRIuz")\n",
 		    alignment, size);
 	}
 
@@ -91,7 +91,7 @@ main(void)
 	    alignment <= MAXALIGN;
 	    alignment <<= 1) {
 		total = 0;
-		fprintf(stderr, "Alignment: %zu\n", alignment);
+		fprintf(stderr, "Alignment: %"PRIuz"\n", alignment);
 		for (size = 1;
 		    size < 3 * alignment && size < (1U << 31);
 		    size += (alignment >> (LG_SIZEOF_PTR-1)) - 1) {
@@ -100,7 +100,7 @@ main(void)
 				    alignment, size);
 				if (err) {
 					fprintf(stderr,
-					    "Error for size %zu (%#zx): %s\n",
+					    "Error for size %"PRIuz" (%#"PRIxz"): %s\n",
 					    size, size, strerror(err));
 					exit(1);
 				}
diff --git a/test/rallocm.c b/test/rallocm.c
index 9c0df40..6d5a939 100644
--- a/test/rallocm.c
+++ b/test/rallocm.c
@@ -37,7 +37,7 @@ main(void)
 	if (q != p)
 		fprintf(stderr, "Unexpected object move\n");
 	if (tsz != sz) {
-		fprintf(stderr, "Unexpected size change: %zu --> %zu\n",
+		fprintf(stderr, "Unexpected size change: %"PRIuz" --> %"PRIuz"\n",
 		    sz, tsz);
 	}
 
@@ -48,7 +48,7 @@ main(void)
 	if (q != p)
 		fprintf(stderr, "Unexpected object move\n");
 	if (tsz != sz) {
-		fprintf(stderr, "Unexpected size change: %zu --> %zu\n",
+		fprintf(stderr, "Unexpected size change: %"PRIuz" --> %"PRIuz"\n",
 		    sz, tsz);
 	}
 
@@ -59,7 +59,7 @@ main(void)
 	if (q != p)
 		fprintf(stderr, "Unexpected object move\n");
 	if (tsz != sz) {
-		fprintf(stderr, "Unexpected size change: %zu --> %zu\n",
+		fprintf(stderr, "Unexpected size change: %"PRIuz" --> %"PRIuz"\n",
 		    sz, tsz);
 	}
 
@@ -70,7 +70,7 @@ main(void)
 	if (q == p)
 		fprintf(stderr, "Expected object move\n");
 	if (tsz == sz) {
-		fprintf(stderr, "Expected size change: %zu --> %zu\n",
+		fprintf(stderr, "Expected size change: %"PRIuz" --> %"PRIuz"\n",
 		    sz, tsz);
 	}
 	p = q;
@@ -82,7 +82,7 @@ main(void)
 	if (q == p)
 		fprintf(stderr, "Expected object move\n");
 	if (tsz == sz) {
-		fprintf(stderr, "Expected size change: %zu --> %zu\n",
+		fprintf(stderr, "Expected size change: %"PRIuz" --> %"PRIuz"\n",
 		    sz, tsz);
 	}
 	p = q;
@@ -92,7 +92,7 @@ main(void)
 	if (r != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected rallocm() error\n");
 	if (tsz == sz) {
-		fprintf(stderr, "Expected size change: %zu --> %zu\n",
+		fprintf(stderr, "Expected size change: %"PRIuz" --> %"PRIuz"\n",
 		    sz, tsz);
 	}
 	p = q;
@@ -104,7 +104,7 @@ main(void)
 	if (q != p)
 		fprintf(stderr, "Unexpected object move\n");
 	if (tsz == sz) {
-		fprintf(stderr, "Expected size change: %zu --> %zu\n",
+		fprintf(stderr, "Expected size change: %"PRIuz" --> %"PRIuz"\n",
 		    sz, tsz);
 	}
 	sz = tsz;
@@ -115,7 +115,7 @@ main(void)
 	if (q != p)
 		fprintf(stderr, "Unexpected object move\n");
 	if (tsz == sz) {
-		fprintf(stderr, "Expected size change: %zu --> %zu\n",
+		fprintf(stderr, "Expected size change: %"PRIuz" --> %"PRIuz"\n",
 		    sz, tsz);
 	}
 	sz = tsz;
-- 
1.7.9.5




More information about the jemalloc-discuss mailing list