Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Picky gcc.
[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 #include "instr/config.h"
15
16 #ifdef HAVE_TRACING
17
18 static long long int counter = 0; /* to uniquely identify simix actions */
19
20 void TRACE_smx_action_execute (smx_action_t act)
21 {
22   if (!IS_TRACING) return;
23
24   act->counter = counter++;
25   char *category = __TRACE_current_category_get (SIMIX_process_self());
26   if (category){
27         act->category = xbt_new (char, strlen (category)+1);
28         strncpy (act->category, category, strlen(category)+1);
29   }
30 }
31
32 void TRACE_smx_action_communicate (smx_action_t act, smx_process_t proc)
33 {
34   if (!IS_TRACING) return;
35
36   act->counter = counter++;
37   char *category = __TRACE_current_category_get (proc);
38   if (category){
39         act->category = xbt_new (char, strlen (category)+1);
40         strncpy (act->category, category, strlen(category)+1);
41   }
42 }
43
44 void TRACE_smx_action_destroy (smx_action_t act)
45 {
46   if (!IS_TRACING || !IS_TRACED(act)) return;
47
48   if (act->category){
49     xbt_free (act->category);
50   }
51 }
52
53 #endif