- ctf_align_pos(pos, sizeof(uint32_t) * CHAR_BIT);
- *(uint32_t *) ctf_get_pos_addr(pos) = pos->packet_size;
- ctf_move_pos(pos, sizeof(uint32_t) * CHAR_BIT);
+ ctf_align_pos(pos, sizeof(uint64_t) * CHAR_BIT);
+ *(uint64_t *) ctf_get_pos_addr(pos) = pos->packet_size;
+ ctf_move_pos(pos, sizeof(uint64_t) * CHAR_BIT);
+}
+
+static
+void write_event_header(struct ctf_stream_pos *pos, char *line,
+ char **tline, size_t len, size_t *tlen,
+ uint64_t *ts)
+{
+ unsigned long sec, usec;
+
+ if (!s_timestamp)
+ return;
+
+ /* Only need to be executed on first pass (dummy) */
+ if (pos->dummy) {
+ int ret;
+
+ /* Extract time from input line */
+ ret = sscanf(line, "[%lu.%lu] ", &sec, &usec);
+ if (ret == 2) {
+ *tline = strchr(line, ']');
+ assert(*tline);
+ (*tline)++;
+ if ((*tline)[0] == ' ') {
+ (*tline)++;
+ }
+ *tlen = len + line - *tline;
+ *ts = (uint64_t) sec * USEC_PER_SEC + (uint64_t) usec;
+ /*
+ * Default CTF clock has 1GHz frequency. Convert
+ * from usec to nsec.
+ */
+ *ts *= 1000;
+ }
+ }
+ /* timestamp */
+ ctf_align_pos(pos, sizeof(uint64_t) * CHAR_BIT);
+ if (!pos->dummy)
+ *(uint64_t *) ctf_get_pos_addr(pos) = *ts;
+ ctf_move_pos(pos, sizeof(uint64_t) * CHAR_BIT);