Commit | Line | Data |
---|---|---|
1d597550 BP |
1 | /* This file is part of the Linux Trace Toolkit viewer |
2 | * Copyright (C) 2009 Benjamin Poirier <benjamin.poirier@polymtl.ca> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License Version 2 as | |
6 | * published by the Free Software Foundation; | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program; if not, write to the Free Software | |
15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | |
16 | * MA 02111-1307, USA. | |
17 | */ | |
18 | ||
19 | #ifdef HAVE_CONFIG_H | |
20 | #include <config.h> | |
21 | #endif | |
22 | ||
23 | #include <errno.h> | |
24 | #include <unistd.h> | |
25 | ||
26 | #include "sync_chain.h" | |
27 | ||
28 | ||
29 | GQueue processingModules= G_QUEUE_INIT; | |
30 | GQueue matchingModules= G_QUEUE_INIT; | |
31 | GQueue analysisModules= G_QUEUE_INIT; | |
32 | GQueue moduleOptions= G_QUEUE_INIT; | |
33 | ||
34 | ||
35 | /* | |
36 | * Calculate the elapsed time between two timeval values | |
37 | * | |
38 | * Args: | |
39 | * end: end time, result is also stored in this structure | |
40 | * start: start time | |
41 | */ | |
42 | void timeDiff(struct timeval* const end, const struct timeval* const start) | |
43 | { | |
44 | if (end->tv_usec >= start->tv_usec) | |
45 | { | |
46 | end->tv_sec-= start->tv_sec; | |
47 | end->tv_usec-= start->tv_usec; | |
48 | } | |
49 | else | |
50 | { | |
51 | end->tv_sec= end->tv_sec - start->tv_sec - 1; | |
52 | end->tv_usec= end->tv_usec - start->tv_usec + 1e6; | |
53 | } | |
54 | } | |
55 | ||
56 | ||
57 | /* | |
58 | * A GCompareFunc for g_slist_find_custom() | |
59 | * | |
60 | * Args: | |
61 | * a: ProcessingModule*, element's data | |
62 | * b: char*, user data to compare against | |
63 | * | |
64 | * Returns: | |
65 | * 0 if the processing module a's name is b | |
66 | */ | |
67 | gint gcfCompareProcessing(gconstpointer a, gconstpointer b) | |
68 | { | |
69 | const ProcessingModule* processingModule; | |
70 | const char* name; | |
71 | ||
72 | processingModule= (const ProcessingModule*) a; | |
73 | name= (const char*) b; | |
74 | ||
75 | return strncmp(processingModule->name, name, | |
76 | strlen(processingModule->name) + 1); | |
77 | } | |
78 | ||
79 | ||
80 | /* | |
81 | * A GCompareFunc for g_slist_find_custom() | |
82 | * | |
83 | * Args: | |
84 | * a: MatchingModule*, element's data | |
85 | * b: char*, user data to compare against | |
86 | * | |
87 | * Returns: | |
88 | * 0 if the matching module a's name is b | |
89 | */ | |
90 | gint gcfCompareMatching(gconstpointer a, gconstpointer b) | |
91 | { | |
92 | const MatchingModule* matchingModule; | |
93 | const char* name; | |
94 | ||
95 | matchingModule= (const MatchingModule*) a; | |
96 | name= (const char*) b; | |
97 | ||
98 | return strncmp(matchingModule->name, name, strlen(matchingModule->name) + | |
99 | 1); | |
100 | } | |
101 | ||
102 | ||
103 | /* | |
104 | * A GCompareFunc for g_slist_find_custom() | |
105 | * | |
106 | * Args: | |
107 | * a: AnalysisModule*, element's data | |
108 | * b: char*, user data to compare against | |
109 | * | |
110 | * Returns: | |
111 | * 0 if the analysis module a's name is b | |
112 | */ | |
113 | gint gcfCompareAnalysis(gconstpointer a, gconstpointer b) | |
114 | { | |
115 | const AnalysisModule* analysisModule; | |
116 | const char* name; | |
117 | ||
118 | analysisModule= (const AnalysisModule*) a; | |
119 | name= (const char*) b; | |
120 | ||
121 | return strncmp(analysisModule->name, name, strlen(analysisModule->name) + | |
122 | 1); | |
123 | } |