Move index initialization to ctf-index.h
[lttng-tools.git] / src / common / index / ctf-index.h
index 8f0a56c25228509ffe6794ae22dac3203e080894..b96888bb7e5a41067c29b31531316c898034ee5e 100644 (file)
 #ifndef LTTNG_INDEX_H
 #define LTTNG_INDEX_H
 
+#include <common/compat/endian.h>
+#include <common/macros.h>
+
+#include <stdint.h>
 #include <limits.h>
+#include <stddef.h>
 
 #define CTF_INDEX_MAGIC 0xC1F1DCC1
 #define CTF_INDEX_MAJOR 1
@@ -101,4 +106,16 @@ static inline uint32_t lttng_to_index_minor(uint32_t lttng_major,
        abort();
 }
 
+static inline void ctf_packet_index_file_hdr_init(
+               struct ctf_packet_index_file_hdr *hdr,
+               uint32_t idx_major, uint32_t idx_minor)
+{
+       memset(hdr, 0, sizeof(*hdr));
+       hdr->magic = htobe32(CTF_INDEX_MAGIC);
+       hdr->index_major = htobe32(idx_major);
+       hdr->index_minor = htobe32(idx_minor);
+       hdr->packet_index_len = htobe32(
+                       ctf_packet_index_len(idx_major, idx_minor));
+}
+
 #endif /* LTTNG_INDEX_H */
This page took 0.024314 seconds and 5 git commands to generate.