Browse Source

trace/simple.c: fix deprecated glib2 interface

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
(cherry picked from commit 0d665005c7fd3800f1ae590701f60fe7e4c9a57a)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Harsh Prateek Bora 13 years ago
parent
commit
08375616a0
1 changed files with 4 additions and 1 deletions
  1. 4 1
      trace/simple.c

+ 4 - 1
trace/simple.c

@@ -161,8 +161,11 @@ static void trace(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3,
     }
     }
 
 
     timestamp = get_clock();
     timestamp = get_clock();
-
+#if GLIB_CHECK_VERSION(2, 30, 0)
+    idx = g_atomic_int_add((gint *)&trace_idx, 1) % TRACE_BUF_LEN;
+#else
     idx = g_atomic_int_exchange_and_add((gint *)&trace_idx, 1) % TRACE_BUF_LEN;
     idx = g_atomic_int_exchange_and_add((gint *)&trace_idx, 1) % TRACE_BUF_LEN;
+#endif
     trace_buf[idx] = (TraceRecord){
     trace_buf[idx] = (TraceRecord){
         .event = event,
         .event = event,
         .timestamp_ns = timestamp,
         .timestamp_ns = timestamp,