1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2009, 2010 Benjamin Poirier <benjamin.poirier@polymtl.ca>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 2.1 of the License, or (at
7 * your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12 * License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include "sync_chain.h"
30 GQueue processingModules
= G_QUEUE_INIT
;
31 GQueue matchingModules
= G_QUEUE_INIT
;
32 GQueue analysisModules
= G_QUEUE_INIT
;
33 GQueue reductionModules
= G_QUEUE_INIT
;
34 GQueue moduleOptions
= G_QUEUE_INIT
;
38 * Call the statistics function of each module of a sync chain
41 * syncState: Container for synchronization data
43 void printStats(SyncState
* const syncState
)
45 if (syncState
->processingModule
->printProcessingStats
!= NULL
)
47 syncState
->processingModule
->printProcessingStats(syncState
);
49 if (syncState
->matchingModule
!= NULL
&&
50 syncState
->matchingModule
->printMatchingStats
!= NULL
)
52 syncState
->matchingModule
->printMatchingStats(syncState
);
54 if (syncState
->analysisModule
!= NULL
&&
55 syncState
->analysisModule
->printAnalysisStats
!= NULL
)
57 syncState
->analysisModule
->printAnalysisStats(syncState
);
59 if (syncState
->reductionModule
!= NULL
&&
60 syncState
->reductionModule
->printReductionStats
!= NULL
)
62 syncState
->reductionModule
->printReductionStats(syncState
);
68 * Calculate the elapsed time between two timeval values
71 * end: end time, result is also stored in this structure
74 void timeDiff(struct timeval
* const end
, const struct timeval
* const start
)
76 if (end
->tv_usec
>= start
->tv_usec
)
78 end
->tv_sec
-= start
->tv_sec
;
79 end
->tv_usec
-= start
->tv_usec
;
83 end
->tv_sec
= end
->tv_sec
- start
->tv_sec
- 1;
84 end
->tv_usec
= end
->tv_usec
- start
->tv_usec
+ 1e6
;
90 * A GCompareFunc for g_slist_find_custom()
93 * a: ProcessingModule*, element's data
94 * b: char*, user data to compare against
97 * 0 if the processing module a's name is b
99 gint
gcfCompareProcessing(gconstpointer a
, gconstpointer b
)
101 const ProcessingModule
* processingModule
;
104 processingModule
= (const ProcessingModule
*) a
;
105 name
= (const char*) b
;
107 return strncmp(processingModule
->name
, name
,
108 strlen(processingModule
->name
) + 1);
113 * A GCompareFunc for g_slist_find_custom()
116 * a: MatchingModule*, element's data
117 * b: char*, user data to compare against
120 * 0 if the matching module a's name is b
122 gint
gcfCompareMatching(gconstpointer a
, gconstpointer b
)
124 const MatchingModule
* matchingModule
;
127 matchingModule
= (const MatchingModule
*) a
;
128 name
= (const char*) b
;
130 return strncmp(matchingModule
->name
, name
, strlen(matchingModule
->name
) +
136 * A GCompareFunc for g_slist_find_custom()
139 * a: AnalysisModule*, element's data
140 * b: char*, user data to compare against
143 * 0 if the analysis module a's name is b
145 gint
gcfCompareAnalysis(gconstpointer a
, gconstpointer b
)
147 const AnalysisModule
* analysisModule
;
150 analysisModule
= (const AnalysisModule
*) a
;
151 name
= (const char*) b
;
153 return strncmp(analysisModule
->name
, name
, strlen(analysisModule
->name
) +
159 * A GCompareFunc for g_slist_find_custom()
162 * a: ReductionModule*, element's data
163 * b: char*, user data to compare against
166 * 0 if the reduction module a's name is b
168 gint
gcfCompareReduction(gconstpointer a
, gconstpointer b
)
170 const ReductionModule
* reductionModule
;
173 reductionModule
= (const ReductionModule
*) a
;
174 name
= (const char*) b
;
176 return strncmp(reductionModule
->name
, name
, strlen(reductionModule
->name
) +
182 * A GFunc for g_queue_foreach()
184 * Concatenate analysis module names.
187 * data: AnalysisModule*
188 * user_data: GString*, concatenated names
190 void gfAppendAnalysisName(gpointer data
, gpointer user_data
)
192 g_string_append((GString
*) user_data
, ((AnalysisModule
*) data
)->name
);
193 g_string_append((GString
*) user_data
, ", ");
198 * A GFunc for g_queue_foreach()
200 * Concatenate reduction module names.
203 * data: ReductionModule*
204 * user_data: GString*, concatenated names
206 void gfAppendReductionName(gpointer data
, gpointer user_data
)
208 g_string_append((GString
*) user_data
, ((ReductionModule
*) data
)->name
);
209 g_string_append((GString
*) user_data
, ", ");
This page took 0.034076 seconds and 4 git commands to generate.