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/>.
26 #include "sync_chain.h"
29 GQueue processingModules
= G_QUEUE_INIT
;
30 GQueue matchingModules
= G_QUEUE_INIT
;
31 GQueue analysisModules
= G_QUEUE_INIT
;
32 GQueue moduleOptions
= G_QUEUE_INIT
;
36 * Calculate the elapsed time between two timeval values
39 * syncState: Container for synchronization data
41 void printStats(SyncState
* const syncState
)
43 if (syncState
->processingModule
->printProcessingStats
!= NULL
)
45 syncState
->processingModule
->printProcessingStats(syncState
);
47 if (syncState
->matchingModule
->printMatchingStats
!= NULL
)
49 syncState
->matchingModule
->printMatchingStats(syncState
);
51 if (syncState
->analysisModule
->printAnalysisStats
!= NULL
)
53 syncState
->analysisModule
->printAnalysisStats(syncState
);
59 * Calculate the elapsed time between two timeval values
62 * end: end time, result is also stored in this structure
65 void timeDiff(struct timeval
* const end
, const struct timeval
* const start
)
67 if (end
->tv_usec
>= start
->tv_usec
)
69 end
->tv_sec
-= start
->tv_sec
;
70 end
->tv_usec
-= start
->tv_usec
;
74 end
->tv_sec
= end
->tv_sec
- start
->tv_sec
- 1;
75 end
->tv_usec
= end
->tv_usec
- start
->tv_usec
+ 1e6
;
81 * A GCompareFunc for g_slist_find_custom()
84 * a: ProcessingModule*, element's data
85 * b: char*, user data to compare against
88 * 0 if the processing module a's name is b
90 gint
gcfCompareProcessing(gconstpointer a
, gconstpointer b
)
92 const ProcessingModule
* processingModule
;
95 processingModule
= (const ProcessingModule
*) a
;
96 name
= (const char*) b
;
98 return strncmp(processingModule
->name
, name
,
99 strlen(processingModule
->name
) + 1);
104 * A GCompareFunc for g_slist_find_custom()
107 * a: MatchingModule*, element's data
108 * b: char*, user data to compare against
111 * 0 if the matching module a's name is b
113 gint
gcfCompareMatching(gconstpointer a
, gconstpointer b
)
115 const MatchingModule
* matchingModule
;
118 matchingModule
= (const MatchingModule
*) a
;
119 name
= (const char*) b
;
121 return strncmp(matchingModule
->name
, name
, strlen(matchingModule
->name
) +
127 * A GCompareFunc for g_slist_find_custom()
130 * a: AnalysisModule*, element's data
131 * b: char*, user data to compare against
134 * 0 if the analysis module a's name is b
136 gint
gcfCompareAnalysis(gconstpointer a
, gconstpointer b
)
138 const AnalysisModule
* analysisModule
;
141 analysisModule
= (const AnalysisModule
*) a
;
142 name
= (const char*) b
;
144 return strncmp(analysisModule
->name
, name
, strlen(analysisModule
->name
) +
150 * A GFunc for g_queue_foreach()
152 * Concatenate analysis module names.
155 * data: AnalysisModule*
156 * user_data: GString*, concatenated names
158 void gfAppendAnalysisName(gpointer data
, gpointer user_data
)
160 g_string_append((GString
*) user_data
, ((AnalysisModule
*) data
)->name
);
161 g_string_append((GString
*) user_data
, ", ");
This page took 0.032504 seconds and 5 git commands to generate.