1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2009 Benjamin Poirier <benjamin.poirier@polymtl.ca>
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;
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.
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,
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 moduleOptions
= G_QUEUE_INIT
;
37 * Calculate the elapsed time between two timeval values
40 * syncState: Container for synchronization data
42 void printStats(SyncState
* const syncState
)
44 if (syncState
->processingModule
->printProcessingStats
!= NULL
)
46 syncState
->processingModule
->printProcessingStats(syncState
);
48 if (syncState
->matchingModule
->printMatchingStats
!= NULL
)
50 syncState
->matchingModule
->printMatchingStats(syncState
);
52 if (syncState
->analysisModule
->printAnalysisStats
!= NULL
)
54 syncState
->analysisModule
->printAnalysisStats(syncState
);
60 * Calculate the elapsed time between two timeval values
63 * end: end time, result is also stored in this structure
66 void timeDiff(struct timeval
* const end
, const struct timeval
* const start
)
68 if (end
->tv_usec
>= start
->tv_usec
)
70 end
->tv_sec
-= start
->tv_sec
;
71 end
->tv_usec
-= start
->tv_usec
;
75 end
->tv_sec
= end
->tv_sec
- start
->tv_sec
- 1;
76 end
->tv_usec
= end
->tv_usec
- start
->tv_usec
+ 1e6
;
82 * A GCompareFunc for g_slist_find_custom()
85 * a: ProcessingModule*, element's data
86 * b: char*, user data to compare against
89 * 0 if the processing module a's name is b
91 gint
gcfCompareProcessing(gconstpointer a
, gconstpointer b
)
93 const ProcessingModule
* processingModule
;
96 processingModule
= (const ProcessingModule
*) a
;
97 name
= (const char*) b
;
99 return strncmp(processingModule
->name
, name
,
100 strlen(processingModule
->name
) + 1);
105 * A GCompareFunc for g_slist_find_custom()
108 * a: MatchingModule*, element's data
109 * b: char*, user data to compare against
112 * 0 if the matching module a's name is b
114 gint
gcfCompareMatching(gconstpointer a
, gconstpointer b
)
116 const MatchingModule
* matchingModule
;
119 matchingModule
= (const MatchingModule
*) a
;
120 name
= (const char*) b
;
122 return strncmp(matchingModule
->name
, name
, strlen(matchingModule
->name
) +
128 * A GCompareFunc for g_slist_find_custom()
131 * a: AnalysisModule*, element's data
132 * b: char*, user data to compare against
135 * 0 if the analysis module a's name is b
137 gint
gcfCompareAnalysis(gconstpointer a
, gconstpointer b
)
139 const AnalysisModule
* analysisModule
;
142 analysisModule
= (const AnalysisModule
*) a
;
143 name
= (const char*) b
;
145 return strncmp(analysisModule
->name
, name
, strlen(analysisModule
->name
) +
151 * A GFunc for g_queue_foreach()
153 * Concatenate analysis module names.
156 * data: AnalysisModule*
157 * user_data: GString*, concatenated names
159 void gfAppendAnalysisName(gpointer data
, gpointer user_data
)
161 g_string_append((GString
*) user_data
, ((AnalysisModule
*) data
)->name
);
162 g_string_append((GString
*) user_data
, ", ");
This page took 0.031735 seconds and 4 git commands to generate.