size_t len;
};
-#define at(a, b) \
- PRINTFRR(a, b)
+#define at(a, b) PRINTFRR(a, b)
#define atn(a, b) \
at(a, b) __attribute__((nonnull(1) _RET_NONNULL))
#define atm(a, b) \
char *asnprintfrr(struct memtype *mt, char *out, size_t sz,
const char *fmt, ...) atn(4, 5);
+#define printfrr(fmt, ...) \
+ do { \
+ char buf[256], *out; \
+ out = asnprintfrr(MTYPE_TMP, buf, sizeof(buf), fmt, \
+ ##__VA_ARGS__); \
+ fputs(out, stdout); \
+ if (out != buf) \
+ XFREE(MTYPE_TMP, out); \
+ } while (0)
+
#undef at
#undef atm
#undef atn
#include "atomlist.h"
#include "seqlock.h"
#include "monotime.h"
+#include "printfrr.h"
/*
* maybe test:
size_t c = 0, s = 0, n = 0;
struct item *item, *prev, dummy;
- printf("[%02u] %35s %s\n", seqlock_cur(&sqlo) >> 2, "", desc);
+ printfrr("[%02u] %35s %s\n", seqlock_cur(&sqlo) >> 2, "", desc);
fflush(stdout);
if (tr->prefill != NOCLEAR)
}
assert(c == alist_count(&ahead));
}
- printf("\033[1A[%02u] %9"PRId64"us c=%5zu s=%5zu n=%5zu %s\n",
+ printfrr("\033[1A[%02u] %9"PRId64"us c=%5zu s=%5zu n=%5zu %s\n",
sv >> 2, delta, c, s, n, desc);
}
struct item *item, *safe;
size_t ctr = 0;
- printf("dumping %s:\n", lbl);
+ printfrr("dumping %s:\n", lbl);
frr_each_safe(alist, &ahead, item) {
- printf("%s %3zu %p %3"PRIu64" %3"PRIu64"\n", lbl, ctr++,
+ printfrr("%s %3zu %p %3"PRIu64" %3"PRIu64"\n", lbl, ctr++,
(void *)item, item->val1, item->val2);
}
}
dump("");
alist_del(&ahead, &itm[1]);
dump("");
- printf("POP: %p\n", alist_pop(&ahead));
+ printfrr("POP: %p\n", alist_pop(&ahead));
dump("");
- printf("POP: %p\n", alist_pop(&ahead));
- printf("POP: %p\n", alist_pop(&ahead));
- printf("POP: %p\n", alist_pop(&ahead));
- printf("POP: %p\n", alist_pop(&ahead));
+ printfrr("POP: %p\n", alist_pop(&ahead));
+ printfrr("POP: %p\n", alist_pop(&ahead));
+ printfrr("POP: %p\n", alist_pop(&ahead));
+ printfrr("POP: %p\n", alist_pop(&ahead));
dump("");
}
#else
#include <stream.h>
#include <thread.h>
+#include "printfrr.h"
+
static unsigned long long ham = 0xdeadbeefdeadbeef;
struct thread_master *master;
{
size_t getp = stream_get_getp(s);
- printf("endp: %zu, readable: %zu, writeable: %zu\n", stream_get_endp(s),
- STREAM_READABLE(s), STREAM_WRITEABLE(s));
+ printfrr("endp: %zu, readable: %zu, writeable: %zu\n",
+ stream_get_endp(s), STREAM_READABLE(s), STREAM_WRITEABLE(s));
while (STREAM_READABLE(s)) {
- printf("0x%x ", *stream_pnt(s));
+ printfrr("0x%x ", *stream_pnt(s));
stream_forward_getp(s, 1);
}
- printf("\n");
+ printfrr("\n");
/* put getp back to where it was */
stream_set_getp(s, getp);
print_stream(s);
- printf("c: 0x%hhx\n", stream_getc(s));
- printf("w: 0x%hx\n", stream_getw(s));
- printf("l: 0x%x\n", stream_getl(s));
- printf("q: 0x%" PRIx64 "\n", stream_getq(s));
+ printfrr("c: 0x%hhx\n", stream_getc(s));
+ printfrr("w: 0x%hx\n", stream_getw(s));
+ printfrr("l: 0x%x\n", stream_getl(s));
+ printfrr("q: 0x%" PRIx64 "\n", stream_getq(s));
return 0;
}
#include "monotime.h"
#include "jhash.h"
#include "sha256.h"
+#include "printfrr.h"
#include "tests/helpers/c/prng.h"
{
int64_t us;
us = monotime_since(&ref, NULL);
- printf("%7"PRId64"us %s\n", us, text);
+ printfrr("%7"PRId64"us %s\n", us, text);
monotime(&ref);
}
static void ts_end(void)
{
int64_t us;
us = monotime_since(&ref0, NULL);
- printf("%7"PRId64"us total\n", us);
+ printfrr("%7"PRId64"us total\n", us);
}
#define TYPE LIST
for (i = 0; i < sizeof(hash); i++)
sprintf(hashtext + i * 2, "%02x", hash[i]);
- printf("%7"PRId64"us %-25s %s%s\n", us, text,
+ printfrr("%7"PRId64"us %-25s %s%s\n", us, text,
expect ? " " : "*", hashtext);
if (expect && strcmp(expect, hashtext)) {
- printf("%-21s %s\n", "EXPECTED:", expect);
+ printfrr("%-21s %s\n", "EXPECTED:", expect);
assert(0);
}
monotime(&ref);
for (i = 0; i < NITEM; i++)
itm[i].val = i;
- printf("%s start\n", str(TYPE));
+ printfrr("%s start\n", str(TYPE));
ts_start();
list_init(&head);
list_fini(&head);
ts_ref("fini");
ts_end();
- printf("%s end\n", str(TYPE));
+ printfrr("%s end\n", str(TYPE));
}
#undef ts_hashx