[Avida-SVN] r1737 - in development: . Avida.xcodeproj source/analyze source/cpu source/main source/platform source/targets/avida source/targets/avida-s source/targets/avida-viewer source/targets/unit-tests source/tools support/config tests/analyze_truncate_lineage_fulllandscape/config
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Sat Jun 30 11:26:30 PDT 2007
Author: brysonda
Date: 2007-06-30 14:26:30 -0400 (Sat, 30 Jun 2007)
New Revision: 1737
Added:
development/source/platform/PlatformExpert.cc
development/source/platform/PlatformExpert.h
development/source/platform/cConditionVariable.h
development/source/platform/cMutex.h
development/source/platform/cRWLock.h
development/source/platform/cThread.cc
development/source/platform/cThread.h
development/source/platform/platform.h
Removed:
development/source/tools/cConditionVariable.h
development/source/tools/cMutex.h
development/source/tools/cRWLock.h
development/source/tools/cThread.cc
development/source/tools/cThread.h
development/source/tools/platform.h
Modified:
development/Avida.xcodeproj/project.pbxproj
development/CMakeLists.txt
development/source/analyze/cAnalyzeJobQueue.cc
development/source/analyze/cAnalyzeJobQueue.h
development/source/cpu/cHardwareGX.cc
development/source/cpu/cHardwareGX.h
development/source/main/cAvidaConfig.h
development/source/main/cDeme.cc
development/source/main/cDeme.h
development/source/main/cGermline.h
development/source/main/cSaleItem.h
development/source/platform/FloatingPoint.h
development/source/targets/avida-s/main.cc
development/source/targets/avida-viewer/viewer.cc
development/source/targets/avida/primitive.cc
development/source/targets/unit-tests/main.cc
development/source/tools/cFlexVar.h
development/source/tools/cRandom.cc
development/source/tools/tList.h
development/support/config/avida.cfg
development/tests/analyze_truncate_lineage_fulllandscape/config/avida.cfg
Log:
- Add in support for automatic processor count detection (on Linux and Mac OS).
- Change MT_CONCURRENCY to MAX_CONCURRENCY. This setting will now cap the maximum number of threads used. By default all available CPUs will be utilized (a setting of < 1 will trigger this behavior).
- Consolidate some initialization methods into a central PlatformExpert::Initialize() function.
- Fix a DEBUG mode race condition in cMutex that would incorrectly mark locked threads as unlocked.
- Move threading classes into platform/
- Increase cAnalyzeJobQueue's cRandomMT pool size to 128 in order to reduce RNG contention larger multiprocessors (>4 CPUs).
- *FIXED* missing header formats and improper include guards on a number of files and repaired some incorrectly named member variables. Please see documentation/code_standards.html for formatting and naming convention details.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/Avida.xcodeproj/project.pbxproj 2007-06-30 18:26:30 UTC (rev 1737)
@@ -119,7 +119,6 @@
7023EC950C0A431B00362B9C /* cTaskLib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0872D08F5E82D00FC65FE /* cTaskLib.cc */; };
7023EC960C0A431B00362B9C /* cTestCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F02808C3C71300F50912 /* cTestCPU.cc */; };
7023EC970C0A431B00362B9C /* cTestCPUInterface.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */; };
- 7023EC980C0A431B00362B9C /* cThread.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7054A11F09A7BEFC00038658 /* cThread.cc */; };
7023EC990C0A431B00362B9C /* cTools.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B08B9008FB2E6B00FC65FE /* cTools.cc */; };
7023EC9A0C0A431B00362B9C /* cWeightedIndex.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B08B9108FB2E6B00FC65FE /* cWeightedIndex.cc */; };
7023EC9B0C0A431B00362B9C /* cWorld.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C5BC6309059A970028A785 /* cWorld.cc */; };
@@ -166,6 +165,8 @@
7039884F09F00D060052ACE7 /* environment.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 707AF2D709EE8501001AEA89 /* environment.cfg */; };
7039885009F00D080052ACE7 /* events.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 707AF2D809EE8501001AEA89 /* events.cfg */; };
704368D60C31991500A05ABA /* ASTree.cc in Sources */ = {isa = PBXBuildFile; fileRef = 704368CC0C3198F200A05ABA /* ASTree.cc */; };
+ 70436B280C36C64400A05ABA /* cThread.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70436B230C36C64000A05ABA /* cThread.cc */; };
+ 70436B6C0C36C98900A05ABA /* PlatformExpert.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70436B260C36C64000A05ABA /* PlatformExpert.cc */; };
7049F3560A66A8F500640512 /* instset-classic.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F3520A66A8F500640512 /* instset-classic.cfg */; };
7049F3570A66A8F500640512 /* instset-sex-classic.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F3530A66A8F500640512 /* instset-sex-classic.cfg */; };
7049F3580A66A8F500640512 /* instset-smt.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F3540A66A8F500640512 /* instset-smt.cfg */; };
@@ -332,10 +333,6 @@
7005A70109BA0FA90007E16E /* cTestCPUInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cTestCPUInterface.h; sourceTree = "<group>"; };
7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cTestCPUInterface.cc; sourceTree = "<group>"; };
7005A70909BA0FBE0007E16E /* cOrgInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cOrgInterface.h; sourceTree = "<group>"; };
- 7009DF370B991AC100070F8F /* cMutex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cMutex.h; sourceTree = "<group>"; };
- 7009DF400B991C6200070F8F /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platform.h; sourceTree = "<group>"; };
- 7009E09D0B9A29BC00070F8F /* cConditionVariable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cConditionVariable.h; sourceTree = "<group>"; };
- 7009E0C50B9A2FAC00070F8F /* cRWLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cRWLock.h; sourceTree = "<group>"; };
700AE91B09DB65F200A073FD /* cTaskContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cTaskContext.h; sourceTree = "<group>"; };
700E11BC0A0815B600B604CD /* cDataEntry.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cDataEntry.cc; sourceTree = "<group>"; };
700E28CF0859FFD700CF158A /* tObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tObjectFactory.h; sourceTree = "<group>"; };
@@ -369,15 +366,6 @@
702F52A80992F8F600B2B507 /* cSymbolTable.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cSymbolTable.cc; sourceTree = "<group>"; };
702F52DE0992FD8000B2B507 /* cScriptObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cScriptObject.h; sourceTree = "<group>"; };
702F52DF0992FD8000B2B507 /* cScriptObject.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cScriptObject.cc; sourceTree = "<group>"; };
- 703CA36D0A50729700AB4DB4 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
- 703CA36F0A5072B700AB4DB4 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
- 703CA3700A5072E600AB4DB4 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
- 703CA3710A50734500AB4DB4 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
- 703CA3720A50735B00AB4DB4 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
- 703CA3730A50737700AB4DB4 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
- 703CA3760A5073CD00AB4DB4 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
- 703CA3770A50740300AB4DB4 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
- 703CA3780A50749F00AB4DB4 /* SConstruct */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConstruct; sourceTree = "<group>"; };
703D4D6D0ABA374A0032C8A0 /* cArgSchema.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cArgSchema.cc; sourceTree = "<group>"; };
70422A1C091B141000A5E67F /* cAnalyze.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyze.cc; sourceTree = "<group>"; };
70422A1D091B141000A5E67F /* cAnalyze.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyze.h; sourceTree = "<group>"; };
@@ -392,6 +380,14 @@
704368CC0C3198F200A05ABA /* ASTree.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ASTree.cc; sourceTree = "<group>"; };
704368CD0C3198F200A05ABA /* ASTree.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ASTree.h; sourceTree = "<group>"; };
704368F50C32E6AB00A05ABA /* cFlexVar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cFlexVar.h; sourceTree = "<group>"; };
+ 70436B200C36C64000A05ABA /* cConditionVariable.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cConditionVariable.h; sourceTree = "<group>"; };
+ 70436B210C36C64000A05ABA /* cMutex.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMutex.h; sourceTree = "<group>"; };
+ 70436B220C36C64000A05ABA /* cRWLock.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cRWLock.h; sourceTree = "<group>"; };
+ 70436B230C36C64000A05ABA /* cThread.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cThread.cc; sourceTree = "<group>"; };
+ 70436B240C36C64000A05ABA /* cThread.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cThread.h; sourceTree = "<group>"; };
+ 70436B250C36C64000A05ABA /* platform.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = platform.h; sourceTree = "<group>"; };
+ 70436B260C36C64000A05ABA /* PlatformExpert.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformExpert.cc; sourceTree = "<group>"; };
+ 70436B270C36C64000A05ABA /* PlatformExpert.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PlatformExpert.h; sourceTree = "<group>"; };
7049F2D70A66859300640512 /* cHardwareTransSMT.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHardwareTransSMT.cc; sourceTree = "<group>"; };
7049F2D80A66859300640512 /* cHardwareTransSMT.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHardwareTransSMT.h; sourceTree = "<group>"; };
7049F3520A66A8F500640512 /* instset-classic.cfg */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = "instset-classic.cfg"; sourceTree = "<group>"; };
@@ -424,8 +420,6 @@
7053336C092A3DF4006BD186 /* nInjectGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = nInjectGenotype.h; sourceTree = "<group>"; };
705333E5092A4B7C006BD186 /* cLineage.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cLineage.cc; sourceTree = "<group>"; };
705333E6092A4B7C006BD186 /* cLineage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLineage.h; sourceTree = "<group>"; };
- 7054A11E09A7BEFC00038658 /* cThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cThread.h; sourceTree = "<group>"; };
- 7054A11F09A7BEFC00038658 /* cThread.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cThread.cc; sourceTree = "<group>"; };
7054A16E09A8014600038658 /* cAnalyzeJobQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cAnalyzeJobQueue.h; sourceTree = "<group>"; };
7054A16F09A8014600038658 /* cAnalyzeJobQueue.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeJobQueue.cc; sourceTree = "<group>"; };
7054A17909A802BC00038658 /* cAnalyzeJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cAnalyzeJob.h; sourceTree = "<group>"; };
@@ -484,7 +478,6 @@
707AF2F309EE8501001AEA89 /* organism.infected */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = organism.infected; sourceTree = "<group>"; };
707AF2F409EE8501001AEA89 /* organism.infected2 */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = organism.infected2; sourceTree = "<group>"; };
707AF2F509EE8501001AEA89 /* organism.noheads */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = organism.noheads; sourceTree = "<group>"; };
- 707AF2FF09EE8501001AEA89 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
707CE51D0A9E49A50022D19C /* config.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html.documentation; path = config.html; sourceTree = "<group>"; };
707CE7490AA333060022D19C /* actions.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html.documentation; path = actions.html; sourceTree = "<group>"; };
707CE7500AA334120022D19C /* analyze.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html.documentation; path = analyze.html; sourceTree = "<group>"; };
@@ -682,10 +675,6 @@
70BCB2470AB7B634003FF331 /* cArgSchema.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cArgSchema.h; sourceTree = "<group>"; };
70C054C80A4F6E19002703C1 /* PopulationActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopulationActions.h; sourceTree = "<group>"; };
70C054C90A4F6E19002703C1 /* PopulationActions.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PopulationActions.cc; sourceTree = "<group>"; };
- 70C054F10A4F6FF1002703C1 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
- 70C054F50A4F701B002703C1 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
- 70C054F60A4F7030002703C1 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
- 70C054F70A4F703D002703C1 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
70C1EF4608C393BA00F50912 /* cCodeLabel.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCodeLabel.cc; sourceTree = "<group>"; };
70C1EF4708C393BA00F50912 /* cCodeLabel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cCodeLabel.h; sourceTree = "<group>"; };
70C1EF5808C3948C00F50912 /* cCPUMemory.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCPUMemory.cc; sourceTree = "<group>"; };
@@ -755,7 +744,7 @@
70DCAC77097AF730002F8733 /* key_chart */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = key_chart; sourceTree = "<group>"; };
70DCAC78097AF730002F8733 /* viewer.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = viewer.cc; sourceTree = "<group>"; };
70DCAC9B097AF7C0002F8733 /* primitive.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = primitive.cc; sourceTree = "<group>"; };
- 70DCAD1C097AF7CC002F8733 /* avida-s */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "avida-s"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 70DCAD1C097AF7CC002F8733 /* avida-s */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = "avida-s"; sourceTree = BUILT_PRODUCTS_DIR; };
70DCAD1F097AF81A002F8733 /* AvidaScript.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AvidaScript.h; sourceTree = "<group>"; };
70DCAD20097AF81A002F8733 /* cLexer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLexer.h; sourceTree = "<group>"; };
70DCAD21097AF81A002F8733 /* cLexer.l */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.lex; path = cLexer.l; sourceTree = "<group>"; };
@@ -859,7 +848,6 @@
701D9115094B770B008B845F /* drivers */ = {
isa = PBXGroup;
children = (
- 703CA36D0A50729700AB4DB4 /* SConscript */,
701D9382094CBA69008B845F /* cDriverManager.cc */,
701D9116094B773E008B845F /* cWorldDriver.h */,
701D912B094B7AC1008B845F /* cAvidaDriver.h */,
@@ -888,7 +876,6 @@
709D924B0A5D950D00D6A163 /* cMutationalNeighborhood.cc */,
709D92490A5D94FD00D6A163 /* cMutationalNeighborhood.h */,
709D924A0A5D94FD00D6A163 /* cMutationalNeighborhoodResults.h */,
- 70C054F50A4F701B002703C1 /* SConscript */,
70F7DE76092967A8009E311D /* cGenotypeBatch.h */,
70422A1C091B141000A5E67F /* cAnalyze.cc */,
70422A1D091B141000A5E67F /* cAnalyze.h */,
@@ -914,7 +901,6 @@
707AEEEE09E80699001AEA89 /* actions */ = {
isa = PBXGroup;
children = (
- 70C054F10A4F6FF1002703C1 /* SConscript */,
707AEEEF09E80725001AEA89 /* cAction.h */,
707AEEFE09E83381001AEA89 /* cActionLibrary.h */,
707AF04409EAB529001AEA89 /* LandscapeActions.h */,
@@ -952,7 +938,6 @@
7049F3540A66A8F500640512 /* instset-smt.cfg */,
7049F3550A66A8F500640512 /* instset-transsmt.cfg */,
707AF2DD09EE8501001AEA89 /* misc */,
- 707AF2FF09EE8501001AEA89 /* SConscript */,
);
name = Support;
path = support/config;
@@ -1049,7 +1034,6 @@
70DCAC56097AF730002F8733 /* avida-s */,
70DCAC58097AF730002F8733 /* avida-viewer */,
701EF27D0BEA5D2300DAE168 /* unit-tests */,
- 703CA3710A50734500AB4DB4 /* SConscript */,
);
path = targets;
sourceTree = "<group>";
@@ -1057,7 +1041,6 @@
70DCAC55097AF730002F8733 /* avida */ = {
isa = PBXGroup;
children = (
- 703CA3720A50735B00AB4DB4 /* SConscript */,
70DCAC9B097AF7C0002F8733 /* primitive.cc */,
);
path = avida;
@@ -1084,7 +1067,6 @@
7099EF4E0B2FBC85001269F6 /* cTextViewerDriver_Base.cc */,
7099EF4F0B2FBC85001269F6 /* cTextViewerDriver_Base.h */,
7099EF500B2FBC85001269F6 /* cView_Base.h */,
- 703CA3730A50737700AB4DB4 /* SConscript */,
70DCAC59097AF730002F8733 /* cBarScreen.cc */,
70DCAC5A097AF730002F8733 /* cBarScreen.h */,
70DCAC5B097AF730002F8733 /* cBaseTextWindow.h */,
@@ -1147,8 +1129,15 @@
isa = PBXGroup;
children = (
70DCF50009CF823500924128 /* tcmalloc */,
- 703CA3700A5072E600AB4DB4 /* SConscript */,
+ 70436B200C36C64000A05ABA /* cConditionVariable.h */,
+ 70436B210C36C64000A05ABA /* cMutex.h */,
+ 70436B220C36C64000A05ABA /* cRWLock.h */,
+ 70436B230C36C64000A05ABA /* cThread.cc */,
+ 70436B240C36C64000A05ABA /* cThread.h */,
707D71280C00B9B300DD4D49 /* FloatingPoint.h */,
+ 70436B250C36C64000A05ABA /* platform.h */,
+ 70436B260C36C64000A05ABA /* PlatformExpert.cc */,
+ 70436B270C36C64000A05ABA /* PlatformExpert.h */,
);
path = platform;
sourceTree = "<group>";
@@ -1172,7 +1161,6 @@
70F7D8C8092546DC009E311D /* classification */ = {
isa = PBXGroup;
children = (
- 70C054F60A4F7030002703C1 /* SConscript */,
705333E5092A4B7C006BD186 /* cLineage.cc */,
705333E6092A4B7C006BD186 /* cLineage.h */,
70533363092A3DF4006BD186 /* cInjectGenotype_BirthData.h */,
@@ -1215,7 +1203,6 @@
DCC3164E07626CF3008F7A48 /* Products */,
70FB86A908BFAFEC00BDF589 /* CMakeLists.txt */,
70658C59085DF67D00486BED /* libncurses.5.4.dylib */,
- 703CA3780A50749F00AB4DB4 /* SConstruct */,
);
sourceTree = "<group>";
};
@@ -1234,7 +1221,6 @@
DCC314D8076253A2008F7A48 /* tools */,
701384A10902A16F0087ED2E /* defs.h */,
DCC30FCF0762539D008F7A48 /* Doxyfile */,
- 703CA3770A50740300AB4DB4 /* SConscript */,
);
name = "Main Source";
path = source;
@@ -1251,7 +1237,6 @@
70B1A64F0B7E237F00067486 /* cHardwareExperimental.cc */,
7049F2D70A66859300640512 /* cHardwareTransSMT.cc */,
7049F2D80A66859300640512 /* cHardwareTransSMT.h */,
- 70C054F70A4F703D002703C1 /* SConscript */,
70C1EF4608C393BA00F50912 /* cCodeLabel.cc */,
70C1EF4708C393BA00F50912 /* cCodeLabel.h */,
70C1EF5808C3948C00F50912 /* cCPUMemory.cc */,
@@ -1294,7 +1279,6 @@
706C6F480B83E69D003174C1 /* cSaleItem.h */,
708BF3010AB65DD300A923BF /* cEventList.h */,
708BF2FD0AB65DC700A923BF /* cEventList.cc */,
- 703CA36F0A5072B700AB4DB4 /* SConscript */,
DCC3109C0762539E008F7A48 /* avida.cc */,
70B086BE08F5D86100FC65FE /* avida.h */,
7013846009028B3E0087ED2E /* cAvidaConfig.cc */,
@@ -1379,7 +1363,6 @@
isa = PBXGroup;
children = (
704368F50C32E6AB00A05ABA /* cFlexVar.h */,
- 703CA3760A5073CD00AB4DB4 /* SConscript */,
7057886F0A21FE8D00E85D8E /* cFixedBlock.cc */,
705788700A21FE8D00E85D8E /* cFixedCoords.cc */,
700E11BC0A0815B600B604CD /* cDataEntry.cc */,
@@ -1484,17 +1467,11 @@
DCC315B1076253A5008F7A48 /* tVerifierSuiteRecurser.hh */,
700E28CF0859FFD700CF158A /* tObjectFactory.h */,
70B3984E0947B29D0018F09D /* tManagedPointerArray.h */,
- 7054A11E09A7BEFC00038658 /* cThread.h */,
- 7054A11F09A7BEFC00038658 /* cThread.cc */,
7093DB4009D6F50300DE7FEB /* tSmartArray.h */,
70BCB21B0AB7ADA6003FF331 /* cArgContainer.h */,
70BCB21C0AB7ADA6003FF331 /* cArgContainer.cc */,
70BCB2470AB7B634003FF331 /* cArgSchema.h */,
703D4D6D0ABA374A0032C8A0 /* cArgSchema.cc */,
- 7009DF370B991AC100070F8F /* cMutex.h */,
- 7009DF400B991C6200070F8F /* platform.h */,
- 7009E09D0B9A29BC00070F8F /* cConditionVariable.h */,
- 7009E0C50B9A2FAC00070F8F /* cRWLock.h */,
);
path = tools;
sourceTree = "<group>";
@@ -1837,7 +1814,6 @@
7023EC950C0A431B00362B9C /* cTaskLib.cc in Sources */,
7023EC960C0A431B00362B9C /* cTestCPU.cc in Sources */,
7023EC970C0A431B00362B9C /* cTestCPUInterface.cc in Sources */,
- 7023EC980C0A431B00362B9C /* cThread.cc in Sources */,
7023EC990C0A431B00362B9C /* cTools.cc in Sources */,
7023EC9A0C0A431B00362B9C /* cWeightedIndex.cc in Sources */,
7023EC9B0C0A431B00362B9C /* cWorld.cc in Sources */,
@@ -1847,6 +1823,8 @@
7023EC9F0C0A431B00362B9C /* PopulationActions.cc in Sources */,
7023ECA00C0A431B00362B9C /* PrintActions.cc in Sources */,
7023ECA10C0A431B00362B9C /* SaveLoadActions.cc in Sources */,
+ 70436B280C36C64400A05ABA /* cThread.cc in Sources */,
+ 70436B6C0C36C98900A05ABA /* PlatformExpert.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: development/CMakeLists.txt
===================================================================
--- development/CMakeLists.txt 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/CMakeLists.txt 2007-06-30 18:26:30 UTC (rev 1737)
@@ -221,6 +221,11 @@
# The platform directory
SET(PLATFORM_DIR ${PROJECT_SOURCE_DIR}/source/platform)
+SET(PLATFORM_SOURCES
+ ${PLATFORM_DIR}/cThread.cc
+ ${PLATFORM_DIR}/PlatformExpert.cc
+)
+LIST(APPEND AVIDA_CORE_SOURCES ${PLATFORM_SOURCES})
LIST(APPEND ALL_INC_DIRS ${PLATFORM_DIR})
@@ -255,7 +260,6 @@
${TOOLS_DIR}/cStringIterator.cc
${TOOLS_DIR}/cStringList.cc
${TOOLS_DIR}/cStringUtil.cc
- ${TOOLS_DIR}/cThread.cc
${TOOLS_DIR}/cTools.cc
${TOOLS_DIR}/cWeightedIndex.cc
)
Modified: development/source/analyze/cAnalyzeJobQueue.cc
===================================================================
--- development/source/analyze/cAnalyzeJobQueue.cc 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/analyze/cAnalyzeJobQueue.cc 2007-06-30 18:26:30 UTC (rev 1737)
@@ -27,14 +27,17 @@
#include "cAnalyzeJobWorker.h"
#include "cWorld.h"
#include "cWorldDriver.h"
+#include "PlatformExpert.h"
-
#include "defs.h"
cAnalyzeJobQueue::cAnalyzeJobQueue(cWorld* world)
-: m_world(world), m_last_jobid(0), m_jobs(0), m_pending(0), m_workers(world->GetConfig().MT_CONCURRENCY.Get())
+: m_world(world), m_last_jobid(0), m_jobs(0), m_pending(0), m_workers(PlatformExpert::AvailableCPUs())
{
+ const int max_workers = world->GetConfig().MAX_CONCURRENCY.Get();
+ if (max_workers > 0 && max_workers < m_workers.GetSize()) m_workers.Resize(max_workers);
+
for (int i = 0; i < MT_RANDOM_POOL_SIZE; i++) {
m_rng_pool[i] = new cRandomMT(world->GetRandom().GetInt(0x7FFFFFFF));
}
Modified: development/source/analyze/cAnalyzeJobQueue.h
===================================================================
--- development/source/analyze/cAnalyzeJobQueue.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/analyze/cAnalyzeJobQueue.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -48,8 +48,8 @@
class cWorld;
-const int MT_RANDOM_POOL_SIZE = 16;
-const int MT_RANDOM_INDEX_MASK = 0xF;
+const int MT_RANDOM_POOL_SIZE = 128;
+const int MT_RANDOM_INDEX_MASK = 0x7F;
class cAnalyzeJobQueue
Modified: development/source/cpu/cHardwareGX.cc
===================================================================
--- development/source/cpu/cHardwareGX.cc 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/cpu/cHardwareGX.cc 2007-06-30 18:26:30 UTC (rev 1737)
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
+
#include <climits>
#include <fstream>
#include <algorithm>
Modified: development/source/cpu/cHardwareGX.h
===================================================================
--- development/source/cpu/cHardwareGX.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/cpu/cHardwareGX.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -2,6 +2,24 @@
* cHardwareGX.h
* Avida
*
+ * Copyright 1999-2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
* cHardwareGX enables gene expression as follows:
* 1) Unlike cHardware{CPU,SMT,TransSMT}, the genome is not directly
* executed by this organism. Instead, cHardwareGX enables portions of the
@@ -23,24 +41,7 @@
*
* \todo We need to abstract cOrganism and derive a new class
* that can accommodate multiple genome fragments.
- *
- *
- * Copyright 1999-2007 Michigan State University. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
+ *
*/
#ifndef cHardwareGX_h
#define cHardwareGX_h
Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/main/cAvidaConfig.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -337,7 +337,7 @@
CONFIG_ADD_VAR(SELL_PRICE, int, 0, "price offered by organisms attempting to sell");
CONFIG_ADD_GROUP(ANALYZE_GROUP, "Analysis Settings");
- CONFIG_ADD_VAR(MT_CONCURRENCY, int, 1, "Number of concurrent analyze threads");
+ CONFIG_ADD_VAR(MAX_CONCURRENCY, int, -1, "Maximum number of analyze threads, -1 == use all available.");
CONFIG_ADD_VAR(ANALYZE_OPTION_1, cString, "", "String variable accessible from analysis scripts");
CONFIG_ADD_VAR(ANALYZE_OPTION_2, cString, "", "String variable accessible from analysis scripts");
Modified: development/source/main/cDeme.cc
===================================================================
--- development/source/main/cDeme.cc 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/main/cDeme.cc 2007-06-30 18:26:30 UTC (rev 1737)
@@ -20,23 +20,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
+
#include "cDeme.h"
-cDeme::cDeme()
-: width(0)
-, birth_count(0)
-, org_count(0)
-, _age(0)
-{
-}
-
-
-cDeme::~cDeme()
-{
-}
-
-
void cDeme::Setup(const tArray<int> & in_cells, int in_width)
{
cell_ids = in_cells;
Modified: development/source/main/cDeme.h
===================================================================
--- development/source/main/cDeme.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/main/cDeme.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
+
#ifndef cDeme_h
#define cDeme_h
@@ -27,16 +28,29 @@
#include "tArray.h"
-
/*! Demes are groups of cells in the population that are somehow bound together
as a unit. The deme object is used from within cPopulation to manage these
groups. */
-class cDeme {
+
+class cDeme
+{
+private:
+ tArray<int> cell_ids;
+ int width; //!< Width of this deme.
+ int birth_count; //!< Number of organisms that have been born into this deme since reset.
+ int org_count; //!< Number of organisms are currently in this deme.
+ int _age; //!< Age of this deme, in updates.
+
+ cGermline _germline; //!< The germline for this deme, if used.
+
+ cDeme(const cDeme&); // @not_implemented
+
+
public:
- cDeme();
- ~cDeme();
+ cDeme() : width(0), birth_count(0), org_count(0), _age(0) { ; }
+ ~cDeme() { ; }
- void Setup(const tArray<int> & in_cells, int in_width=-1);
+ void Setup(const tArray<int>& in_cells, int in_width = -1);
int GetSize() const { return cell_ids.GetSize(); }
int GetCellID(int pos) const { return cell_ids[pos]; }
@@ -71,14 +85,6 @@
updates since the last time Reset() was called. */
int GetAge() const { return _age; }
-private:
- tArray<int> cell_ids;
- int width; //!< Width of this deme.
- int birth_count; //!< Number of organisms that have been born into this deme since reset.
- int org_count; //!< Number of organisms are currently in this deme.
- int _age; //!< Age of this deme, in updates.
-
- cGermline _germline; //!< The germline for this deme, if used.
};
#endif
Modified: development/source/main/cGermline.h
===================================================================
--- development/source/main/cGermline.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/main/cGermline.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -1,19 +1,48 @@
-#ifndef _C_GERMLINE_H_
-#define _C_GERMLINE_H_
+/*
+ * cGermline.h
+ * Avida
+ *
+ * Copyright 2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef cGermline_h
+#define cGermline_h
+
#include <vector>
#include "cGenome.h"
-class cGermline {
+class cGermline
+{
+protected:
+ std::vector<cGenome> m_germline;
+
+ cGermline(const cGermline&); // @not_implmented
+
+
public:
- cGenome& GetLatest() { return _germline.back(); }
- void Add(const cGenome& genome) { _germline.push_back(genome); }
- unsigned int Size() const { return _germline.size(); }
-
-protected:
- std::vector<cGenome> _germline;
+ cGermline() { ; }
+
+ cGenome& GetLatest() { return m_germline.back(); }
+ void Add(const cGenome& genome) { m_germline.push_back(genome); }
+ unsigned int Size() const { return m_germline.size(); }
};
#endif
Modified: development/source/main/cSaleItem.h
===================================================================
--- development/source/main/cSaleItem.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/main/cSaleItem.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -1,50 +1,72 @@
+/*
+ * cSaleItem.h
+ * Avida
+ *
+ * Called "event_list.hh" prior to 12/2/05.
+ * Copyright 2006-2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
#ifndef cSaleItem_h
#define cSaleItem_h
-#ifndef cOrganism_H
+#ifndef cOrganism_h
#include "cOrganism.h"
#endif
class cSaleItem
+{
+private:
+ int m_data;
+ int m_label;
+ int m_price;
+ int m_org_id;
+ int m_cell_id;
+ tListNode<tListNode<cSaleItem> >* m_nodeptr;
+
+public:
+ cSaleItem() : m_data(0), m_label(0), m_price(0), m_org_id(0), m_cell_id(0) { ; }
+ cSaleItem(const int in_data, const int in_label, const int in_price,
+ const int in_org_id, const int in_cell_id) :
+ m_data(in_data),
+ m_label(in_label),
+ m_price(in_price),
+ m_org_id(in_org_id),
+ m_cell_id(in_cell_id)
+ {}
+
+ ~cSaleItem() { ; }
+ int GetData() { return m_data; }
+ void SetData(const int in_data) { m_data = in_data; }
+ int GetLabel() { return m_label; }
+ void SetLabel(const int in_label) { m_label = in_label; }
+ int GetPrice() { return m_price; }
+ void SetPrice(const int in_price) { m_price = in_price; }
+ int GetOrgID() { return m_org_id; }
+ int GetCellID() { return m_cell_id; }
+ void SetNodePtr(tListNode<tListNode<cSaleItem> >* in_nodeptr) { m_nodeptr = in_nodeptr; }
+ tListNode<tListNode<cSaleItem> >* GetNodePtr() { return m_nodeptr; }
+ bool operator == (cSaleItem &rhs)
{
- private:
- int m_data;
- int m_label;
- int m_price;
- int m_org_id;
- int m_cell_id;
- tListNode<tListNode<cSaleItem> >* m_nodeptr;
+ return ( (m_data == rhs.GetData()) && (m_label == rhs.GetLabel()) &&
+ (m_org_id == rhs.GetOrgID()) && (m_price == rhs.GetPrice()) &&
+ (m_cell_id == rhs.GetCellID()));
+ }
+};
- public:
- cSaleItem() : m_data(0), m_label(0), m_price(0), m_org_id(0), m_cell_id(0) { ; }
- cSaleItem(const int in_data, const int in_label, const int in_price,
- const int in_org_id, const int in_cell_id) :
- m_data(in_data),
- m_label(in_label),
- m_price(in_price),
- m_org_id(in_org_id),
- m_cell_id(in_cell_id)
- {}
-
- ~cSaleItem()
- {
- }
- int GetData() { return m_data; }
- void SetData(const int in_data) { m_data = in_data; }
- int GetLabel() { return m_label; }
- void SetLabel(const int in_label) { m_label = in_label; }
- int GetPrice() { return m_price; }
- void SetPrice(const int in_price) { m_price = in_price; }
- int GetOrgID() { return m_org_id; }
- int GetCellID() { return m_cell_id; }
- void SetNodePtr(tListNode<tListNode<cSaleItem> >* in_nodeptr) {
- m_nodeptr = in_nodeptr; }
- tListNode<tListNode<cSaleItem> >* GetNodePtr() { return m_nodeptr; }
- bool operator == (cSaleItem &rhs)
- {
- return ( (m_data == rhs.GetData()) && (m_label == rhs.GetLabel()) &&
- (m_org_id == rhs.GetOrgID()) && (m_price == rhs.GetPrice()) &&
- (m_cell_id == rhs.GetCellID()));
- }
- };
#endif
Modified: development/source/platform/FloatingPoint.h
===================================================================
--- development/source/platform/FloatingPoint.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/platform/FloatingPoint.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -5,6 +5,21 @@
* Created by David on 5/20/07.
* Copyright 2007 Michigan State University. All rights reserved.
*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#ifndef FloatingPoint_h
Added: development/source/platform/PlatformExpert.cc
===================================================================
--- development/source/platform/PlatformExpert.cc (rev 0)
+++ development/source/platform/PlatformExpert.cc 2007-06-30 18:26:30 UTC (rev 1737)
@@ -0,0 +1,74 @@
+/*
+ * PlatformExpert.cc
+ * Avida
+ *
+ * Created by David on 6/29/07.
+ * Copyright 2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "PlatformExpert.h"
+
+#include "platform.h"
+
+#if AVIDA_PLATFORM(APPLE)
+# include <mach/mach.h>
+#elif AVIDA_PLATFORM(UNIX)
+# include <unistd.h>
+#endif
+
+#include <csignal>
+
+#include "avida.h"
+#include "cDriverManager.h"
+#include "FloatingPoint.h"
+
+
+namespace PlatformExpert
+{
+ //! Initialize various platform settings and system handlers
+ void Initialize()
+ {
+ SetupFloatingPointEnvironment();
+
+ // Catch Interrupt making sure to close appropriately
+ signal(SIGINT, ExitAvida);
+
+ cDriverManager::Initialize();
+ }
+
+
+ //! Autodetect the number of CPUs on a box, if available. Otherwise, return 1.
+ int AvailableCPUs()
+ {
+ int ncpus = 1;
+
+#if AVIDA_PLATFORM(APPLE)
+ kern_return_t kr;
+ host_basic_info_data_t p_host_info;
+ mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
+ kr = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&p_host_info, &count);
+ if (kr == KERN_SUCCESS) ncpus = (int)(p_host_info.avail_cpus);
+#elif AVIDA_PLATFORM(UNIX) && defined(_SC_NPROCESSORS_ONLN)
+ ncpus = (int)sysconf(_SC_NPROCESSORS_ONLN);
+#endif
+
+ return ncpus;
+ }
+
+};
Added: development/source/platform/PlatformExpert.h
===================================================================
--- development/source/platform/PlatformExpert.h (rev 0)
+++ development/source/platform/PlatformExpert.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -0,0 +1,36 @@
+/*
+ * PlatformExpert.h
+ * Avida
+ *
+ * Created by David on 6/29/07.
+ * Copyright 2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PlatformExpert_h
+#define PlatformExpert_h
+
+
+namespace PlatformExpert
+{
+ void Initialize();
+
+ int AvailableCPUs();
+};
+
+#endif
Copied: development/source/platform/cConditionVariable.h (from rev 1736, development/source/tools/cConditionVariable.h)
===================================================================
--- development/source/platform/cConditionVariable.h (rev 0)
+++ development/source/platform/cConditionVariable.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -0,0 +1,123 @@
+/*
+ * cConditionVariable.h
+ * Avida
+ *
+ * Created by David on 3/3/07.
+ * Copyright 2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef cConditionVariable_h
+#define cConditionVariable_h
+
+#ifndef cMutex_h
+#include "cMutex.h"
+#endif
+#ifndef platform_h
+#include "platform.h"
+#endif
+
+
+#if AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(UNIX)
+
+// Use POSIX Threads
+# include <pthread.h>
+
+class cConditionVariable
+{
+private:
+ pthread_cond_t m_cond;
+
+ cConditionVariable(const cConditionVariable&); // @not_implemented
+ cConditionVariable& operator=(const cConditionVariable&); // @not_implemented
+
+
+public:
+ inline cConditionVariable() { pthread_cond_init(&m_cond, NULL); }
+ inline ~cConditionVariable() { pthread_cond_destroy(&m_cond); }
+
+#ifdef DEBUG
+ void Wait(cMutex& mutex)
+ {
+ mutex.m_locked = false;
+ pthread_cond_wait(&m_cond, &(mutex.m_mutex));
+ mutex.m_locked = true;
+ }
+#else
+ inline void Wait(cMutex& mutex) { pthread_cond_wait(&m_cond, &(mutex.m_mutex)); }
+#endif
+
+ inline void Signal() { pthread_cond_signal(&m_cond); }
+ inline void Broadcast() { pthread_cond_broadcast(&m_cond); }
+};
+
+#elif AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(WINDOWS)
+
+// Use Windows Threading
+# include <windows.h>
+class cConditionVariable
+{
+private:
+ CONDITION_VARIABLE m_cond;
+
+ cConditionVariable(const cConditionVariable&); // @not_implemented
+ cConditionVariable& operator=(const cConditionVariable&); // @not_implemented
+
+
+public:
+ inline cConditionVariable() { InitializeConditionVariable(&m_cond); }
+ inline ~cConditionVariable() { ; }
+
+#ifdef DEBUG
+ void Wait(cMutex& mutex)
+ {
+ mutex.m_locked = false;
+ SleepConditionVariableCS(&m_cond, &(mutex.m_mutex));
+ mutex.m_locked = true;
+ }
+#else
+ inline void Wait(cMutex& mutex) { SleepConditionVariableCS(&m_cond, &(mutex.m_mutex)); }
+#endif
+
+ inline void Signal() { WakeConditionVariable(&m_cond); }
+ inline void Broadcast() { WakeAllConditionVariable(&m_cond); }
+};
+
+
+#else
+
+// Disable Threading
+class cConditionVariable
+{
+private:
+ cConditionVariable(const cConditionVariable&); // @not_implemented
+ cConditionVariable& operator=(const cConditionVariable&); // @not_implemented
+
+public:
+ inline cConditionVariable() { ; }
+ inline ~cConditionVariable() { ; }
+
+ inline void Wait(cMutex& mutex) { ; }
+
+ inline void Signal() { ; }
+ inline void Broadcast() { ; }
+};
+
+#endif
+
+#endif
Copied: development/source/platform/cMutex.h (from rev 1736, development/source/tools/cMutex.h)
===================================================================
--- development/source/platform/cMutex.h (rev 0)
+++ development/source/platform/cMutex.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -0,0 +1,207 @@
+/*
+ * cMutex.h
+ * Avida
+ *
+ * Created by David on 3/2/07.
+ * Copyright 2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef cMutex_h
+#define cMutex_h
+
+#ifndef platform_h
+#include "platform.h"
+#endif
+
+
+#if AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(UNIX)
+
+// Use POSIX Threads
+# include <pthread.h>
+
+#ifdef DEBUG
+# define PTHREAD_MUTEX_CHKRTN(OP) \
+ { \
+ int ret = OP; \
+ ASSERT_MSG(ret == 0, "OP failed"); \
+ }
+#else
+# define PTHREAD_MUTEX_CHKRTN(OP) OP
+#endif
+
+class cMutex
+{
+ friend class cConditionVariable;
+private:
+ pthread_mutex_t m_mutex;
+#ifdef DEBUG
+ bool m_locked;
+#endif
+
+ cMutex(const cMutex&); // @not_implemented
+ cMutex& operator=(const cMutex&); // @not_implemented
+
+
+public:
+#ifdef DEBUG
+ cMutex() : m_locked(false) { PTHREAD_MUTEX_CHKRTN(pthread_mutex_init(&m_mutex, NULL)); }
+#else
+ inline cMutex() { PTHREAD_MUTEX_CHKRTN(pthread_mutex_init(&m_mutex, NULL)); }
+#endif
+
+ inline ~cMutex()
+ {
+ ASSERT_MSG(!m_locked, "destroying locked mutex");
+ PTHREAD_MUTEX_CHKRTN(pthread_mutex_destroy(&m_mutex));
+ }
+
+#ifdef DEBUG
+ void Lock()
+ {
+ PTHREAD_MUTEX_CHKRTN(pthread_mutex_lock(&m_mutex));
+ m_locked = true;
+ }
+#else
+ inline void Lock() { PTHREAD_MUTEX_CHKRTN(pthread_mutex_lock(&m_mutex)); }
+#endif
+
+#ifdef DEBUG
+ void Unlock()
+ {
+ ASSERT_MSG(m_locked, "mutex not locked");
+ m_locked = false;
+ PTHREAD_MUTEX_CHKRTN(pthread_mutex_unlock(&m_mutex));
+ }
+#else
+ inline void Unlock() { PTHREAD_MUTEX_CHKRTN(pthread_mutex_unlock(&m_mutex)); }
+#endif
+};
+
+#elif AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(WINDOWS)
+
+// Use Windows Threading
+# include <windows.h>
+
+class cMutex
+{
+ friend class cConditionVariable;
+private:
+ CRITICAL_SECTION m_mutex;
+#ifdef DEBUG
+ bool m_locked;
+#endif
+
+ cMutex(const cMutex&); // @not_implemented
+ cMutex& operator=(const cMutex&); // @not_implemented
+
+
+public:
+#ifdef DEBUG
+ cMutex() : m_locked(false) { InitializeCriticalSection(&m_mutex); }
+#else
+ inline cMutex() { InitializeCriticalSection(&m_mutex); }
+#endif
+
+ inline ~cMutex()
+ {
+ ASSERT_MSG(!m_locked, "destroying locked mutex");
+ DeleteCriticalSection(&m_mutex);
+ }
+
+#ifdef DEBUG
+ void Lock()
+ {
+ EnterCriticalSection(&m_mutex);
+ m_locked = true;
+ }
+#else
+ inline void Lock() { EnterCriticalSection(&m_mutex); }
+#endif
+
+#ifdef DEBUG
+ void Unlock()
+ {
+ ASSERT_MSG(m_locked, "mutex not locked");
+ m_locked = false;
+ LeaveCriticalSection(&m_mutex);
+ }
+#else
+ inline void Unlock() { LeaveCriticalSection(&m_mutex); }
+#endif
+};
+
+
+#else
+
+// Disable Threading
+class cMutex
+{
+private:
+#ifdef DEBUG
+ bool m_locked;
+#endif
+
+ cMutex(const cMutex&); // @not_implemented
+ cMutex& operator=(const cMutex&); // @not_implemented
+
+
+public:
+#ifdef DEBUG
+ cMutex() : m_locked(false) { ; }
+#else
+ inline cMutex() { ; }
+#endif
+
+ inline ~cMutex() { ASSERT_MSG(!m_locked, "destroying locked mutex"); }
+
+#ifdef DEBUG
+ void Lock() { m_locked = true; }
+#else
+ inline void Lock() { ; }
+#endif
+
+#ifdef DEBUG
+ void Unlock()
+ {
+ ASSERT_MSG(m_locked, "mutex not locked");
+ m_locked = false;
+ }
+#else
+ inline void Unlock() { ; }
+#endif
+};
+
+#endif
+
+
+class cMutexAutoLock
+{
+private:
+ cMutex& m_mutex;
+
+ cMutexAutoLock(); // @not_implemented
+ cMutexAutoLock(const cMutexAutoLock&); // @not_implemented
+ cMutexAutoLock& operator=(const cMutexAutoLock&); // @not_implemented
+
+public:
+ inline explicit cMutexAutoLock(cMutex& mutex) : m_mutex(mutex) { m_mutex.Lock(); }
+ inline ~cMutexAutoLock() { m_mutex.Unlock(); }
+};
+
+#endif
Copied: development/source/platform/cRWLock.h (from rev 1736, development/source/tools/cRWLock.h)
===================================================================
--- development/source/platform/cRWLock.h (rev 0)
+++ development/source/platform/cRWLock.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -0,0 +1,105 @@
+/*
+ * cRWLock.h
+ * Avida
+ *
+ * Created by David on 3/3/07.
+ * Copyright 2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef cRWLock_h
+#define cRWLock_h
+
+#ifndef platform_h
+#include "platform.h"
+#endif
+
+
+#if AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(UNIX)
+
+// Use POSIX Threads
+# include <pthread.h>
+
+class cRWLock
+{
+private:
+ pthread_rwlock_t m_rwlock;
+
+ cRWLock(const cRWLock&); // @not_implemented
+ cRWLock& operator=(const cRWLock&); // @not_implemented
+
+public:
+ inline cRWLock() { pthread_rwlock_init(&m_rwlock, NULL); }
+ inline ~cRWLock() { pthread_rwlock_destroy(&m_rwlock); }
+
+ inline void ReadLock() { pthread_rwlock_rdlock(&m_rwlock); }
+ inline void ReadUnlock() { pthread_rwlock_unlock(&m_rwlock); }
+
+ inline void WriteLock() { pthread_rwlock_wrlock(&m_rwlock); }
+ inline void WriteUnlock() { pthread_rwlock_unlock(&m_rwlock); }
+};
+
+#elif AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(WINDOWS)
+
+// Use Windows Threading
+# include <windows.h>
+
+class cRWLock
+{
+private:
+ SRWLOCK m_rwlock;
+
+ cRWLock(const cRWLock&); // @not_implemented
+ cRWLock& operator=(const cRWLock&); // @not_implemented
+
+public:
+ inline cRWLock() { InitializeSRWLock(&m_rwlock); }
+ inline ~cRWLock() { ; }
+
+ inline void ReadLock() { AcquireSRWLockShared(&m_rwlock); }
+ inline void ReadUnlock() { ReleaseSRWLockShared(&m_rwlock); }
+
+ inline void WriteLock() { AcquireSRWLockExclusive(&m_rwlock); }
+ inline void WriteUnlock() { ReleaseSRWLockExclusive(&m_rwlock); }
+};
+
+
+
+#else
+
+class cRWLock
+{
+private:
+ cRWLock(const cRWLock&); // @not_implemented
+ cRWLock& operator=(const cRWLock&); // @not_implemented
+
+public:
+ inline cRWLock() { ; }
+ inline ~cRWLock() { ; }
+
+ inline void ReadLock() { ; }
+ inline void ReadUnlock() { ; }
+
+ inline void WriteLock() { ; }
+ inline void WriteUnlock() { ; }
+};
+
+
+#endif
+
+#endif
Copied: development/source/platform/cThread.cc (from rev 1736, development/source/tools/cThread.cc)
===================================================================
--- development/source/platform/cThread.cc (rev 0)
+++ development/source/platform/cThread.cc 2007-06-30 18:26:30 UTC (rev 1737)
@@ -0,0 +1,124 @@
+/*
+ * cThread.cc
+ * Avida
+ *
+ * Created by David on 2/18/06.
+ * Copyright 1999-2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "cThread.h"
+
+#if AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(UNIX)
+
+cThread::~cThread() { if (m_running) pthread_detach(m_thread); }
+
+bool cThread::Start()
+{
+ m_mutex.Lock();
+ if (!m_running) {
+ m_running = true;
+ m_mutex.Unlock();
+
+ // Create thread, mark as running when successful
+ int rval = pthread_create(&m_thread, NULL, &cThread::EntryPoint, this);
+ if (rval) m_running = false;
+ } else {
+ m_mutex.Unlock();
+ }
+
+ return m_running;
+}
+
+void cThread::Stop()
+{
+ if (m_running) {
+ // Close and clean up thread, set running to false
+ pthread_cancel(m_thread);
+ pthread_join(m_thread, NULL);
+ m_running = false;
+ }
+}
+
+void cThread::Join()
+{
+ if (m_running) {
+ pthread_join(m_thread, NULL);
+ m_running = false;
+ }
+}
+
+void* cThread::EntryPoint(void* arg)
+{
+ // Common entry point to start cThread objects
+ // Calls Run method of appropriate subclass to do the actual work
+ cThread* thread = static_cast<cThread*>(arg);
+ thread->Run();
+
+ pthread_exit(NULL);
+ return NULL;
+}
+
+
+#elif AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(WINDOWS)
+
+cThread::~cThread() { if (m_thread) CloseHandle(m_thread); }
+
+bool cThread::Start()
+{
+ cMutexAutoLock lock(m_mutex);
+
+ if (m_thread == 0) {
+ unsigned long tid = 0;
+ m_thread = (HANDLE)_beginthreadex(0, 0, &cThread::EntryPoint, this, 0, &tid);
+
+ if (m_thread) return true;
+ return false;
+ }
+
+ return true;
+}
+
+void cThread::Stop()
+{
+ if (m_thread) {
+ if (CloseHandle(m_thread) == TRUE) {
+ m_thread = 0;
+ }
+ }
+
+}
+
+void cThread::Join()
+{
+ if (m_thread) WaitForSingleObject(m_thread, INFINITE);
+}
+
+unsigned int __stdcall cThread::EntryPoint(void* arg)
+{
+ // Common entry point to start cThread objects
+ // Calls Run method of appropriate subclass to do the actual work
+ cThread* thread = static_cast<cThread*>(arg);
+ thread->Run();
+
+ _endthreadex(0);
+ return 0;
+}
+
+
+#endif
Copied: development/source/platform/cThread.h (from rev 1736, development/source/tools/cThread.h)
===================================================================
--- development/source/platform/cThread.h (rev 0)
+++ development/source/platform/cThread.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -0,0 +1,112 @@
+/*
+ * cThread.h
+ * Avida
+ *
+ * Created by David on 2/18/06.
+ * Copyright 2006-2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef cThread_h
+#define cThread_h
+
+#ifndef cMutex_h
+#include "cMutex.h"
+#endif
+
+
+#if AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(UNIX)
+
+// Use POSIX Threads
+#include <pthread.h>
+
+class cThread
+{
+protected:
+ pthread_t m_thread;
+ cMutex m_mutex;
+ bool m_running;
+
+ void Stop();
+
+ virtual void Run() = 0;
+
+ static void* EntryPoint(void* arg);
+
+ cThread(const cThread&); // @not_implemented
+ cThread& operator=(const cThread&); // @not_implemented
+
+public:
+ cThread() : m_running(false) { ; }
+ virtual ~cThread();
+
+ bool Start();
+ void Join();
+};
+
+#elif AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(WINDOWS)
+
+// Use Windows Threading
+#include <windows.h>
+
+class cThread
+{
+protected:
+ HANDLE m_thread;
+ cMutex m_mutex;
+
+ void Stop();
+
+ virtual void Run() = 0;
+
+ static unsigned int __stdcall EntryPoint(void* arg);
+
+ cThread(const cThread&); // @not_implemented
+ cThread& operator=(const cThread&); // @not_implemented
+
+public:
+ cThread() : m_thread(0) { ; }
+ virtual ~cThread();
+
+ bool Start();
+ void Join();
+};
+
+#else
+
+// Disable Threading
+class cThread
+{
+protected:
+ virtual void Run() = 0;
+
+ cThread(const cThread&); // @not_implemented
+ cThread& operator=(const cThread&); // @not_implemented
+
+public:
+ inline cThread() { ; }
+ virtual ~cThread() { ; }
+
+ inline bool Start() { Run(); return true; }
+ inline void Join() { ; }
+};
+
+#endif
+
+
+#endif
Copied: development/source/platform/platform.h (from rev 1736, development/source/tools/platform.h)
===================================================================
--- development/source/platform/platform.h (rev 0)
+++ development/source/platform/platform.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -0,0 +1,65 @@
+/*
+ * platform.h
+ * Avida
+ *
+ * Created by David on 3/2/07.
+ * Copyright 2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef platform_h
+#define platform_h
+
+// spaces between defined's parentheses and contained value are required by Visual Studio's preprocessor
+#define AVIDA_PLATFORM(PROP) (defined( AVIDA_PLATFORM_ ## PROP ) && AVIDA_PLATFORM_##PROP)
+
+#if defined(WIN32) || defined(_WIN32)
+# define AVIDA_PLATFORM_WINDOWS 1
+# ifdef ENABLE_THREADS
+# define AVIDA_PLATFORM_THREADS 1
+# else
+# define AVIDA_PLATFORM_THREADS 0
+# endif
+ // Disable warning C4355: 'this' : used in base member initializer list
+# pragma warning( disable : 4355 )
+#endif
+
+#if defined(__APPLE__) || defined(unix) || defined(__unix) || defined(__unix__) || defined (__NetBSD__) || defined(_AIX)
+# define AVIDA_PLATFORM_UNIX 1
+# define AVIDA_PLATFORM_THREADS 1
+#endif
+
+#if defined(__APPLE__)
+# define AVIDA_PLATFORM_APPLE 1
+#endif
+
+
+#ifdef DEBUG
+# include <cstdlib>
+# include <iostream>
+# define ASSERT_MSG(VALUE, MSG) if (!(VALUE)) { std::cerr << "Error: " << MSG << std::endl; abort(); }
+#else
+# define ASSERT_MSG(VALUE, MSG)
+#endif
+
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif
Modified: development/source/targets/avida/primitive.cc
===================================================================
--- development/source/targets/avida/primitive.cc 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/targets/avida/primitive.cc 2007-06-30 18:26:30 UTC (rev 1737)
@@ -21,30 +21,22 @@
*
*/
-#include <csignal>
-
#include "avida.h"
#include "cAvidaConfig.h"
#include "cDefaultAnalyzeDriver.h"
#include "cDefaultRunDriver.h"
-#include "cDriverManager.h"
#include "cWorld.h"
+#include "PlatformExpert.h"
-#include "FloatingPoint.h"
-
using namespace std;
+
int main(int argc, char * argv[])
{
- SetupFloatingPointEnvironment();
+ PlatformExpert::Initialize();
- // Catch Interrupt making sure to close appropriately
- signal(SIGINT, ExitAvida);
-
printVersionBanner();
-
- cDriverManager::Initialize();
-
+
// Initialize the configuration data...
cWorld* world = new cWorld(cAvidaConfig::LoadWithCmdLineArgs(argc, argv));
cAvidaDriver* driver = NULL;
@@ -61,4 +53,6 @@
// Exit Nicely
ExitAvida(0);
+
+ return 0;
}
Modified: development/source/targets/avida-s/main.cc
===================================================================
--- development/source/targets/avida-s/main.cc 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/targets/avida-s/main.cc 2007-06-30 18:26:30 UTC (rev 1737)
@@ -22,20 +22,24 @@
*
*/
+#include "avida.h"
#include "cASLibrary.h"
#include "cFile.h"
#include "cParser.h"
+#include "PlatformExpert.h"
-#include <iostream>
-
int main (int argc, char * const argv[])
{
+ PlatformExpert::Initialize();
+
cASLibrary* lib = new cASLibrary;
cParser* parser = new cParser(lib);
cFile file;
if (file.Open("main.asl")) parser->Parse(file);
+ ExitAvida(0);
+
return 0;
}
Modified: development/source/targets/avida-viewer/viewer.cc
===================================================================
--- development/source/targets/avida-viewer/viewer.cc 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/targets/avida-viewer/viewer.cc 2007-06-30 18:26:30 UTC (rev 1737)
@@ -30,23 +30,17 @@
#include "cTextViewerDriver.h"
#include "cWorld.h"
-#include "FloatingPoint.h"
+#include "PlatformExpert.h"
using namespace std;
int main(int argc, char * argv[])
{
- SetupFloatingPointEnvironment();
+ PlatformExpert::Initialize();
-
- // Catch Interrupt making sure to close appropriately
- signal(SIGINT, ExitAvida);
-
printVersionBanner();
- cDriverManager::Initialize();
-
// Initialize the configuration data...
cWorld* world = new cWorld(cAvidaConfig::LoadWithCmdLineArgs(argc, argv));
cAvidaDriver* driver = NULL;
@@ -63,4 +57,6 @@
// Exit Nicely
ExitAvida(0);
+
+ return 0;
}
Modified: development/source/targets/unit-tests/main.cc
===================================================================
--- development/source/targets/unit-tests/main.cc 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/targets/unit-tests/main.cc 2007-06-30 18:26:30 UTC (rev 1737)
@@ -41,6 +41,7 @@
public:
cUnitTest() : m_total(0), m_failed(0) { ; }
+ virtual ~cUnitTest();
virtual const char* GetUnitName() = 0;
Deleted: development/source/tools/cConditionVariable.h
===================================================================
--- development/source/tools/cConditionVariable.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/tools/cConditionVariable.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -1,123 +0,0 @@
-/*
- * cConditionVariable.h
- * Avida
- *
- * Created by David on 3/3/07.
- * Copyright 2007 Michigan State University. All rights reserved.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cConditionVariable_h
-#define cConditionVariable_h
-
-#ifndef cMutex_h
-#include "cMutex.h"
-#endif
-#ifndef platform_h
-#include "platform.h"
-#endif
-
-
-#if AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(UNIX)
-
-// Use POSIX Threads
-# include <pthread.h>
-
-class cConditionVariable
-{
-private:
- pthread_cond_t m_cond;
-
- cConditionVariable(const cConditionVariable&); // @not_implemented
- cConditionVariable& operator=(const cConditionVariable&); // @not_implemented
-
-
-public:
- inline cConditionVariable() { pthread_cond_init(&m_cond, NULL); }
- inline ~cConditionVariable() { pthread_cond_destroy(&m_cond); }
-
-#ifdef DEBUG
- void Wait(cMutex& mutex)
- {
- mutex.m_locked = false;
- pthread_cond_wait(&m_cond, &(mutex.m_mutex));
- mutex.m_locked = true;
- }
-#else
- inline void Wait(cMutex& mutex) { pthread_cond_wait(&m_cond, &(mutex.m_mutex)); }
-#endif
-
- inline void Signal() { pthread_cond_signal(&m_cond); }
- inline void Broadcast() { pthread_cond_broadcast(&m_cond); }
-};
-
-#elif AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(WINDOWS)
-
-// Use Windows Threading
-# include <windows.h>
-class cConditionVariable
-{
-private:
- CONDITION_VARIABLE m_cond;
-
- cConditionVariable(const cConditionVariable&); // @not_implemented
- cConditionVariable& operator=(const cConditionVariable&); // @not_implemented
-
-
-public:
- inline cConditionVariable() { InitializeConditionVariable(&m_cond); }
- inline ~cConditionVariable() { ; }
-
-#ifdef DEBUG
- void Wait(cMutex& mutex)
- {
- mutex.m_locked = false;
- SleepConditionVariableCS(&m_cond, &(mutex.m_mutex));
- mutex.m_locked = true;
- }
-#else
- inline void Wait(cMutex& mutex) { SleepConditionVariableCS(&m_cond, &(mutex.m_mutex)); }
-#endif
-
- inline void Signal() { WakeConditionVariable(&m_cond); }
- inline void Broadcast() { WakeAllConditionVariable(&m_cond); }
-};
-
-
-#else
-
-// Disable Threading
-class cConditionVariable
-{
-private:
- cConditionVariable(const cConditionVariable&); // @not_implemented
- cConditionVariable& operator=(const cConditionVariable&); // @not_implemented
-
-public:
- inline cConditionVariable() { ; }
- inline ~cConditionVariable() { ; }
-
- inline void Wait(cMutex& mutex) { ; }
-
- inline void Signal() { ; }
- inline void Broadcast() { ; }
-};
-
-#endif
-
-#endif
Modified: development/source/tools/cFlexVar.h
===================================================================
--- development/source/tools/cFlexVar.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/tools/cFlexVar.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -1,3 +1,26 @@
+/*
+ * cFlexVar.h
+ * Avida
+ *
+ * Copyright 2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
#ifndef cFlexVar_h
#define cFlexVar_h
Deleted: development/source/tools/cMutex.h
===================================================================
--- development/source/tools/cMutex.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/tools/cMutex.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -1,207 +0,0 @@
-/*
- * cMutex.h
- * Avida
- *
- * Created by David on 3/2/07.
- * Copyright 2007 Michigan State University. All rights reserved.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cMutex_h
-#define cMutex_h
-
-#ifndef platform_h
-#include "platform.h"
-#endif
-
-
-#if AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(UNIX)
-
-// Use POSIX Threads
-# include <pthread.h>
-
-#ifdef DEBUG
-# define PTHREAD_MUTEX_CHKRTN(OP) \
- { \
- int ret = OP; \
- ASSERT_MSG(ret == 0, "OP failed"); \
- }
-#else
-# define PTHREAD_MUTEX_CHKRTN(OP) OP
-#endif
-
-class cMutex
-{
- friend class cConditionVariable;
-private:
- pthread_mutex_t m_mutex;
-#ifdef DEBUG
- bool m_locked;
-#endif
-
- cMutex(const cMutex&); // @not_implemented
- cMutex& operator=(const cMutex&); // @not_implemented
-
-
-public:
-#ifdef DEBUG
- cMutex() : m_locked(false) { PTHREAD_MUTEX_CHKRTN(pthread_mutex_init(&m_mutex, NULL)); }
-#else
- inline cMutex() { PTHREAD_MUTEX_CHKRTN(pthread_mutex_init(&m_mutex, NULL)); }
-#endif
-
- inline ~cMutex()
- {
- ASSERT_MSG(!m_locked, "destroying locked mutex");
- PTHREAD_MUTEX_CHKRTN(pthread_mutex_destroy(&m_mutex));
- }
-
-#ifdef DEBUG
- void Lock()
- {
- PTHREAD_MUTEX_CHKRTN(pthread_mutex_lock(&m_mutex));
- m_locked = true;
- }
-#else
- inline void Lock() { PTHREAD_MUTEX_CHKRTN(pthread_mutex_lock(&m_mutex)); }
-#endif
-
-#ifdef DEBUG
- void Unlock()
- {
- ASSERT_MSG(m_locked, "mutex not locked");
- PTHREAD_MUTEX_CHKRTN(pthread_mutex_unlock(&m_mutex));
- m_locked = false;
- }
-#else
- inline void Unlock() { PTHREAD_MUTEX_CHKRTN(pthread_mutex_unlock(&m_mutex)); }
-#endif
-};
-
-#elif AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(WINDOWS)
-
-// Use Windows Threading
-# include <windows.h>
-
-class cMutex
-{
- friend class cConditionVariable;
-private:
- CRITICAL_SECTION m_mutex;
-#ifdef DEBUG
- bool m_locked;
-#endif
-
- cMutex(const cMutex&); // @not_implemented
- cMutex& operator=(const cMutex&); // @not_implemented
-
-
-public:
-#ifdef DEBUG
- cMutex() : m_locked(false) { InitializeCriticalSection(&m_mutex); }
-#else
- inline cMutex() { InitializeCriticalSection(&m_mutex); }
-#endif
-
- inline ~cMutex()
- {
- ASSERT_MSG(!m_locked, "destroying locked mutex");
- DeleteCriticalSection(&m_mutex);
- }
-
-#ifdef DEBUG
- void Lock()
- {
- EnterCriticalSection(&m_mutex);
- m_locked = true;
- }
-#else
- inline void Lock() { EnterCriticalSection(&m_mutex); }
-#endif
-
-#ifdef DEBUG
- void Unlock()
- {
- ASSERT_MSG(m_locked, "mutex not locked");
- LeaveCriticalSection(&m_mutex);
- m_locked = false;
- }
-#else
- inline void Unlock() { LeaveCriticalSection(&m_mutex); }
-#endif
-};
-
-
-#else
-
-// Disable Threading
-class cMutex
-{
-private:
-#ifdef DEBUG
- bool m_locked;
-#endif
-
- cMutex(const cMutex&); // @not_implemented
- cMutex& operator=(const cMutex&); // @not_implemented
-
-
-public:
-#ifdef DEBUG
- cMutex() : m_locked(false) { ; }
-#else
- inline cMutex() { ; }
-#endif
-
- inline ~cMutex() { ASSERT_MSG(!m_locked, "destroying locked mutex"); }
-
-#ifdef DEBUG
- void Lock() { m_locked = true; }
-#else
- inline void Lock() { ; }
-#endif
-
-#ifdef DEBUG
- void Unlock()
- {
- ASSERT_MSG(m_locked, "mutex not locked");
- m_locked = false;
- }
-#else
- inline void Unlock() { ; }
-#endif
-};
-
-#endif
-
-
-class cMutexAutoLock
-{
-private:
- cMutex& m_mutex;
-
- cMutexAutoLock(); // @not_implemented
- cMutexAutoLock(const cMutexAutoLock&); // @not_implemented
- cMutexAutoLock& operator=(const cMutexAutoLock&); // @not_implemented
-
-public:
- inline explicit cMutexAutoLock(cMutex& mutex) : m_mutex(mutex) { m_mutex.Lock(); }
- inline ~cMutexAutoLock() { m_mutex.Unlock(); }
-};
-
-#endif
Deleted: development/source/tools/cRWLock.h
===================================================================
--- development/source/tools/cRWLock.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/tools/cRWLock.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -1,105 +0,0 @@
-/*
- * cRWLock.h
- * Avida
- *
- * Created by David on 3/3/07.
- * Copyright 2007 Michigan State University. All rights reserved.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cRWLock_h
-#define cRWLock_h
-
-#ifndef platform_h
-#include "platform.h"
-#endif
-
-
-#if AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(UNIX)
-
-// Use POSIX Threads
-# include <pthread.h>
-
-class cRWLock
-{
-private:
- pthread_rwlock_t m_rwlock;
-
- cRWLock(const cRWLock&); // @not_implemented
- cRWLock& operator=(const cRWLock&); // @not_implemented
-
-public:
- inline cRWLock() { pthread_rwlock_init(&m_rwlock, NULL); }
- inline ~cRWLock() { pthread_rwlock_destroy(&m_rwlock); }
-
- inline void ReadLock() { pthread_rwlock_rdlock(&m_rwlock); }
- inline void ReadUnlock() { pthread_rwlock_unlock(&m_rwlock); }
-
- inline void WriteLock() { pthread_rwlock_wrlock(&m_rwlock); }
- inline void WriteUnlock() { pthread_rwlock_unlock(&m_rwlock); }
-};
-
-#elif AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(WINDOWS)
-
-// Use Windows Threading
-# include <windows.h>
-
-class cRWLock
-{
-private:
- SRWLOCK m_rwlock;
-
- cRWLock(const cRWLock&); // @not_implemented
- cRWLock& operator=(const cRWLock&); // @not_implemented
-
-public:
- inline cRWLock() { InitializeSRWLock(&m_rwlock); }
- inline ~cRWLock() { ; }
-
- inline void ReadLock() { AcquireSRWLockShared(&m_rwlock); }
- inline void ReadUnlock() { ReleaseSRWLockShared(&m_rwlock); }
-
- inline void WriteLock() { AcquireSRWLockExclusive(&m_rwlock); }
- inline void WriteUnlock() { ReleaseSRWLockExclusive(&m_rwlock); }
-};
-
-
-
-#else
-
-class cRWLock
-{
-private:
- cRWLock(const cRWLock&); // @not_implemented
- cRWLock& operator=(const cRWLock&); // @not_implemented
-
-public:
- inline cRWLock() { ; }
- inline ~cRWLock() { ; }
-
- inline void ReadLock() { ; }
- inline void ReadUnlock() { ; }
-
- inline void WriteLock() { ; }
- inline void WriteUnlock() { ; }
-};
-
-
-#endif
-
-#endif
Modified: development/source/tools/cRandom.cc
===================================================================
--- development/source/tools/cRandom.cc 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/tools/cRandom.cc 2007-06-30 18:26:30 UTC (rev 1737)
@@ -57,7 +57,7 @@
if (in_seed <= 0) {
int seed_time = (int) time(NULL);
-#ifdef MSVC_COMPILER
+#if AVIDA_PLATFORM(WINDOWS)
int seed_pid = (int) _getpid();
#else
int seed_pid = (int) getpid();
Deleted: development/source/tools/cThread.cc
===================================================================
--- development/source/tools/cThread.cc 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/tools/cThread.cc 2007-06-30 18:26:30 UTC (rev 1737)
@@ -1,124 +0,0 @@
-/*
- * cThread.cc
- * Avida
- *
- * Created by David on 2/18/06.
- * Copyright 1999-2007 Michigan State University. All rights reserved.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "cThread.h"
-
-#if AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(UNIX)
-
-cThread::~cThread() { if (m_running) pthread_detach(m_thread); }
-
-bool cThread::Start()
-{
- m_mutex.Lock();
- if (!m_running) {
- m_running = true;
- m_mutex.Unlock();
-
- // Create thread, mark as running when successful
- int rval = pthread_create(&m_thread, NULL, &cThread::EntryPoint, this);
- if (rval) m_running = false;
- } else {
- m_mutex.Unlock();
- }
-
- return m_running;
-}
-
-void cThread::Stop()
-{
- if (m_running) {
- // Close and clean up thread, set running to false
- pthread_cancel(m_thread);
- pthread_join(m_thread, NULL);
- m_running = false;
- }
-}
-
-void cThread::Join()
-{
- if (m_running) {
- pthread_join(m_thread, NULL);
- m_running = false;
- }
-}
-
-void* cThread::EntryPoint(void* arg)
-{
- // Common entry point to start cThread objects
- // Calls Run method of appropriate subclass to do the actual work
- cThread* thread = static_cast<cThread*>(arg);
- thread->Run();
-
- pthread_exit(NULL);
- return NULL;
-}
-
-
-#elif AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(WINDOWS)
-
-cThread::~cThread() { if (m_thread) CloseHandle(m_thread); }
-
-bool cThread::Start()
-{
- cMutexAutoLock lock(m_mutex);
-
- if (m_thread == 0) {
- unsigned long tid = 0;
- m_thread = (HANDLE)_beginthreadex(0, 0, &cThread::EntryPoint, this, 0, &tid);
-
- if (m_thread) return true;
- return false;
- }
-
- return true;
-}
-
-void cThread::Stop()
-{
- if (m_thread) {
- if (CloseHandle(m_thread) == TRUE) {
- m_thread = 0;
- }
- }
-
-}
-
-void cThread::Join()
-{
- if (m_thread) WaitForSingleObject(m_thread, INFINITE);
-}
-
-unsigned int __stdcall cThread::EntryPoint(void* arg)
-{
- // Common entry point to start cThread objects
- // Calls Run method of appropriate subclass to do the actual work
- cThread* thread = static_cast<cThread*>(arg);
- thread->Run();
-
- _endthreadex(0);
- return 0;
-}
-
-
-#endif
Deleted: development/source/tools/cThread.h
===================================================================
--- development/source/tools/cThread.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/tools/cThread.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -1,112 +0,0 @@
-/*
- * cThread.h
- * Avida
- *
- * Created by David on 2/18/06.
- * Copyright 2006-2007 Michigan State University. All rights reserved.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cThread_h
-#define cThread_h
-
-#ifndef cMutex_h
-#include "cMutex.h"
-#endif
-
-
-#if AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(UNIX)
-
-// Use POSIX Threads
-#include <pthread.h>
-
-class cThread
-{
-protected:
- pthread_t m_thread;
- cMutex m_mutex;
- bool m_running;
-
- void Stop();
-
- virtual void Run() = 0;
-
- static void* EntryPoint(void* arg);
-
- cThread(const cThread&); // @not_implemented
- cThread& operator=(const cThread&); // @not_implemented
-
-public:
- cThread() : m_running(false) { ; }
- virtual ~cThread();
-
- bool Start();
- void Join();
-};
-
-#elif AVIDA_PLATFORM(THREADS) && AVIDA_PLATFORM(WINDOWS)
-
-// Use Windows Threading
-#include <windows.h>
-
-class cThread
-{
-protected:
- HANDLE m_thread;
- cMutex m_mutex;
-
- void Stop();
-
- virtual void Run() = 0;
-
- static unsigned int __stdcall EntryPoint(void* arg);
-
- cThread(const cThread&); // @not_implemented
- cThread& operator=(const cThread&); // @not_implemented
-
-public:
- cThread() : m_thread(0) { ; }
- virtual ~cThread();
-
- bool Start();
- void Join();
-};
-
-#else
-
-// Disable Threading
-class cThread
-{
-protected:
- virtual void Run() = 0;
-
- cThread(const cThread&); // @not_implemented
- cThread& operator=(const cThread&); // @not_implemented
-
-public:
- inline cThread() { ; }
- virtual ~cThread() { ; }
-
- inline bool Start() { Run(); return true; }
- inline void Join() { ; }
-};
-
-#endif
-
-
-#endif
Deleted: development/source/tools/platform.h
===================================================================
--- development/source/tools/platform.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/tools/platform.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -1,61 +0,0 @@
-/*
- * platform.h
- * Avida
- *
- * Created by David on 3/2/07.
- * Copyright 2007 Michigan State University. All rights reserved.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef platform_h
-#define platform_h
-
-// spaces between defined's parentheses and contained value are required by Visual Studio's preprocessor
-#define AVIDA_PLATFORM(PROP) (defined( AVIDA_PLATFORM_ ## PROP ) && AVIDA_PLATFORM_##PROP)
-
-#if defined(WIN32) || defined(_WIN32)
-# define AVIDA_PLATFORM_WINDOWS 1
-# ifdef ENABLE_THREADS
-# define AVIDA_PLATFORM_THREADS 1
-# else
-# define AVIDA_PLATFORM_THREADS 0
-# endif
- // Disable warning C4355: 'this' : used in base member initializer list
-# pragma warning( disable : 4355 )
-#endif
-
-#if defined(__APPLE__) || defined(unix) || defined(__unix) || defined(__unix__) || defined (__NetBSD__) || defined(_AIX)
-# define AVIDA_PLATFORM_UNIX 1
-# define AVIDA_PLATFORM_THREADS 1
-#endif
-
-
-#ifdef DEBUG
-# include <cstdlib>
-# include <iostream>
-# define ASSERT_MSG(VALUE, MSG) if (!(VALUE)) { std::cerr << "Error: " << MSG << std::endl; abort(); }
-#else
-# define ASSERT_MSG(VALUE, MSG)
-#endif
-
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#endif
Modified: development/source/tools/tList.h
===================================================================
--- development/source/tools/tList.h 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/source/tools/tList.h 2007-06-30 18:26:30 UTC (rev 1737)
@@ -32,11 +32,6 @@
# endif
#endif
-#ifndef platform_h
-#include "platform.h"
-#endif
-
-
#ifndef NULL
#define NULL 0
#endif
@@ -50,13 +45,9 @@
tListNode<T> * next;
tListNode<T> * prev;
-// @DMB - Visual Studio doesn't like usage of 'this' in initializers
-// and throws a lot of useless warnings.
-#if AVIDA_PLATFORM(WINDOWS)
+ // @DMB - Visual Studio doesn't like usage of 'this' in initializers
+ // and throws a lot of useless warnings.
tListNode() : data(NULL) { next = this; prev = this; }
-#else
- tListNode() : data(NULL), next(this), prev(this) { ; }
-#endif
template<class Archive>
void serialize(Archive & a, const unsigned int version){
Modified: development/support/config/avida.cfg
===================================================================
--- development/support/config/avida.cfg 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/support/config/avida.cfg 2007-06-30 18:26:30 UTC (rev 1737)
@@ -258,7 +258,7 @@
### ANALYZE_GROUP ###
# Analysis Settings
-MT_CONCURRENCY 1 # Number of concurrent analyze threads
+MAX_CONCURRENCY -1 # Number of concurrent analyze threads
ANALYZE_OPTION_1 # String variable accessible from analysis scripts
ANALYZE_OPTION_2 # String variable accessible from analysis scripts
Modified: development/tests/analyze_truncate_lineage_fulllandscape/config/avida.cfg
===================================================================
--- development/tests/analyze_truncate_lineage_fulllandscape/config/avida.cfg 2007-06-30 12:55:57 UTC (rev 1736)
+++ development/tests/analyze_truncate_lineage_fulllandscape/config/avida.cfg 2007-06-30 18:26:30 UTC (rev 1737)
@@ -229,6 +229,6 @@
### ANALYZE_GROUP ###
# Analysis Settings
-MT_CONCURRENCY 2 # Number of concurrent analyze threads
+MAX_CONCURRENCY 4 # Number of concurrent analyze threads
ANALYZE_OPTION_1 # String variable accessible from analysis scripts
ANALYZE_OPTION_2 # String variable accessible from analysis scripts
More information about the Avida-cvs
mailing list