From: Benjamin Poirier Date: Mon, 8 Feb 2010 18:51:19 +0000 (-0500) Subject: Do not use __attribute__((constructor)) X-Git-Tag: v0.12.30~5 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2f961b65e3422f23019286e9531b0a40070278ea;p=lttv.git Do not use __attribute__((constructor)) For greater compatibility with older compilers. The functions that used to be constructors are functions that register the sync modules. These functions now have to be called from each sync_chain initialization function. Signed-off-by: Benjamin Poirier --- diff --git a/lttv/lttv/sync/event_analysis_chull.c b/lttv/lttv/sync/event_analysis_chull.c index 8e965b72..6f098b6d 100644 --- a/lttv/lttv/sync/event_analysis_chull.c +++ b/lttv/lttv/sync/event_analysis_chull.c @@ -61,8 +61,6 @@ static void writeAnalysisGraphsPlotsCHull(SyncState* const syncState, const unsigned int i, const unsigned int j); // Functions specific to this module -static void registerAnalysisCHull() __attribute__((constructor (101))); - static void openGraphFiles(SyncState* const syncState); static void closeGraphFiles(SyncState* const syncState); static void writeGraphFiles(SyncState* const syncState); @@ -121,7 +119,7 @@ const char* const approxNames[]= { /* * Analysis module registering function */ -static void registerAnalysisCHull() +void registerAnalysisCHull() { g_queue_push_tail(&analysisModules, &analysisModuleCHull); } diff --git a/lttv/lttv/sync/event_analysis_chull.h b/lttv/lttv/sync/event_analysis_chull.h index b82596b9..07942cc9 100644 --- a/lttv/lttv/sync/event_analysis_chull.h +++ b/lttv/lttv/sync/event_analysis_chull.h @@ -169,6 +169,7 @@ typedef struct AnalysisGraphsDataCHull* graphsData; } AnalysisDataCHull; +void registerAnalysisCHull(); FactorsCHull** calculateAllFactors(struct _SyncState* const syncState); void freeAllFactors(const unsigned int traceNb, FactorsCHull** const diff --git a/lttv/lttv/sync/event_analysis_eval.c b/lttv/lttv/sync/event_analysis_eval.c index 0c0b7b51..6b961020 100644 --- a/lttv/lttv/sync/event_analysis_eval.c +++ b/lttv/lttv/sync/event_analysis_eval.c @@ -78,7 +78,6 @@ static void writeAnalysisTraceTraceForePlotsEval(SyncState* const syncState, const unsigned int i, const unsigned int j); // Functions specific to this module -static void registerAnalysisEval() __attribute__((constructor (102))); static guint ghfRttKeyHash(gconstpointer key); static gboolean gefRttKeyEqual(gconstpointer a, gconstpointer b); static void gdnDestroyRttKey(gpointer data); @@ -156,7 +155,7 @@ static ModuleOption optionEvalRttFile= { /* * Analysis module registering function */ -static void registerAnalysisEval() +void registerAnalysisEval() { binBase= exp10(6. / (BIN_NB - 3)); diff --git a/lttv/lttv/sync/event_analysis_eval.h b/lttv/lttv/sync/event_analysis_eval.h index c0b02d0d..05d86601 100644 --- a/lttv/lttv/sync/event_analysis_eval.h +++ b/lttv/lttv/sync/event_analysis_eval.h @@ -153,4 +153,6 @@ typedef struct AnalysisGraphsEval* graphs; } AnalysisDataEval; +void registerAnalysisEval(); + #endif diff --git a/lttv/lttv/sync/event_analysis_linreg.c b/lttv/lttv/sync/event_analysis_linreg.c index 07537780..7011f96f 100644 --- a/lttv/lttv/sync/event_analysis_linreg.c +++ b/lttv/lttv/sync/event_analysis_linreg.c @@ -43,8 +43,6 @@ static void writeAnalysisGraphsPlotsLinReg(SyncState* const syncState, const unsigned int i, const unsigned int j); // Functions specific to this module -static void registerAnalysisLinReg() __attribute__((constructor (102))); - static void finalizeLSA(SyncState* const syncState); static void doGraphProcessing(SyncState* const syncState); static GArray* calculateFactors(SyncState* const syncState); @@ -78,7 +76,7 @@ static AnalysisModule analysisModuleLinReg= { /* * Analysis module registering function */ -static void registerAnalysisLinReg() +void registerAnalysisLinReg() { g_queue_push_tail(&analysisModules, &analysisModuleLinReg); } diff --git a/lttv/lttv/sync/event_analysis_linreg.h b/lttv/lttv/sync/event_analysis_linreg.h index 60002e3e..0eafe3f6 100644 --- a/lttv/lttv/sync/event_analysis_linreg.h +++ b/lttv/lttv/sync/event_analysis_linreg.h @@ -49,4 +49,6 @@ typedef struct double* stDev; } AnalysisDataLinReg; +void registerAnalysisLinReg(); + #endif diff --git a/lttv/lttv/sync/event_matching_broadcast.c b/lttv/lttv/sync/event_matching_broadcast.c index 96885697..1bc5d75e 100644 --- a/lttv/lttv/sync/event_matching_broadcast.c +++ b/lttv/lttv/sync/event_matching_broadcast.c @@ -43,8 +43,6 @@ static void writeMatchingGraphsPlotsBroadcast(SyncState* const syncState, const unsigned int i, const unsigned int j); // Functions specific to this module -static void registerMatchingBroadcast() __attribute__((constructor (101))); - static void partialDestroyMatchingBroadcast(SyncState* const syncState); static void openGraphDataFiles(SyncState* const syncState); @@ -71,7 +69,7 @@ static MatchingModule matchingModuleBroadcast = { /* * Matching module registering function */ -static void registerMatchingBroadcast() +void registerMatchingBroadcast() { g_queue_push_tail(&matchingModules, &matchingModuleBroadcast); } diff --git a/lttv/lttv/sync/event_matching_broadcast.h b/lttv/lttv/sync/event_matching_broadcast.h index 8006cdd1..d9c4fbfa 100644 --- a/lttv/lttv/sync/event_matching_broadcast.h +++ b/lttv/lttv/sync/event_matching_broadcast.h @@ -65,4 +65,6 @@ typedef struct MatchingGraphsBroadcast* graphs; } MatchingDataBroadcast; +void registerMatchingBroadcast(); + #endif diff --git a/lttv/lttv/sync/event_matching_distributor.c b/lttv/lttv/sync/event_matching_distributor.c index 4bb7e68c..6ea6c0fd 100644 --- a/lttv/lttv/sync/event_matching_distributor.c +++ b/lttv/lttv/sync/event_matching_distributor.c @@ -68,8 +68,6 @@ static void writeMatchingTraceTimeOptionsDistributor(SyncState* const syncState, const unsigned int i, const unsigned int j); // Functions specific to this module -static void registerMatchingDistributor() __attribute__((constructor (101))); - void gfInitModule(gpointer data, gpointer user_data); void gfDestroyModule(gpointer data, gpointer user_data); void gfMatchEvent(gpointer data, gpointer user_data); @@ -103,7 +101,7 @@ static MatchingModule matchingModuleDistributor = { /* * Matching module registering function */ -static void registerMatchingDistributor() +void registerMatchingDistributor() { g_queue_push_tail(&matchingModules, &matchingModuleDistributor); } diff --git a/lttv/lttv/sync/event_matching_distributor.h b/lttv/lttv/sync/event_matching_distributor.h index b4399e5c..e5e071ac 100644 --- a/lttv/lttv/sync/event_matching_distributor.h +++ b/lttv/lttv/sync/event_matching_distributor.h @@ -31,4 +31,6 @@ typedef struct GQueue* distributedModules; } MatchingDataDistributor; +void registerMatchingDistributor(); + #endif diff --git a/lttv/lttv/sync/event_matching_tcp.c b/lttv/lttv/sync/event_matching_tcp.c index 9ba8b632..5f3aa934 100644 --- a/lttv/lttv/sync/event_matching_tcp.c +++ b/lttv/lttv/sync/event_matching_tcp.c @@ -43,8 +43,6 @@ static void writeMatchingGraphsPlotsTCPMessages(SyncState* const syncState, const unsigned int i, const unsigned int j); // Functions specific to this module -static void registerMatchingTCP() __attribute__((constructor (101))); - static void matchEvents(SyncState* const syncState, Event* const event, GHashTable* const unMatchedList, GHashTable* const unMatchedOppositeList, const size_t fieldOffset, const size_t @@ -79,7 +77,7 @@ static MatchingModule matchingModuleTCP = { /* * Matching module registering function */ -static void registerMatchingTCP() +void registerMatchingTCP() { g_queue_push_tail(&matchingModules, &matchingModuleTCP); } diff --git a/lttv/lttv/sync/event_matching_tcp.h b/lttv/lttv/sync/event_matching_tcp.h index 2687aa21..9ec887a5 100644 --- a/lttv/lttv/sync/event_matching_tcp.h +++ b/lttv/lttv/sync/event_matching_tcp.h @@ -60,4 +60,6 @@ typedef struct FILE*** messagePoints; } MatchingDataTCP; +void registerMatchingTCP(); + #endif diff --git a/lttv/lttv/sync/event_processing_lttng_null.c b/lttv/lttv/sync/event_processing_lttng_null.c index 8970e036..3a917317 100644 --- a/lttv/lttv/sync/event_processing_lttng_null.c +++ b/lttv/lttv/sync/event_processing_lttng_null.c @@ -36,7 +36,6 @@ static void destroyProcessingLTTVNull(SyncState* const syncState); static void finalizeProcessingLTTVNull(SyncState* const syncState); // Functions specific to this module -static void registerProcessingLTTVNull() __attribute__((constructor (102))); static gboolean processEventLTTVNull(void* hookData, void* callData); @@ -52,7 +51,7 @@ static ProcessingModule processingModuleLTTVNull = { /* * Processing Module registering function */ -static void registerProcessingLTTVNull() +void registerProcessingLTTVNull() { g_queue_push_tail(&processingModules, &processingModuleLTTVNull); diff --git a/lttv/lttv/sync/event_processing_lttng_null.h b/lttv/lttv/sync/event_processing_lttng_null.h index 9204b8fb..8e01c58c 100644 --- a/lttv/lttv/sync/event_processing_lttng_null.h +++ b/lttv/lttv/sync/event_processing_lttng_null.h @@ -35,4 +35,6 @@ typedef struct GArray* hookListList; } ProcessingDataLTTVNull; +void registerProcessingLTTVNull(); + #endif diff --git a/lttv/lttv/sync/event_processing_lttng_standard.c b/lttv/lttv/sync/event_processing_lttng_standard.c index 876dac08..55806dfa 100644 --- a/lttv/lttv/sync/event_processing_lttng_standard.c +++ b/lttv/lttv/sync/event_processing_lttng_standard.c @@ -54,7 +54,6 @@ static void writeProcessingTraceTimeOptionsLTTVStandard(SyncState* const syncState, const unsigned int i, const unsigned int j); // Functions specific to this module -static void registerProcessingLTTVStandard() __attribute__((constructor (102))); static gboolean processEventLTTVStandard(void* hookData, void* callData); static void partialDestroyProcessingLTTVStandard(SyncState* const syncState); @@ -76,7 +75,7 @@ static ProcessingModule processingModuleLTTVStandard = { /* * Processing Module registering function */ -static void registerProcessingLTTVStandard() +void registerProcessingLTTVStandard() { g_queue_push_tail(&processingModules, &processingModuleLTTVStandard); diff --git a/lttv/lttv/sync/event_processing_lttng_standard.h b/lttv/lttv/sync/event_processing_lttng_standard.h index 3875e398..419aac2b 100644 --- a/lttv/lttv/sync/event_processing_lttng_standard.h +++ b/lttv/lttv/sync/event_processing_lttng_standard.h @@ -61,4 +61,6 @@ typedef struct ProcessingGraphsLTTVStandard* graphs; } ProcessingDataLTTVStandard; +void registerProcessingLTTVStandard(); + #endif diff --git a/lttv/lttv/sync/event_processing_text.c b/lttv/lttv/sync/event_processing_text.c index 8471096a..238d658c 100644 --- a/lttv/lttv/sync/event_processing_text.c +++ b/lttv/lttv/sync/event_processing_text.c @@ -48,8 +48,6 @@ static void writeProcessingGraphVariablesText(SyncState* const syncState, const unsigned int i); // Functions specific to this module -static void registerProcessingText() __attribute__((constructor (102))); - static unsigned int readTraceNb(FILE* testCase); static void skipCommentLines(FILE* testCase); @@ -71,7 +69,7 @@ static ProcessingModule processingModuleText = { /* * Processing Module registering function */ -static void registerProcessingText() +void registerProcessingText() { g_queue_push_tail(&processingModules, &processingModuleText); } diff --git a/lttv/lttv/sync/event_processing_text.h b/lttv/lttv/sync/event_processing_text.h index 0fda7786..451b7b99 100644 --- a/lttv/lttv/sync/event_processing_text.h +++ b/lttv/lttv/sync/event_processing_text.h @@ -29,4 +29,6 @@ typedef struct FILE* testCase; } ProcessingDataText; +void registerProcessingText(); + #endif diff --git a/lttv/lttv/sync/sync_chain_lttv.c b/lttv/lttv/sync/sync_chain_lttv.c index dc207bab..7fd0c6e4 100644 --- a/lttv/lttv/sync/sync_chain_lttv.c +++ b/lttv/lttv/sync/sync_chain_lttv.c @@ -33,6 +33,15 @@ #include #include + +#include "event_processing_lttng_standard.h" +#include "event_processing_lttng_null.h" +#include "event_matching_tcp.h" +#include "event_matching_broadcast.h" +#include "event_matching_distributor.h" +#include "event_analysis_chull.h" +#include "event_analysis_linreg.h" +#include "event_analysis_eval.h" #include "sync_chain.h" #include "sync_chain_lttv.h" @@ -80,13 +89,7 @@ static ModuleOption optionSyncGraphsDir= { /* * Module init function * - * This function is declared to be the module initialization function. Event - * modules are registered with a "constructor (102)" attribute except one in - * each class (processing, matching, analysis) which is chosen to be the - * default and which is registered with a "constructor (101)" attribute. - * Constructors with no priority are called after constructors with - * priorities. The result is that the list of event modules is known when this - * function is executed. + * This function is declared to be the module initialization function. */ static void init() { @@ -94,6 +97,24 @@ static void init() g_debug("Sync init"); + /* + * Initialize event modules + * Call the "constructor" or initialization function of each event module + * so it can register itself. This must be done before elements in + * processingModules, matchingModules, analysisModules or moduleOptions + * are accessed. + */ + registerProcessingLTTVStandard(); + registerProcessingLTTVNull(); + + registerMatchingTCP(); + registerMatchingBroadcast(); + registerMatchingDistributor(); + + registerAnalysisCHull(); + registerAnalysisLinReg(); + registerAnalysisEval(); + g_assert(g_queue_get_length(&analysisModules) > 0); optionSyncAnalysis.arg= ((AnalysisModule*) g_queue_peek_head(&analysisModules))->name; diff --git a/lttv/lttv/sync/sync_chain_unittest.c b/lttv/lttv/sync/sync_chain_unittest.c index 5d475ea8..79b3b58f 100644 --- a/lttv/lttv/sync/sync_chain_unittest.c +++ b/lttv/lttv/sync/sync_chain_unittest.c @@ -35,6 +35,13 @@ #include #include +#include "event_processing_text.h" +#include "event_matching_tcp.h" +#include "event_matching_broadcast.h" +#include "event_matching_distributor.h" +#include "event_analysis_chull.h" +#include "event_analysis_linreg.h" +#include "event_analysis_eval.h" #include "sync_chain.h" @@ -100,6 +107,23 @@ int main(const int argc, char* const argv[]) GString* analysisModulesNames; unsigned int id; + /* + * Initialize event modules + * Call the "constructor" or initialization function of each event module + * so it can register itself. This must be done before elements in + * processingModules, matchingModules, analysisModules or moduleOptions + * are accessed. + */ + registerProcessingText(); + + registerMatchingTCP(); + registerMatchingBroadcast(); + registerMatchingDistributor(); + + registerAnalysisCHull(); + registerAnalysisLinReg(); + registerAnalysisEval(); + // Initialize data structures syncState= malloc(sizeof(SyncState));