capture: make counter value a union of int64 and double

This allows us to use the type field of the counter to specify if the
counter is a double or a 64-bit integer.
This commit is contained in:
Christian Hergert
2016-04-15 04:54:55 -07:00
parent 88cc6485dd
commit 49e9ad9db8
5 changed files with 39 additions and 31 deletions

View File

@ -606,7 +606,7 @@ sp_capture_reader_read_counter_define (SpCaptureReader *self)
for (i = 0; i < def->n_counters; i++)
{
def->counters[i].id = GUINT32_SWAP_LE_BE (def->counters[i].id);
def->counters[i].value = GUINT64_SWAP_LE_BE (def->counters[i].value);
def->counters[i].value.v64 = GUINT64_SWAP_LE_BE (def->counters[i].value.v64);
}
}
@ -657,7 +657,7 @@ sp_capture_reader_read_counter_set (SpCaptureReader *self)
for (j = 0; j < G_N_ELEMENTS (set->values[0].values); i++)
{
set->values[i].ids[j] = GUINT32_SWAP_LE_BE (set->values[i].ids[j]);
set->values[i].values[j] = GUINT64_SWAP_LE_BE (set->values[i].values[j]);
set->values[i].values[j].v64 = GUINT64_SWAP_LE_BE (set->values[i].values[j].v64);
}
}
}

View File

@ -38,13 +38,21 @@ G_BEGIN_DECLS
# define SP_CAPTURE_ADDRESS_FORMAT "0x%016llx"
#endif
#define SP_CAPTURE_CURRENT_TIME (g_get_monotonic_time() * 1000L)
#define SP_CAPTURE_CURRENT_TIME (g_get_monotonic_time() * 1000L)
#define SP_CAPTURE_COUNTER_INT64 0
#define SP_CAPTURE_COUNTER_DOUBLE 1
typedef struct _SpCaptureReader SpCaptureReader;
typedef struct _SpCaptureWriter SpCaptureWriter;
typedef guint64 SpCaptureAddress;
typedef union
{
gint64 v64;
gdouble vdbl;
} SpCaptureCounterValue;
typedef enum
{
SP_CAPTURE_FRAME_TIMESTAMP = 1,
@ -131,12 +139,12 @@ typedef struct
typedef struct
{
gchar category[32];
gchar name[32];
gchar description[52];
guint32 id : 24;
guint8 type;
gint64 value;
gchar category[32];
gchar name[32];
gchar description[52];
guint32 id : 24;
guint8 type;
SpCaptureCounterValue value;
} SpCaptureCounter;
typedef struct
@ -154,8 +162,8 @@ typedef struct
* bytes. So this makes a nice 2-cacheline aligned size which is
* useful when the number of counters is rather small.
*/
guint32 ids[8];
gint64 values[8];
guint32 ids[8];
SpCaptureCounterValue values[8];
} SpCaptureCounterValues;
typedef struct

View File

@ -1022,13 +1022,13 @@ sp_capture_writer_define_counters (SpCaptureWriter *self,
}
gboolean
sp_capture_writer_set_counters (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid,
const guint *counters_ids,
const gint64 *values,
guint n_counters)
sp_capture_writer_set_counters (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid,
const guint *counters_ids,
const SpCaptureCounterValue *values,
guint n_counters)
{
SpCaptureFrameCounterSet *set;
gsize len;

View File

@ -92,7 +92,7 @@ gboolean sp_capture_writer_set_counters (SpCaptureWriter *
gint cpu,
GPid pid,
const guint *counters_ids,
const gint64 *values,
const SpCaptureCounterValue *values,
guint n_counters);
gboolean sp_capture_writer_flush (SpCaptureWriter *self);
gboolean sp_capture_writer_save_as (SpCaptureWriter *self,