msgbuf: Add pldm_msgbuf_insert_uint64

Required for encoding firmware update non_functioning_component_bitmap

Change-Id: I3360b09150021bc30423bdc8de4936b6fa31092d
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
diff --git a/src/msgbuf.h b/src/msgbuf.h
index 6cab0d2..d34c4a4 100644
--- a/src/msgbuf.h
+++ b/src/msgbuf.h
@@ -658,6 +658,35 @@
 						      dst_count)
 
 LIBPLDM_CC_NONNULL
+LIBPLDM_CC_ALWAYS_INLINE int pldm_msgbuf_insert_uint64(struct pldm_msgbuf *ctx,
+						       const uint64_t src)
+{
+	uint64_t val = htole64(src);
+
+	if (!ctx->cursor) {
+		return -EINVAL;
+	}
+
+	static_assert(
+		// NOLINTNEXTLINE(bugprone-sizeof-expression)
+		sizeof(src) < INTMAX_MAX,
+		"The following addition may not uphold the runtime assertion");
+
+	if (ctx->remaining >= (intmax_t)sizeof(src)) {
+		memcpy(ctx->cursor, &val, sizeof(val));
+		ctx->cursor += sizeof(src);
+		ctx->remaining -= sizeof(src);
+		return 0;
+	}
+
+	if (ctx->remaining >= INTMAX_MIN + (intmax_t)sizeof(src)) {
+		ctx->remaining -= sizeof(src);
+	}
+
+	return -EOVERFLOW;
+}
+
+LIBPLDM_CC_NONNULL
 LIBPLDM_CC_ALWAYS_INLINE int pldm_msgbuf_insert_uint32(struct pldm_msgbuf *ctx,
 						       const uint32_t src)
 {
@@ -834,7 +863,8 @@
 		uint16_t: pldm_msgbuf_insert_uint16,                           \
 		int16_t: pldm_msgbuf_insert_int16,                             \
 		uint32_t: pldm_msgbuf_insert_uint32,                           \
-		int32_t: pldm_msgbuf_insert_int32)(dst, src)
+		int32_t: pldm_msgbuf_insert_int32,                             \
+		uint64_t: pldm_msgbuf_insert_uint64)(dst, src)
 
 /**
  * @ref pldm_msgbuf_insert_array