@@ -53,7 +53,7 @@ enum {
uint8_t trace_buf[TRACE_BUF_LEN];
static unsigned int trace_idx;
static unsigned int writeout_idx;
-static uint64_t dropped_events;
+static int dropped_events;
static FILE *trace_fp;
static char *trace_file_name;
@@ -63,7 +63,7 @@ typedef struct {
uint64_t timestamp_ns;
uint32_t length; /* in bytes */
uint32_t reserved; /* unused */
- uint8_t arguments[];
+ uint64_t arguments[];
} TraceRecord;
typedef struct {
@@ -160,7 +160,7 @@ static gpointer writeout_thread(gpointer opaque)
uint8_t bytes[sizeof(TraceRecord) + sizeof(uint64_t)];
} dropped;
unsigned int idx = 0;
- uint64_t dropped_count;
+ int dropped_count;
size_t unused __attribute__ ((unused));
for (;;) {
@@ -169,16 +169,16 @@ static gpointer writeout_thread(gpointer opaque)
if (dropped_events) {
dropped.rec.event = DROPPED_EVENT_ID,
dropped.rec.timestamp_ns = get_clock();
- dropped.rec.length = sizeof(TraceRecord) + sizeof(dropped_events),
+ dropped.rec.length = sizeof(TraceRecord) + sizeof(uint64_t),
dropped.rec.reserved = 0;
while (1) {
dropped_count = dropped_events;
- if (g_atomic_int_compare_and_exchange((gint *)&dropped_events,
+ if (g_atomic_int_compare_and_exchange(&dropped_events,
dropped_count, 0)) {
break;
}
}
- memcpy(dropped.rec.arguments, &dropped_count, sizeof(uint64_t));
+ dropped.rec.arguments[0] = dropped_count;
unused = fwrite(&dropped.rec, dropped.rec.length, 1, trace_fp);
}
@@ -220,11 +220,11 @@ int trace_record_start(TraceBufferRecord *rec, TraceEventID event, size_t datasi
if (new_idx - writeout_idx > TRACE_BUF_LEN) {
/* Trace Buffer Full, Event dropped ! */
- g_atomic_int_inc((gint *)&dropped_events);
+ g_atomic_int_inc(&dropped_events);
return -ENOSPC;
}
- if (g_atomic_int_compare_and_exchange((gint *)&trace_idx,
+ if (g_atomic_int_compare_and_exchange(&trace_idx,
old_idx, new_idx)) {
break;
}