[med-svn] [SCM] aghermann branch, master, updated. 99b1d5a023eee9df74b0e0d6f894516fc79435ad

Andrei Zavada johnhommer at gmail.com
Sun Jul 7 23:03:48 UTC 2013


The following commit has been merged in the master branch:
commit b99d348880bfff3b6a1d9f8aa88cfdb1d824f850
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Sun Jun 9 01:16:10 2013 +0300

    move aghermann globals from common/ into aghermann/
    
    those are gsl_rng *rng; and int num_procs;

diff --git a/src/aghermann/Makefile.am b/src/aghermann/Makefile.am
index bc4529f..cb7dcca 100644
--- a/src/aghermann/Makefile.am
+++ b/src/aghermann/Makefile.am
@@ -18,6 +18,8 @@ bin_PROGRAMS := aghermann
 aghermann_SOURCES := \
 	print_version.cc \
 	main.cc \
+	globals.cc \
+	globals.hh \
 	ui/sm/sm.hh
 
 print_version.o: FORCE
diff --git a/src/aghermann/expdesign/primaries.cc b/src/aghermann/expdesign/primaries.cc
index c966908..20ae3b2 100644
--- a/src/aghermann/expdesign/primaries.cc
+++ b/src/aghermann/expdesign/primaries.cc
@@ -20,7 +20,7 @@
 #include <omp.h>
 #endif
 
-#include "common/globals.hh"
+#include "aghermann/globals.hh"
 #include "common/config-validate.hh"
 #include "primaries.hh"
 
diff --git a/src/aghermann/globals.cc b/src/aghermann/globals.cc
new file mode 100644
index 0000000..0fec459
--- /dev/null
+++ b/src/aghermann/globals.cc
@@ -0,0 +1,70 @@
+/*
+ *       File name:  aghermann/globals.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2013-06-09
+ *
+ *         Purpose:  global variables, all two of them
+ *
+ *         License:  GPL
+ */
+
+
+#include <sys/time.h>
+#include <gsl/gsl_rng.h>
+
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
+#include "globals.hh"
+
+
+#if HAVE_CONFIG_H && !defined(VERSION)
+#  include "config.h"
+#endif
+
+using namespace std;
+
+
+gsl_rng *agh::global::rng = nullptr;
+
+void
+agh::global::
+init()
+{
+      // 1. init rng
+	{
+		const gsl_rng_type *T;
+		gsl_rng_env_setup();
+		T = gsl_rng_default;
+		if ( gsl_rng_default_seed == 0 ) {
+			struct timeval tp = { 0L, 0L };
+			gettimeofday( &tp, NULL);
+			gsl_rng_default_seed = tp.tv_usec;
+		}
+		rng = gsl_rng_alloc( T);
+	}
+
+      // 2. omp
+	{
+#ifdef _OPENMP
+		agh::global::num_procs = omp_get_max_threads();
+		// if ( agh::global::num_procs > 1 )
+		// 	printf( "This host is SMP-capable (omp_get_max_threads() returns %d)\n", agh::global::num_procs);
+		// else
+		// 	printf( "This host is not SMP-capable\n");
+#endif
+
+	}
+}
+
+
+
+
+int agh::global::num_procs = 1;
+
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/aghermann/globals.hh b/src/aghermann/globals.hh
new file mode 100644
index 0000000..866f1b1
--- /dev/null
+++ b/src/aghermann/globals.hh
@@ -0,0 +1,40 @@
+/*
+ *       File name:  aghermann/globals.hh
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2010-04-28
+ *
+ *         Purpose:  global (gasp!) variable definitions
+ *
+ *         License:  GPL
+ */
+
+#ifndef _AGH_GLOBALS_H
+#define _AGH_GLOBALS_H
+
+#include <gsl/gsl_rng.h>
+
+#if HAVE_CONFIG_H && !defined(VERSION)
+#  include "config.h"
+#endif
+
+using namespace std;
+
+namespace agh {
+namespace global {
+
+extern gsl_rng *rng;
+
+extern int num_procs;
+
+void init();
+
+} // namespace global
+} // namespace agh
+
+#endif
+
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: 8
+// End:
diff --git a/src/aghermann/main.cc b/src/aghermann/main.cc
index a687b49..608f9ea 100644
--- a/src/aghermann/main.cc
+++ b/src/aghermann/main.cc
@@ -18,10 +18,10 @@
 #include <gtk/gtk.h>
 #include <unique/unique.h>
 
-#include "common/globals.hh"
-#include "aghermann/ui/globals.hh"
-#include "aghermann/ui/ui.hh"
-#include "aghermann/ui/sm/sm.hh"
+#include "globals.hh"
+#include "ui/globals.hh"
+#include "ui/ui.hh"
+#include "ui/sm/sm.hh"
 
 
 
@@ -39,7 +39,7 @@ message_received_cb( UniqueApp         *,
 
 	switch ( command ) {
 	case UNIQUE_ACTIVATE:
-		/* move the main window to the screen that sent us the command */
+		// move the main window to the screen that sent us the command
 		gtk_window_set_screen( aghui::__main_window__, unique_message_data_get_screen( message));
 		gtk_window_present_with_time( aghui::__main_window__, time_);
 		res = UNIQUE_RESPONSE_OK;
@@ -84,14 +84,8 @@ main( int argc, char **argv)
 				  (GCallback)message_received_cb,
 				  NULL);
 
-		agh::global::init_rng();
-#ifdef _OPENMP
-		agh::global::num_procs = omp_get_max_threads();
-		if ( agh::global::num_procs > 1 )
-			printf( "This host is SMP-capable (omp_get_max_threads() returns %d)\n", agh::global::num_procs);
-		else
-			printf( "This host is not SMP-capable\n");
-#endif
+		agh::global::init();
+
 		if ( aghui::prepare_for_expdesign() ) {
 			aghui::pop_ok_message( NULL, "UI failed to initialize", "Your install is broken.");
 			return 2;
diff --git a/src/aghermann/model/achermann-siman.cc b/src/aghermann/model/achermann-siman.cc
index aab096a..097dcd3 100644
--- a/src/aghermann/model/achermann-siman.cc
+++ b/src/aghermann/model/achermann-siman.cc
@@ -14,7 +14,7 @@
 #include <gsl/gsl_math.h>
 #include <gsl/gsl_siman.h>
 
-#include "common/globals.hh"
+#include "aghermann/globals.hh"
 #include "aghermann/expdesign/recording.hh"
 #include "achermann.hh"
 
diff --git a/src/aghermann/model/achermann-tunable.cc b/src/aghermann/model/achermann-tunable.cc
index ba4f6b0..8ea71fc 100644
--- a/src/aghermann/model/achermann-tunable.cc
+++ b/src/aghermann/model/achermann-tunable.cc
@@ -13,7 +13,7 @@
 
 #include <cassert>
 #include <gsl/gsl_rng.h>
-#include "common/globals.hh"
+#include "aghermann/globals.hh"
 #include "achermann-tunable.hh"
 
 
diff --git a/src/aghermann/model/ultradian-cycle.cc b/src/aghermann/model/ultradian-cycle.cc
index 243b32b..9a776d9 100644
--- a/src/aghermann/model/ultradian-cycle.cc
+++ b/src/aghermann/model/ultradian-cycle.cc
@@ -13,7 +13,7 @@
 #include <gsl/gsl_siman.h>
 #include <gsl/gsl_blas.h>
 
-#include "common/globals.hh"
+#include "aghermann/globals.hh"
 #include "aghermann/expdesign/recording.hh"
 #include "beersma.hh"
 
diff --git a/src/aghermann/ui/globals.hh b/src/aghermann/ui/globals.hh
index 3c36c9d..d031345 100644
--- a/src/aghermann/ui/globals.hh
+++ b/src/aghermann/ui/globals.hh
@@ -4,7 +4,7 @@
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2012-09-22
  *
- *         Purpose:  general init and global decls
+ *         Purpose:  ui globals
  *
  *         License:  GPL
  */
diff --git a/src/aghermann/ui/mw/settings_cb.cc b/src/aghermann/ui/mw/settings_cb.cc
index a4e6249..244b048 100644
--- a/src/aghermann/ui/mw/settings_cb.cc
+++ b/src/aghermann/ui/mw/settings_cb.cc
@@ -13,7 +13,7 @@
 #include <omp.h>
 #endif
 
-#include "common/globals.hh"
+#include "aghermann/globals.hh"
 #include "common/string.hh"
 #include "aghermann/ui/misc.hh"
 #include "aghermann/ui/sf/sf.hh"
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 85e3099..fd78959 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -10,7 +10,6 @@ liba_a_SOURCES := \
 	subject_id.cc \
 	config-validate.hh \
 	string.hh \
-	globals.hh \
 	alg.hh \
 	fs.hh \
 	lang.hh \
@@ -20,7 +19,6 @@ if DO_PCH
 BUILT_SOURCES := \
 	config-validate.hh.gch \
 	string.hh.gch \
-	globals.hh.gch \
 	alg.hh.gch \
 	containers.hh.gch \
 	fs.hh.gch \
diff --git a/src/common/globals.hh b/src/common/globals.hh
deleted file mode 100644
index a820fe1..0000000
--- a/src/common/globals.hh
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *       File name:  common/globals.hh
- *         Project:  Aghermann
- *          Author:  Andrei Zavada <johnhommer at gmail.com>
- * Initial version:  2010-04-28
- *
- *         Purpose:  global (gasp!) variable definitions
- *
- *         License:  GPL
- */
-
-#ifndef _AGH_COMMON_GLOBALS_H
-#define _AGH_COMMON_GLOBALS_H
-
-#include <gsl/gsl_rng.h>
-
-#if HAVE_CONFIG_H && !defined(VERSION)
-#  include "config.h"
-#endif
-
-using namespace std;
-
-namespace agh {
-namespace global {
-
-extern gsl_rng *rng;
-void init_rng();
-
-extern int num_procs;
-
-// typedef std::valarray<TFloat> VAF;
-
-// // debugging aids
-// template <typename T> void
-// vaf_dump( const valarray<T>& v, const string& fname, size_t size = -1)
-// {
-// 	if ( size == (size_t)-1 )
-// 		size = v.size();
-// 	int fd;
-// 	if ( (fd = open( fname.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1 ||
-// 	     write( fd, &v[0], size * sizeof(T)) == -1 )
-// 		printf( "so broken even vaf_dump failed\n");
-// 	close( fd);
-// }
-
-} // namespace global
-} // namespace agh
-
-#endif
-
-// Local Variables:
-// Mode: c++
-// indent-tabs-mode: 8
-// End:
diff --git a/src/common/libcommon.cc b/src/common/libcommon.cc
index b3ce11e..5800f97 100644
--- a/src/common/libcommon.cc
+++ b/src/common/libcommon.cc
@@ -1,4 +1,3 @@
-// ;-*-C++-*-
 /*
  *       File name:  common/libcommon.cc
  *         Project:  Aghermann
@@ -17,12 +16,10 @@
 #include <list>
 
 #include <unistd.h>
-#include <sys/time.h>
 #include <errno.h>
 #include <wchar.h>
 #include <iconv.h>
 
-#include "globals.hh"
 #include "string.hh"
 #include "alg.hh"
 #include "fs.hh"
@@ -339,34 +336,6 @@ sensible_scale_reduction_factor( double display_scale,
 }
 
 
-
-
-
-
-
-
-gsl_rng *agh::global::rng = nullptr;
-
-void
-agh::global::
-init_rng()
-{
-	const gsl_rng_type *T;
-	gsl_rng_env_setup();
-	T = gsl_rng_default;
-	if ( gsl_rng_default_seed == 0 ) {
-		struct timeval tp = { 0L, 0L };
-		gettimeofday( &tp, NULL);
-		gsl_rng_default_seed = tp.tv_usec;
-	}
-	rng = gsl_rng_alloc( T);
-}
-
-
-
-
-int agh::global::num_procs = 1;
-
 // Local Variables:
 // Mode: c++
 // indent-tabs-mode: 8

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list