Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4122102fdaba43d1b06bfe3597deffc1ffadecdf
[simgrid.git] / src / instr / instr_categories.c
1 /* Copyright (c) 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5   * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "instr/instr_private.h"
8
9 #ifdef HAVE_TRACING
10
11 static xbt_dict_t current_task_category = NULL;
12
13 void TRACE_category_alloc()
14 {
15   current_task_category = xbt_dict_new();
16 }
17
18 void TRACE_category_release()
19 {
20   xbt_dict_free(&current_task_category);
21 }
22
23 void TRACE_category_set(smx_process_t proc, const char *category)
24 {
25   char processid[100];
26   char *var_cpy = NULL;
27   snprintf(processid, 100, "%p", proc);
28   var_cpy = xbt_strdup(category);
29   xbt_dict_set(current_task_category, processid, var_cpy, xbt_free);
30 }
31
32 char *TRACE_category_get(smx_process_t proc)
33 {
34   char processid[100];
35   snprintf(processid, 100, "%p", proc);
36   return xbt_dict_get_or_null(current_task_category, processid);
37 }
38
39 void TRACE_category_unset(smx_process_t proc)
40 {
41   char processid[100];
42   snprintf(processid, 100, "%p", proc);
43   if (xbt_dict_get_or_null(current_task_category, processid) != NULL) {
44     xbt_dict_remove(current_task_category, processid);
45   }
46 }
47
48 void TRACE_msg_category_set(smx_process_t proc, m_task_t task)
49 {
50   TRACE_category_set(proc, task->category);
51 }
52
53
54 #endif /* HAVE_TRACING */