Skip to content

Instantly share code, notes, and snippets.

@ludwigschwardt
Last active December 11, 2015 07:48
Show Gist options
  • Save ludwigschwardt/4568292 to your computer and use it in GitHub Desktop.
Save ludwigschwardt/4568292 to your computer and use it in GitHub Desktop.
Patches for meqtrees Homebrew formula
diff --git a/DMI/src/DMI.h b/DMI/src/DMI.h
index 49e2e9b..8917bcf 100644
--- a/DMI/src/DMI.h
+++ b/DMI/src/DMI.h
@@ -110,6 +110,7 @@ namespace DMI
// compile-time error reporting. This is borrowed from Alexandrescu
template<int> struct CompileTimeError;
template<> struct CompileTimeError<true> {};
+ template<> struct CompileTimeError<false> {};
};
diff --git a/DMI/src/Packer.h b/DMI/src/Packer.h
index 2ef85ae..52372d5 100644
--- a/DMI/src/Packer.h
+++ b/DMI/src/Packer.h
@@ -525,8 +525,8 @@ template <class Map, class KeyPacker, class ValuePacker>
void MapPacker<Map,KeyPacker,ValuePacker>::unpack (Map &mp, const void *block, size_t sz)
{
FailWhen(sz<sizeof(size_t),"corrupt block");
- const size_t
- *hdr = static_cast<size_t*>(block),
+ size_t
+ *hdr = const_cast<size_t*>(static_cast<const size_t*>(block)),
n = *(hdr++),
sz0 = (1+ (KeyPacker::binary()?0:n) + (ValuePacker::binary()?0:n))*sizeof(size_t);
FailWhen(sz<sz0,"corrupt block");
diff --git a/MEQ/src/FastParmTable.cc b/MEQ/src/FastParmTable.cc
index c0e53fc..7034607 100644
--- a/MEQ/src/FastParmTable.cc
+++ b/MEQ/src/FastParmTable.cc
@@ -164,7 +164,15 @@ void FastParmTable::throwErrno (const string &message)
{
int errno0 = errno;
char errbuf[256];
+// This test was taken from Chromium's safe_strerror_posix.cc
+#if (defined(__GLIBC__) || defined(OS_NACL))
+ // Use the historical GNU-specific version of strerror_r found on e.g. Linux
char *err = strerror_r(errno0,errbuf,sizeof(errbuf));
+#else
+ // Use the POSIX-compliant (XSI-compliant) version of strerror_r found on e.g. Darwin
+ int errno1 = strerror_r(errno0,errbuf,sizeof(errbuf));
+ char *err = errbuf;
+#endif
Throw(Debug::ssprintf("%s: %s (errno=%d)",
Debug::ssprintf(message.c_str(),table_name_.c_str()).c_str(),err,errno0));
}
diff --git a/TimBase/src/Thread/Thread.cc b/TimBase/src/Thread/Thread.cc
index c90c7af..b673098 100644
--- a/TimBase/src/Thread/Thread.cc
+++ b/TimBase/src/Thread/Thread.cc
@@ -74,7 +74,7 @@ namespace LOFAR
pthread_t id = 0;
pthread_create(&id,attr,start,arg);
// add to map
- thread_map_[thread_list_.size()] = id;
+ thread_map_[id] = thread_list_.size();
thread_list_.push_back(id);
return id;
}
diff --git a/MEQ/src/ComposedPolc.cc b/MEQ/src/ComposedPolc.cc
index 510b158..e895ef6 100644
--- a/MEQ/src/ComposedPolc.cc
+++ b/MEQ/src/ComposedPolc.cc
@@ -266,13 +266,13 @@ void ComposedPolc::validateContent (bool recursive)
starti[axisi]=0;endi[axisi]=0;continue;
}
if (!polcdom.isDefined(axisi)){
- starti[axisi]=0;endi[axisi]=std::min(res_shape[axisi]-1,startgrid[axisi].size()-1);continue;
+ starti[axisi]=0;endi[axisi]=std::min(res_shape[axisi]-1,static_cast<int>(startgrid[axisi].size())-1);continue;
}
- int maxk=std::min(res_shape[axisi],startgrid[axisi].size());
+ int maxk=std::min(res_shape[axisi],static_cast<int>(startgrid[axisi].size()));
int k=0;
while(k<maxk && centergrid[axisi](k)<polcdom.start(axisi)) k++;
starti[axisi] = k;
- k=std::min(res_shape[axisi]-1,startgrid[axisi].size()-1);
+ k=std::min(res_shape[axisi]-1,static_cast<int>(startgrid[axisi].size())-1);
while(k>0 && (centergrid[axisi](k)>polcdom.end(axisi))) k--;
endi[axisi] = k;
cdebug(3)<<"axis : "<<axisi<<" begin : "<<starti[axisi]<<" end : "<<endi[axisi]<<endl;
diff --git a/MEQ/src/Polc.cc b/MEQ/src/Polc.cc
index 130f0e0..da0b1f8 100644
--- a/MEQ/src/Polc.cc
+++ b/MEQ/src/Polc.cc
@@ -224,7 +224,7 @@ void Polc::do_evaluate (VellSet &vs,const Cells &cells,
grid[i] = ( grid[i] - getOffset(i) )*one_over_scale;
cdebug(4)<<"calculating polc on grid "<<i<<" : "<<grid[i]<<endl;
- res_shape[iaxis] = std::max(grid[i].size(),1);
+ res_shape[iaxis] = std::max(static_cast<int>(grid[i].size()),1);
}
}
// now evaluate
diff --git a/MEQ/src/Spline.cc b/MEQ/src/Spline.cc
index beaccaa..ae001fc 100644
--- a/MEQ/src/Spline.cc
+++ b/MEQ/src/Spline.cc
@@ -195,7 +195,7 @@ void Spline::do_evaluate (VellSet &vs,const Cells &cells,
" is not defined in Cells");
grid[i].resize(cells.ncells(iaxis));
grid[i] = cells.center(iaxis);
- res_shape[iaxis] = std::max(grid[i].size(),1);
+ res_shape[iaxis] = std::max(static_cast<int>(grid[i].size()),1);
total*=res_shape[iaxis];
}
}
diff --git a/TimBase/src/Lorrays-Blitz.h b/TimBase/src/Lorrays-Blitz.h
index d31b03d..11ca33f 100644
--- a/TimBase/src/Lorrays-Blitz.h
+++ b/TimBase/src/Lorrays-Blitz.h
@@ -258,16 +258,29 @@ class VariVector : public std::vector<int>
VariVector (int n1,int n2,int n3,int n4,int n5) : std::vector<int>(5)
{ iterator iter = begin(); *iter++=n1; *iter++=n2; *iter++=n3; *iter++=n4; *iter++=n5; }
- // construct from TinyVector
+ // construct from TinyVector<int,N>
// (this assumes contiguity in TinyVector, which is probably pretty safe to assume)
template<int N>
VariVector( const blitz::TinyVector<int,N> &tvec )
: std::vector<int>(tvec.data(),tvec.data() + N) {};
- // convert to TinyVector
+ // convert to TinyVector<int,N>
template<int N>
operator blitz::TinyVector<int,N> () const
{
- blitz::TinyVector<int,N> tvec(0);
+ int initial_value = 0;
+ blitz::TinyVector<int,N> tvec(initial_value);
+ for( int i = 0; i < std::min(N,(int)size()); i++ )
+ tvec[i] = (*this)[i];
+ return tvec;
+ }
+ // convert to TinyVector<long int,N>
+ // Since Blitz++ 0.10 the Blitz::Array stride has a different type (diffType) to the shape (int)
+ // and on at least some platforms diffType is long int
+ template<int N>
+ operator blitz::TinyVector<long int,N> () const
+ {
+ long int initial_value = 0;
+ blitz::TinyVector<long int,N> tvec(initial_value);
for( int i = 0; i < std::min(N,(int)size()); i++ )
tvec[i] = (*this)[i];
return tvec;
diff --git a/MeqNodes/src/TFSmearFactorApprox.cc b/MeqNodes/src/TFSmearFactorApprox.cc
index fb25bdf..4d10f54 100644
--- a/MeqNodes/src/TFSmearFactorApprox.cc
+++ b/MeqNodes/src/TFSmearFactorApprox.cc
@@ -54,22 +54,22 @@ using namespace VellsMath;
// for teh normal stencils: used to have
// A = .5*central12(B,blitz::firstDim);
BZ_DECLARE_STENCIL2(TimeDiff, A,B)
- A = forward11(B,blitz::firstDim);
+ A = forward11_stencilop(B,blitz::firstDim);
BZ_END_STENCIL
BZ_DECLARE_STENCIL2(TimeDiff1,A,B)
- A = forward11(B,blitz::firstDim);
+ A = forward11_stencilop(B,blitz::firstDim);
BZ_END_STENCIL
BZ_DECLARE_STENCIL2(TimeDiff2,A,B)
- A = backward11(B,blitz::firstDim);
+ A = backward11_stencilop(B,blitz::firstDim);
BZ_END_STENCIL
BZ_DECLARE_STENCIL2(FreqDiff, A,B)
- A = forward11(B,blitz::secondDim);
+ A = forward11_stencilop(B,blitz::secondDim);
BZ_END_STENCIL
BZ_DECLARE_STENCIL2(FreqDiff1,A,B)
- A = forward11(B,blitz::secondDim);
+ A = forward11_stencilop(B,blitz::secondDim);
BZ_END_STENCIL
BZ_DECLARE_STENCIL2(FreqDiff2,A,B)
- A = backward11(B,blitz::secondDim);
+ A = backward11_stencilop(B,blitz::secondDim);
BZ_END_STENCIL
diff --git a/AppAgent/AppUtils/src/MSInputChannel.cc b/AppAgent/AppUtils/src/MSInputChannel.cc
index 5aeca2d..32dfee9 100644
--- a/AppAgent/AppUtils/src/MSInputChannel.cc
+++ b/AppAgent/AppUtils/src/MSInputChannel.cc
@@ -191,7 +191,7 @@ void MSInputChannel::fillHeader (DMI::Record &hdr,const DMI::Record &select)
//##ModelId=3DF9FECD025E
void MSInputChannel::openMS (DMI::Record &header,const DMI::Record &select)
{
- Mutex::Lock lock(aipspp_mutex);
+ LOFAR::Thread::Mutex::Lock lock(aipspp_mutex);
// open MS
ms_ = MeasurementSet(msname_,TableLock(TableLock::AutoNoReadLocking),Table::Old);
dprintf(1)("opened MS %s, %d rows\n",msname_.c_str(),ms_.nrow());
@@ -456,7 +456,7 @@ void MSInputChannel::close (const string &str)
{
FileChannel::close(str);
// close & detach from everything
- Mutex::Lock lock(aipspp_mutex);
+ LOFAR::Thread::Mutex::Lock lock(aipspp_mutex);
selms_ = MeasurementSet();
ms_ = MeasurementSet();
tileformat_.detach();
@@ -475,7 +475,7 @@ BZ_END_STENCIL_WITH_SHAPE(blitz::shape(0,-1,0),blitz::shape(0,1,0))
//##ModelId=3DF9FECD021B
int MSInputChannel::refillStream ()
{
- Mutex::Lock lock(aipspp_mutex);
+ LOFAR::Thread::Mutex::Lock lock(aipspp_mutex);
try
{
if( state() == HEADER )
diff --git a/AppAgent/AppUtils/src/MSOutputChannel.cc b/AppAgent/AppUtils/src/MSOutputChannel.cc
index 5e759c5..0540163 100644
--- a/AppAgent/AppUtils/src/MSOutputChannel.cc
+++ b/AppAgent/AppUtils/src/MSOutputChannel.cc
@@ -64,7 +64,7 @@ int MSOutputChannel::init (const DMI::Record &params)
if( FileChannel::init(params) < 0 )
return state();
- Mutex::Lock lock(aipspp_mutex);
+ LOFAR::Thread::Mutex::Lock lock(aipspp_mutex);
params_ = params;
ms_ = MeasurementSet();
msname_ = "(none)";
@@ -83,7 +83,7 @@ void MSOutputChannel::close (const string &msg)
void MSOutputChannel::close_ms ()
{
- Mutex::Lock lock(aipspp_mutex);
+ LOFAR::Thread::Mutex::Lock lock(aipspp_mutex);
rowFlagCol_.reference(casa::ScalarColumn<casa::Bool>());
flagCol_.reference(casa::ArrayColumn<casa::Bool>());
datacol_.col.reference(casa::ArrayColumn<casa::Complex>());
@@ -97,7 +97,7 @@ void MSOutputChannel::close_ms ()
void MSOutputChannel::postEvent (const HIID &id, const ObjRef &data,AtomicID cat,const HIID &src)
{
recordOutputEvent(id,data,cat,src);
- Mutex::Lock lock(aipspp_mutex);
+ LOFAR::Thread::Mutex::Lock lock(aipspp_mutex);
try
{
int code = VisEventType(id);
diff --git a/MeqNodes/src/CUDAPointSourceVisibility.cc b/MeqNodes/src/CUDAPointSourceVisibility.cc
index 3dec9d0..fe8a4f5 100644
--- a/MeqNodes/src/CUDAPointSourceVisibility.cc
+++ b/MeqNodes/src/CUDAPointSourceVisibility.cc
@@ -151,7 +151,7 @@ void CUDAPointSourceVisibility::checkTensorDims (int ichild,const LoShape &shape
else
{
n = shape[0];
- printf("child %i is dim %i\n", ichild, shape.size());
+ printf("child %i is dim %zu\n", ichild, shape.size());
if( shape.size() == 2 )
{
printf(" %i x %i\n", shape[0], shape[1]);
diff --git a/PyApps/src/meqbrowser.py b/PyApps/src/meqbrowser.py
index 390ca8b..3248183 100755
--- a/PyApps/src/meqbrowser.py
+++ b/PyApps/src/meqbrowser.py
@@ -95,6 +95,10 @@ if __name__ == "__main__":
print "Welcome to the MeqTrees Browser!";
print "Please wait a second while the GUI starts up.";
+ if not sys.platform.startswith('linux'):
+ print "Removing left-over Unix socket files associated with MeqTrees"
+ os.system('rm -f /tmp/\=meqbrowser-%d:*' % (os.getuid(),))
+ os.system('rm -f /tmp/\=meqserver-%d:*' % (os.getuid(),))
# first things first: setup app defaults from here and from
# command line (this has to go first, as other modules being imported
@@ -182,18 +186,23 @@ def meqbrowse (debug={},**kwargs):
sock = "";
print "Not binding to a local socket.";
else:
+ # Use abstract socket on Linux and corresponding file-based socket elsewhere
sock = "="+sock;
+ if not sys.platform.startswith('linux'):
+ sock = "/tmp/"+sock;
print "Binding to local socket %s"%sock;
# check local socket
sk = socket.socket(socket.AF_UNIX);
try:
- sk.bind("\0"+sock[1:]);
+ sk.bind( ("\0"+sock[1:]) if sock[0] == '=' else sock);
except:
print "Error binding to local socket %s"%sock;
print "This probably means that another meqbrowser is already running."
print "For advanced use, see the -s option (use -h to get help).";
sys.exit(1);
sk.close();
+ if sock[0] != '=' and os.path.exists(sock):
+ os.remove(sock)
print "Binding to TCP port %d, remote meqservers may connect with gwpeer=<host>:%d"%(port,port);
if not octopussy.is_initialized():
octopussy.init(gwclient=False,gwtcp=port,gwlocal=sock);
diff --git a/OCTOPython/src/__init__.py b/OCTOPython/src/__init__.py
index 2746e95..d0f7976 100644
--- a/OCTOPython/src/__init__.py
+++ b/OCTOPython/src/__init__.py
@@ -44,7 +44,7 @@ __all__ = [ "dmi","utils","octopussy","octopython","dmi_repr" ];
# list of optional packages which will be added to the include path
-_Packages = [ "Cattery" ];
+_Packages = [ "Siamese", "Calico" ];
# list of locations where packages will be searched for
_PackageLocations = [ "~","~/Frameworks/",
@@ -68,7 +68,8 @@ def _tryPackageDir (path,package):
"""Tests if path refers to a valid directory, adds it to system include path if so.
Marks package as having this path.""";
if os.path.isdir(path):
- sys.path.insert(0,path);
+ if path not in sys.path:
+ sys.path.insert(0,path);
# check for version info
try:
version = ' '.join(file(os.path.join(path,'version_info')));
@@ -82,7 +83,7 @@ def _tryPackageDir (path,package):
def _setPackagePath (package):
"""Finds the given package, by first looking in $MEQTREES_PACKAGE_PATH, then checking for
- subdirectories of the standard _PackageLocations list.""";
+ subdirectories of the standard _PackageLocations list and finally importing it.""";
# check for explicit MEQTREES_PACKAGE_PATH first
varname = 'MEQTREES_%s_PATH'%package.upper()
path = os.environ.get(varname,None);
@@ -97,6 +98,15 @@ def _setPackagePath (package):
path = os.path.expanduser(path);
if _tryPackageDir(os.path.join(path,package),package):
return;
+ # else do a standard import
+ try:
+ mod = __import__(package);
+ except ImportError:
+ pass;
+ else:
+ path = os.path.split(os.path.split(mod.__file__)[0])[0];
+ if _tryPackageDir(os.path.join(path,package),package):
+ return;
# none found
print "Warning: No %s package found."%package;
print "If you have %s in a non-standard location, please set the %s environment"%(package,varname);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment