Do not use __attribute__((constructor))
authorBenjamin Poirier <benjamin.poirier@polymtl.ca>
Mon, 8 Feb 2010 18:51:19 +0000 (13:51 -0500)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Mon, 8 Feb 2010 18:54:59 +0000 (13:54 -0500)
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 <benjamin.poirier@polymtl.ca>
20 files changed:
lttv/lttv/sync/event_analysis_chull.c
lttv/lttv/sync/event_analysis_chull.h
lttv/lttv/sync/event_analysis_eval.c
lttv/lttv/sync/event_analysis_eval.h
lttv/lttv/sync/event_analysis_linreg.c
lttv/lttv/sync/event_analysis_linreg.h
lttv/lttv/sync/event_matching_broadcast.c
lttv/lttv/sync/event_matching_broadcast.h
lttv/lttv/sync/event_matching_distributor.c
lttv/lttv/sync/event_matching_distributor.h
lttv/lttv/sync/event_matching_tcp.c
lttv/lttv/sync/event_matching_tcp.h
lttv/lttv/sync/event_processing_lttng_null.c
lttv/lttv/sync/event_processing_lttng_null.h
lttv/lttv/sync/event_processing_lttng_standard.c
lttv/lttv/sync/event_processing_lttng_standard.h
lttv/lttv/sync/event_processing_text.c
lttv/lttv/sync/event_processing_text.h
lttv/lttv/sync/sync_chain_lttv.c
lttv/lttv/sync/sync_chain_unittest.c

index 8e965b72a7e1296de507cfe187f893f4784d5ae3..6f098b6d0890cefa1af477c2f9038c36307117bf 100644 (file)
@@ -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);
 }
index b82596b97009dbe4355b95867607a859bd3ccc49..07942cc9aa031a0d8dd88d718bdc727a36f32a6d 100644 (file)
@@ -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
index 0c0b7b51a80e86fc3cb48cbf104e9bb14aca369c..6b96102071ddedea3ae42288ec7f86abfb0b72c7 100644 (file)
@@ -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));
 
index c0b02d0daa53d5277b8050000e0d1a1f4d71c127..05d86601506f24d32539ff2d70851f0158b84e01 100644 (file)
@@ -153,4 +153,6 @@ typedef struct
        AnalysisGraphsEval* graphs;
 } AnalysisDataEval;
 
+void registerAnalysisEval();
+
 #endif
index 07537780bcb8ae4ced81d91622c5bbad2920be3b..7011f96fb55aac14251553b8b228493e3ed11c18 100644 (file)
@@ -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);
 }
index 60002e3ecfddcabc80db49fd673ff0a2321a0b63..0eafe3f6baa02604fae2f96cb4c64962d047eaeb 100644 (file)
@@ -49,4 +49,6 @@ typedef struct
        double* stDev;
 } AnalysisDataLinReg;
 
+void registerAnalysisLinReg();
+
 #endif
index 968856979b157496dcd6c00ac5c2d64e7740c758..1bc5d75e510492a5e18006ab97490d2cf154009e 100644 (file)
@@ -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);
 }
index 8006cdd1d33e8a99ef9c62cc03267487b5170ff0..d9c4fbfad8e9df5d43c8e391280e8a8ceff1fe36 100644 (file)
@@ -65,4 +65,6 @@ typedef struct
        MatchingGraphsBroadcast* graphs;
 } MatchingDataBroadcast;
 
+void registerMatchingBroadcast();
+
 #endif
index 4bb7e68cd50dd9158dadd414b4c4b0cd642795a6..6ea6c0fd95f3c1add42284e69161448e0c1b742d 100644 (file)
@@ -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);
 }
index b4399e5c6727799650ac0479a90a9f35cf19d93d..e5e071acab9656f94ce77ad5e55fd78f56b0475b 100644 (file)
@@ -31,4 +31,6 @@ typedef struct
        GQueue* distributedModules;
 } MatchingDataDistributor;
 
+void registerMatchingDistributor();
+
 #endif
index 9ba8b63265463670db782c8dddb57b72f76890c3..5f3aa934e4c87564945b9d874daf554c9c51522c 100644 (file)
@@ -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);
 }
index 2687aa2117416cbc5d1b6047f102cbfe8c38402a..9ec887a5351830f216a8891f25005ef91118f4dc 100644 (file)
@@ -60,4 +60,6 @@ typedef struct
        FILE*** messagePoints;
 } MatchingDataTCP;
 
+void registerMatchingTCP();
+
 #endif
index 8970e0363ef1cebcc7fc984857042a4ab90964a9..3a917317af7bdee2d4c8805c13b33573210aa7e9 100644 (file)
@@ -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);
 
index 9204b8fb4802d5512eb7f37726db414c1f011588..8e01c58c3bda3ee85c6b482f0972d2ea8a32440d 100644 (file)
@@ -35,4 +35,6 @@ typedef struct
        GArray* hookListList;
 } ProcessingDataLTTVNull;
 
+void registerProcessingLTTVNull();
+
 #endif
index 876dac0858c501838e3c108b88af9194c094f527..55806dfa8922826c814a4c6ed5c6eee2e265e606 100644 (file)
@@ -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);
 
index 3875e39850357312256c0d74d3daebada57eb51f..419aac2b672fcb60c6582dc1a0d5013fb246cd59 100644 (file)
@@ -61,4 +61,6 @@ typedef struct
        ProcessingGraphsLTTVStandard* graphs;
 } ProcessingDataLTTVStandard;
 
+void registerProcessingLTTVStandard();
+
 #endif
index 8471096a6d07d90af439843196d4321c76cde370..238d658cd3d15bd2ff8f39ebbde6652ff7689b11 100644 (file)
@@ -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);
 }
index 0fda7786d508759973178832782ff55e07ccad49..451b7b99f43aca9c05b182d0cfd47b46f93c1345 100644 (file)
@@ -29,4 +29,6 @@ typedef struct
        FILE* testCase;
 } ProcessingDataText;
 
+void registerProcessingText();
+
 #endif
index dc207babfb6bb949c46764c0fb4dce53787c874b..7fd0c6e435666300fa646cdddf90b692af97629e 100644 (file)
 #include <lttv/module.h>
 #include <lttv/option.h>
 
+
+#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;
index 5d475ea8008f97c15d4ff548185a7d0ec842b109..79b3b58fd764b401303dfe3aefab8b0538bba32f 100644 (file)
 #include <sys/stat.h>
 #include <unistd.h>
 
+#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));
 
This page took 0.032227 seconds and 4 git commands to generate.