Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleaning tracing code
[simgrid.git] / src / instr / smx_instr.c
1 /*
2  * smx.c
3  *
4  *  Created on: Nov 24, 2009
5  *      Author: Lucas Schnorr
6  *     License: This program is free software; you can redistribute
7  *              it and/or modify it under the terms of the license
8  *              (GNU LGPL) which comes with this package.
9  *
10  *     Copyright (c) 2009 The SimGrid team.
11  */
12
13 #include "instr/private.h"
14
15 #ifdef HAVE_TRACING
16
17 static long long int counter = 0; /* to uniquely identify simix actions */
18
19 void TRACE_smx_action_execute (smx_action_t act)
20 {
21   if (!IS_TRACING) return;
22
23   act->counter = counter++;
24   char *category = __TRACE_current_category_get (SIMIX_process_self());
25   if (category){
26         act->category = xbt_new (char, strlen (category)+1);
27         strncpy (act->category, category, strlen(category)+1);
28   }
29 }
30
31 void TRACE_smx_action_communicate (smx_action_t act, smx_process_t proc)
32 {
33   if (!IS_TRACING) return;
34
35   act->counter = counter++;
36   char *category = __TRACE_current_category_get (proc);
37   if (category){
38         act->category = xbt_new (char, strlen (category)+1);
39         strncpy (act->category, category, strlen(category)+1);
40   }
41 }
42
43 void TRACE_smx_action_destroy (smx_action_t act)
44 {
45   if (!IS_TRACING || !IS_TRACED(act)) return;
46
47   if (act->category){
48     xbt_free (act->category);
49   }
50 }
51
52 #endif