ref: 477dc93db81feed168d2bcd42bc9a7fc3a88d4c0
parent: df83e0fd31da4af191a662e4f54df71c905d2f34
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Mar 14 09:15:12 EDT 2023
use PRI* macros a bit
--- a/plan9/platform.h
+++ b/plan9/platform.h
@@ -37,6 +37,14 @@
#define LC_NUMERIC 0
#define setlocale(x,y)
+#define PRId64 "lld"
+#define PRIu64 "llud"
+#ifdef BITS64
+#define PRIdPTR PRId64
+#else
+#define PRIdPTR "ld"
+#endif
+
#define NULL nil
#define INT_MAX 0x7fffffff
#define UINT_MAX 0xffffffffU
--- a/posix/platform.h
+++ b/posix/platform.h
@@ -4,6 +4,7 @@
#include <errno.h>
#include <fcntl.h>
#include <float.h>
+#include <inttypes.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
--- a/print.c
+++ b/print.c
@@ -362,10 +362,10 @@
if ((label=(value_t)ptrhash_get(&printconses, (void*)v)) !=
(value_t)HT_NOTFOUND) {
if (!ismarked(v)) {
- HPOS+=ios_printf(f, "#%ld#", numval(label));
+ HPOS+=ios_printf(f, "#%"PRIdPTR"#", numval(label));
return 1;
}
- HPOS+=ios_printf(f, "#%ld=", numval(label));
+ HPOS+=ios_printf(f, "#%"PRIdPTR"=", numval(label));
}
if (ismanaged(v))
unmark_cons(v);
@@ -384,7 +384,7 @@
switch (tag(v)) {
case TAG_NUM :
- case TAG_NUM1: HPOS+=ios_printf(f, "%lld", (int64_t)numval(v)); break;
+ case TAG_NUM1: HPOS+=ios_printf(f, "%"PRId64, (int64_t)numval(v)); break;
case TAG_SYM:
name = symbol_name(v);
if (print_princ)
@@ -700,9 +700,9 @@
) {
uint64_t ui64 = *(uint64_t*)data;
if (weak || print_princ)
- HPOS += ios_printf(f, "%llud", ui64);
+ HPOS += ios_printf(f, "%"PRIu64, ui64);
else
- HPOS += ios_printf(f, "#%s(%llud)", symbol_name(type), ui64);
+ HPOS += ios_printf(f, "#%s(%"PRIu64")", symbol_name(type), ui64);
}
else if (issymbol(type)) {
// handle other integer prims. we know it's smaller than uint64
@@ -714,9 +714,9 @@
else {
int64_t i64 = conv_to_int64(data, nt);
if (weak || print_princ)
- HPOS += ios_printf(f, "%lld", i64);
+ HPOS += ios_printf(f, "%"PRId64, i64);
else
- HPOS += ios_printf(f, "#%s(%lld)", symbol_name(type), i64);
+ HPOS += ios_printf(f, "#%s(%"PRId64")", symbol_name(type), i64);
}
}
else if (iscons(type)) {
--- a/read.c
+++ b/read.c
@@ -695,7 +695,7 @@
case TOK_LABEL:
// create backreference label
if (ptrhash_has(&readstate->backrefs, (void*)tokval))
- lerrorf(ParseError, "read: label %ld redefined", numval(tokval));
+ lerrorf(ParseError, "read: label %"PRIdPTR" redefined", numval(tokval));
oldtokval = tokval;
v = do_read_sexpr(tokval);
ptrhash_put(&readstate->backrefs, (void*)oldtokval, (void*)v);
@@ -704,7 +704,7 @@
// look up backreference
v = (value_t)ptrhash_get(&readstate->backrefs, (void*)tokval);
if (v == (value_t)HT_NOTFOUND)
- lerrorf(ParseError, "read: undefined label %ld", numval(tokval));
+ lerrorf(ParseError, "read: undefined label %"PRIdPTR, numval(tokval));
return v;
case TOK_GENSYM:
pv = (value_t*)ptrhash_bp(&readstate->gensyms, (void*)tokval);