[sysprof] capture: add 64-bit time stamp for start time



commit ad5f855a2b6dc60e10c5445471cadc93346e2cce
Author: Christian Hergert <chergert redhat com>
Date:   Fri Apr 15 04:48:04 2016 -0700

    capture: add 64-bit time stamp for start time
    
    We keep the start time as a iso8601 string, which is useful, but not
    enough for relative timestamps to the epoch (start time). Include a
    clock time in the same clock domain.

 lib/sp-capture-reader.c |   11 +++++++++++
 lib/sp-capture-reader.h |    1 +
 lib/sp-capture-types.h  |    3 ++-
 lib/sp-capture-writer.c |    1 +
 4 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/lib/sp-capture-reader.c b/lib/sp-capture-reader.c
index 69582b7..c283928 100644
--- a/lib/sp-capture-reader.c
+++ b/lib/sp-capture-reader.c
@@ -783,3 +783,14 @@ handle_errno:
 
   return FALSE;
 }
+
+gint64
+sp_capture_reader_get_start_time (SpCaptureReader *self)
+{
+  g_return_val_if_fail (self != NULL, 0);
+
+  if (self->endian != G_BYTE_ORDER)
+    return GUINT64_SWAP_LE_BE (self->header.time);
+
+  return self->header.time;
+}
diff --git a/lib/sp-capture-reader.h b/lib/sp-capture-reader.h
index f703b3d..bfe6217 100644
--- a/lib/sp-capture-reader.h
+++ b/lib/sp-capture-reader.h
@@ -33,6 +33,7 @@ SpCaptureReader                   *sp_capture_reader_ref                 (SpCapt
 void                               sp_capture_reader_unref               (SpCaptureReader     *self);
 const gchar                       *sp_capture_reader_get_filename        (SpCaptureReader     *self);
 const gchar                       *sp_capture_reader_get_time            (SpCaptureReader     *self);
+gint64                             sp_capture_reader_get_start_time      (SpCaptureReader     *self);
 gboolean                           sp_capture_reader_skip                (SpCaptureReader     *self);
 gboolean                           sp_capture_reader_peek_type           (SpCaptureReader     *self,
                                                                           SpCaptureFrameType  *type);
diff --git a/lib/sp-capture-types.h b/lib/sp-capture-types.h
index 0e33da2..1c040d9 100644
--- a/lib/sp-capture-types.h
+++ b/lib/sp-capture-types.h
@@ -67,7 +67,8 @@ typedef struct
   guint32 little_endian : 1;
   guint32 padding : 23;
   gchar   capture_time[64];
-  gchar   suffix[184];
+  gint64  time;
+  gchar   suffix[176];
 } SpCaptureFileHeader;
 
 typedef struct
diff --git a/lib/sp-capture-writer.c b/lib/sp-capture-writer.c
index caded66..d96d3cb 100644
--- a/lib/sp-capture-writer.c
+++ b/lib/sp-capture-writer.c
@@ -396,6 +396,7 @@ sp_capture_writer_new_from_fd (int   fd,
 #endif
   header->padding = 0;
   g_strlcpy (header->capture_time, nowstr, sizeof header->capture_time);
+  header->time = SP_CAPTURE_CURRENT_TIME;
   memset (header->suffix, 0, sizeof header->suffix);
 
   self->pos += sizeof *header;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]