Commit d921d9ed authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

json: add spdk_json_write_[u]int64()



Change-Id: I29c2c8f8546774842adf7e77e7bb550735c6fccc
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 3c3824a3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -196,6 +196,8 @@ int spdk_json_write_null(struct spdk_json_write_ctx *w);
int spdk_json_write_bool(struct spdk_json_write_ctx *w, bool val);
int spdk_json_write_int32(struct spdk_json_write_ctx *w, int32_t val);
int spdk_json_write_uint32(struct spdk_json_write_ctx *w, uint32_t val);
int spdk_json_write_int64(struct spdk_json_write_ctx *w, int64_t val);
int spdk_json_write_uint64(struct spdk_json_write_ctx *w, uint64_t val);
int spdk_json_write_string(struct spdk_json_write_ctx *w, const char *val);
int spdk_json_write_string_raw(struct spdk_json_write_ctx *w, const char *val, size_t len);
int spdk_json_write_array_begin(struct spdk_json_write_ctx *w);
+24 −0
Original line number Diff line number Diff line
@@ -188,6 +188,30 @@ spdk_json_write_uint32(struct spdk_json_write_ctx *w, uint32_t val)
	return emit(w, buf, count);
}

int
spdk_json_write_int64(struct spdk_json_write_ctx *w, int64_t val)
{
	char buf[32];
	int count;

	if (begin_value(w)) return fail(w);
	count = snprintf(buf, sizeof(buf), "%" PRId64, val);
	if (count <= 0 || (size_t)count >= sizeof(buf)) return fail(w);
	return emit(w, buf, count);
}

int
spdk_json_write_uint64(struct spdk_json_write_ctx *w, uint64_t val)
{
	char buf[32];
	int count;

	if (begin_value(w)) return fail(w);
	count = snprintf(buf, sizeof(buf), "%" PRIu64, val);
	if (count <= 0 || (size_t)count >= sizeof(buf)) return fail(w);
	return emit(w, buf, count);
}

static void
write_hex_4(void *dest, uint16_t val)
{