aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common.h12
-rw-r--r--pack.c4
-rw-r--r--unpack.c8
3 files changed, 18 insertions, 6 deletions
diff --git a/common.h b/common.h
index d8a9622..a9386be 100644
--- a/common.h
+++ b/common.h
@@ -10,6 +10,18 @@
#define BITMASK(n) (UINTMAX_MAX >> (sizeof (uintmax_t) * CHAR_BIT - n))
+#ifndef PRIuSIZE
+ #ifdef _WIN32
+ #ifdef _WIN64
+ #define PRIuSIZE PRIu64
+ #else
+ #define PRIuSIZE PRIu32
+ #endif
+ #else
+ #define PRIuSIZE "zu"
+ #endif
+#endif
+
enum endian { BIG, LITTLE };
size_t getsize(char c);
diff --git a/pack.c b/pack.c
index 4dc6c3a..a287448 100644
--- a/pack.c
+++ b/pack.c
@@ -25,7 +25,7 @@ enum pack_status pack(void *buf_, size_t size, const char *fmt, ...)
size_t offset = 0;
va_list ap;
- tr_call("pack(%p, %zu, %s, ...)", (void *)buf, size, fmt);
+ tr_call("pack(%p, %" PRIuSIZE ", %s, ...)", (void *)buf, size, fmt);
va_start(ap, fmt);
@@ -54,7 +54,7 @@ enum pack_status pack(void *buf_, size_t size, const char *fmt, ...)
tr_debug("i: %d, fmt[i]: %c, sign: %ssigned", i, fmt[i], sign ? "" : "un");
s = getsize(fmt[i]);
- tr_debug("s: %zu", s);
+ tr_debug("s: %" PRIuSIZE, s);
if (s == (size_t)-1) return PACK_FMTINVAL;
if (size - offset < s) return PACK_TOOSMALL;
diff --git a/unpack.c b/unpack.c
index 1686cd7..6c0d97d 100644
--- a/unpack.c
+++ b/unpack.c
@@ -43,7 +43,7 @@ enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...)
size_t offset = 0;
va_list ap;
- tr_call("unpack(%p, %zu, %s, ...)", (const void *)buf, size, fmt);
+ tr_call("unpack(%p, %" PRIuSIZE ", %s, ...)", (const void *)buf, size, fmt);
va_start(ap, fmt);
@@ -81,7 +81,7 @@ enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...)
i++;
}
sign = islower(fmt[i]);
- tr_debug("count: %zu, i: %d, fmt[i]: %c, sign: %ssigned",
+ tr_debug("count: %" PRIuSIZE ", i: %d, fmt[i]: %c, sign: %ssigned",
count, i, fmt[i], sign ? "" : "un");
switch (fmt[i]) {
case '>': endianness = BIG; continue;
@@ -103,7 +103,7 @@ enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...)
}
s = getsize(fmt[i]);
- tr_debug("s: %zu", s);
+ tr_debug("s: %" PRIuSIZE, s);
if (s == (size_t)-1) return PACK_FMTINVAL;
if (size - offset < s * count) return PACK_TOOSMALL;
@@ -112,7 +112,7 @@ enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...)
for (size_t j = 0; j < count; j++) {
val.u = read_val(buf + offset + s * j, s, endianness);
- tr_debug("val.u: %" PRIuMAX ", at: %zu", val.u, offset + s * j);
+ tr_debug("val.u: %" PRIuMAX ", at: %" PRIuSIZE, val.u, offset + s * j);
if (fmt[i] == 'f') {
float f = ieee754b32_deserialise(val.u);