From bc31c6cd1eee9d013db0fe2bef3af7d7d705feed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20K=C3=B6nnecke?= Date: Fri, 14 Mar 2014 09:48:14 +0100 Subject: [PATCH 1/2] Changes to make SICS compile on OSX Maverick with clang --- ascon.c | 4 ++-- asyncqueue.c | 2 +- asynnet.c | 2 +- chadapter.c | 5 +++-- devexec.c | 2 +- fourmess.c | 2 +- frame.c | 4 ++-- histmem.c | 2 +- hmdata.c | 3 --- initializer.c | 2 +- integrate.c | 4 +--- macosx_def | 6 ++++-- makefile_linux | 2 +- makefile_macosx | 19 +++++++++---------- network.c | 2 +- nxinter_wrap.c | 1 - remob.c | 2 +- sansbc.c | 2 +- scan.c | 4 ++-- scriptcontext.c | 2 +- sctcomtask.c | 2 +- selector.c | 2 +- sicshdbfactory.c | 2 +- sicshipadaba.c | 4 ++-- singlex.c | 8 ++++---- singlex.h | 2 +- splitter.c | 2 +- tasscanub.c | 4 ++-- tasublib.c | 2 +- ubfour.c | 2 +- 30 files changed, 49 insertions(+), 53 deletions(-) diff --git a/ascon.c b/ascon.c index be3e0a1d..ead3be90 100644 --- a/ascon.c +++ b/ascon.c @@ -40,7 +40,7 @@ static int CreateSocketAdress(struct sockaddr_in *sockaddrPtr, /* Socket addres (char *) hostent->h_addr_list[0], (size_t) hostent->h_length); } else { addr.s_addr = inet_addr(host); - if (addr.s_addr == (unsigned long) -1) { + if (addr.s_addr == (unsigned int) -1) { return 0; /* error */ } } @@ -73,7 +73,7 @@ void AsconError(Ascon *a, char *msg, int errorno) char *state; char num[8]; - if (a->state < 0 || a->state >= AsconMaxState) { + if ( a->state >= AsconMaxState) { state = "bad state"; } else { state = stateText[a->state]; diff --git a/asyncqueue.c b/asyncqueue.c index 6b75a9f8..66800fe5 100644 --- a/asyncqueue.c +++ b/asyncqueue.c @@ -85,7 +85,7 @@ static int CreateSocketAdress(struct sockaddr_in *sockaddrPtr, /* Socket addres (char *) hostent->h_addr_list[0], (size_t) hostent->h_length); } else { addr.s_addr = inet_addr(host); - if (addr.s_addr == (unsigned long) -1) { + if (addr.s_addr == (unsigned int) -1) { return 0; /* error */ } } diff --git a/asynnet.c b/asynnet.c index 8aa349b1..7f92eb46 100644 --- a/asynnet.c +++ b/asynnet.c @@ -237,7 +237,7 @@ int ANETconnect(char *name, int iPort) } else { /* check for aaa.bbbb.ccc.dddd */ addr.s_addr = inet_addr(name); - if(addr.s_addr == (unsigned long) -1) { + if(addr.s_addr == (unsigned int) -1) { anetLog(ANETERROR, "Failed to locate host: %s", name); return ANETOPENFAIL; } diff --git a/chadapter.c b/chadapter.c index 9e7d3237..290ebe53 100644 --- a/chadapter.c +++ b/chadapter.c @@ -174,8 +174,9 @@ static void KillAdapter(void *pData) if (self->pInt) free(self->pInt); - if (self->pParName); - free(self->pParName); + if (self->pParName){ + free(self->pParName); + } free(self); } diff --git a/devexec.c b/devexec.c index 7979d9eb..063e5ab0 100644 --- a/devexec.c +++ b/devexec.c @@ -498,7 +498,7 @@ int StopExe(pExeList self, char *name) assert(self); /* if not active, nothing to do */ - if ((self->pOwner == NULL) ) { + if (self->pOwner == NULL ) { self->iRun = 0; return 1; } diff --git a/fourmess.c b/fourmess.c index b6cb77b5..8e2cbf6e 100644 --- a/fourmess.c +++ b/fourmess.c @@ -393,7 +393,7 @@ static int FourMessStoreIntern(pSICSOBJ self, SConnection * pCon, double fHkl[3], double fPosition[4], char *extra) { pFourMess priv = self->pPrivate; - float fSum, fSigma, fTemp, fStep, fPreset; + float fSum, fSigma, fTemp, fStep = .0, fPreset =.0; int i, iLF, iRet, iNP, ii; long *lCounts = NULL; pEVControl pEva = NULL; diff --git a/frame.c b/frame.c index 09e06ea1..f30ed071 100644 --- a/frame.c +++ b/frame.c @@ -19,8 +19,8 @@ #include "HistMem.h" #include "HistMem.i" #include "HistDriv.i" -#include "sicspsi/hardsup/sinqhm.h" -#include "sicspsi/sinqhmdriv.i" +#include +#include #include "nxdict.h" #include "frame.h" diff --git a/histmem.c b/histmem.c index 4e92896c..8e106428 100644 --- a/histmem.c +++ b/histmem.c @@ -1129,7 +1129,7 @@ void HMListOption(pHistMem self, SConnection * pCon) static pDynString formatTOF(pHistMem self) { const float *timebin; - int iLength, i, delay, delta; + int iLength, i, delay, delta = .0; char number[20]; pDynString result = NULL; diff --git a/hmdata.c b/hmdata.c index 5584d910..68cf22b3 100644 --- a/hmdata.c +++ b/hmdata.c @@ -469,9 +469,6 @@ long sumHMDataRectangle(pHistMem hist, SConnection * pCon, return -1; break; } - if (lSum < 0) { - lSum = -lSum; - } return lSum; } diff --git a/initializer.c b/initializer.c index f64e53d8..05c1b240 100644 --- a/initializer.c +++ b/initializer.c @@ -162,7 +162,7 @@ static int RemoveObject(SConnection * con, SicsInterp * sics, p = strchr(className, ' '); if (p) { snprintf(shortClassName, sizeof shortClassName, "%.*s", - p - className, className); + (int)(p - className), className); cmdin = (CmdInitializer) GetInitializer("Object", shortClassName); } } diff --git a/integrate.c b/integrate.c index c9a8751d..5f29f7c0 100644 --- a/integrate.c +++ b/integrate.c @@ -211,7 +211,7 @@ static int FindLimit(pIntegData self, int iStart, int iSign) --------------------------------------------------------------------------*/ static int DoIntegrate(pIntegData self, float *fSum, float *fVariance) { - long lLeftBack, lRightBack, lBackMean; + long lLeftBack = 0, lRightBack, lBackMean; int i, iRes = 1; float fScan, fBackVar, fLeft, fRight, fN, fNP, fNB, fSumm; float fMLeft, fMRight; @@ -224,13 +224,11 @@ static int DoIntegrate(pIntegData self, float *fSum, float *fVariance) for (i = 0, lLeftBack = 0; i < self->iLeft; i++) { lLeftBack += self->lCounts[i]; } - lLeftBack = lLeftBack; /* sum the right background */ for (i = self->iRight, lRightBack = 0; i < self->iCounts; i++) { lRightBack += self->lCounts[i]; } - lRightBack = lRightBack; /* sum all of it */ diff --git a/macosx_def b/macosx_def index 0085c42a..f7d12721 100644 --- a/macosx_def +++ b/macosx_def @@ -8,6 +8,8 @@ #FORTIFYOBJ= fortify.o strdup.o #DFORTIFY= -pg -MFLAGS=-f makefile_linux$(DUMMY) +MFLAGS=-f makefile_macosx + +HDFROOT=/usr/pkg + -HDFROOT=/Users/Shared diff --git a/makefile_linux b/makefile_linux index 590bf7c4..ace6d454 100644 --- a/makefile_linux +++ b/makefile_linux @@ -14,7 +14,7 @@ NI= #NIOBJ= nigpib.o #NILIB=$(SINQDIR)/lib/cib.o -include linux_def +include $(SICSROOT)/sics/linux_def CC = gcc CFLAGS = -I$(HDFROOT)/include -I/usr/include/hdf -I$(TCLINC) -DHDF4 -DHDF5 \ diff --git a/makefile_macosx b/makefile_macosx index 2dc98c99..91e265f9 100644 --- a/makefile_macosx +++ b/makefile_macosx @@ -5,6 +5,7 @@ # Mark Koennecke 1996-2001 # Markus Zolliker, March 2003 # Mark Koennecke, July 2008 +# Mark Koennecke, March 2014 for Maverick #========================================================================== # assign if the National Instrument GPIB driver is available SINQDIR=/Users/Shared @@ -12,23 +13,21 @@ SINQDIR=/Users/Shared #NIOBJ= nigpib.o #NILIB=$(SINQDIR)/sl5/lib/cib.o +SICSROOT=/Users/konnecke/src include macosx_def -CC = gcc -CFLAGS = -I$(HDFROOT)/include -I/sw/include -DNXXML -DHDF5 -DHDF4 $(NI) -DMACOSX \ - -Ipsi/hardsup -I. \ +CC = clang +CFLAGS = -I$(HDFROOT)/include -I/usr/local/include -DNXXML -DHDF5 $(NI) -DMACOSX \ + -I$(SICSROOT)/psi/hardsup -I$(SICSROOT)/sicspsi -I. -I/usr/pkg/include \ -Werror -DNONINTF -g $(DFORTIFY) \ -Wall -Wno-unused -Wno-comment -Wno-switch BINTARGET = bin EXTRA=nintf.o -SUBLIBS = psi/libpsi.a psi/hardsup/libhlib.a matrix/libmatrix.a \ - psi/tecs/libtecsl.a -LIBS = -L$(HDFROOT)/lib -L/sw/lib $(SUBLIBS) $(NILIB)\ - -ltcl $(HDFROOT)/lib/libhdf5.a -lmfhdf -ldf \ - $(HDFROOT)/lib/libsz.a \ - $(HDFROOT)/lib/libjson.a -ljpeg \ - -ldl -lz -lmxml $(HDFROOT)/lib/libghttp.a -lm -lc +SUBLIBS = $(SICSROOT)/sicspsi/libpsi.a $(SICSROOT)/sicspsi/hardsup/libhlib.a matrix/libmatrix.a \ + $(SICSROOT)/sicspsi/tecs/libtecsl.a +LIBS = -L$(HDFROOT)/lib -L/usr/local/lib $(SUBLIBS) $(NILIB)\ + -ltcl -lhdf5 -lNeXus -ljson -lghttp -ldl -lz -lmxml -lm -lc include make_gen diff --git a/network.c b/network.c index be90cf31..a9801b19 100644 --- a/network.c +++ b/network.c @@ -98,7 +98,7 @@ static int CreateSocketAdress(struct sockaddr_in *sockaddrPtr, /* Socket addres (char *) hostent->h_addr_list[0], (size_t) hostent->h_length); } else { addr.s_addr = inet_addr(host); - if (addr.s_addr == (unsigned long) -1) { + if (addr.s_addr == (unsigned int) -1) { return 0; /* error */ } } diff --git a/nxinter_wrap.c b/nxinter_wrap.c index a2aaf7d7..3e76b0d0 100644 --- a/nxinter_wrap.c +++ b/nxinter_wrap.c @@ -3829,7 +3829,6 @@ SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) swig_module_info *module_head, *iter; int found; - clientdata = clientdata; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next == 0) { diff --git a/remob.c b/remob.c index 3aa384ea..ce4cf1d9 100644 --- a/remob.c +++ b/remob.c @@ -995,7 +995,7 @@ int RemobCreate(SConnection * pCon, SicsInterp * pSics, void *pData, SCPrintf(pCon, eError, "ERROR: illegal host:port"); return 0; } - snprintf(host, sizeof host, "%.*s", p - argv[3], argv[3]); + snprintf(host, sizeof host, "%.*s", (int)(p - argv[3]), argv[3]); remserver = RemServerInit(argv[2], host, atoi(p + 1)); } if (!remserver) { diff --git a/sansbc.c b/sansbc.c index 51cc1155..69cdcfa7 100644 --- a/sansbc.c +++ b/sansbc.c @@ -188,7 +188,7 @@ static int StatCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, return 0; } max = -9999; - min = 99999.99; + min = 99999; length = dim[0]*dim[1]; for(i = 0, sum = 0; i < length; i++){ sum += data[i]; diff --git a/scan.c b/scan.c index 42f74e01..21bd521c 100644 --- a/scan.c +++ b/scan.c @@ -1277,7 +1277,7 @@ static int ScanDynInterest(int iEvent, void *pEventData, void *pUser) if (pCount != NULL) { lVal = pCount->lCount; } else { - lVal = -9999.99; + lVal = -9999; } snprintf(pBueffel, 255, "%s.scanpoint = {%d %f %ld}", self->objectName, i, fVal, lVal); @@ -1624,7 +1624,7 @@ int ScanWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, float *fData = NULL; int lNP; int iChannel; - int iRet, iMode, i; + int iRet = 0, iMode, i; char *pPtr = NULL, pItem[20]; long *lData = NULL, lID; int *iData; diff --git a/scriptcontext.c b/scriptcontext.c index 21aeb6d9..3653b23c 100644 --- a/scriptcontext.c +++ b/scriptcontext.c @@ -536,7 +536,7 @@ static char *SctActionHandler(void *actionData, char *lastReply, } else { l = strlen(origScript); } - snprintf(eprop, sizeof eprop, "error_in_%.*s", l, origScript); + snprintf(eprop, sizeof eprop, "error_in_%.*s", (int)l, origScript); emsg = GetHdbProp(node, eprop); cnt = 0; if (emsg != NULL) { diff --git a/sctcomtask.c b/sctcomtask.c index 56796261..df83bd27 100644 --- a/sctcomtask.c +++ b/sctcomtask.c @@ -27,7 +27,7 @@ #include "sicsutil.h" #include "sicshipadaba.h" -static unsigned int mamaID = 0L; +static int mamaID = 0L; extern char *ParText(Hdb * cmdNode, char *name, int nPar, char *defaultValue); diff --git a/selector.c b/selector.c index 16a8c76b..ff74ef35 100644 --- a/selector.c +++ b/selector.c @@ -376,7 +376,7 @@ int MonoAction(SConnection * pCon, SicsInterp * pSics, void *pData, pSicsSelector pSelf = NULL; TokenList *pList = NULL; TokenList *pCurrent; - int iRet; + int iRet = 0; char pBueffel[132]; char pName[132]; float fVal; diff --git a/sicshdbfactory.c b/sicshdbfactory.c index 4cdf4e97..82599f2f 100644 --- a/sicshdbfactory.c +++ b/sicshdbfactory.c @@ -108,7 +108,7 @@ static int MakePlainNode(pHdb parent, char *name, SConnection * pCon, static int MakeScriptNode(pHdb parent, char *name, SConnection * pCon, int argc, char *argv[]) { - int type, length; + int type, length = 0; pHdb child = NULL; hdbValue v; diff --git a/sicshipadaba.c b/sicshipadaba.c index 82da1b6f..c11fcf75 100644 --- a/sicshipadaba.c +++ b/sicshipadaba.c @@ -2536,7 +2536,7 @@ static int ZipGetHdbNode(SConnection * pCon, SicsInterp * pSics, { pHdb targetNode = NULL; char error[512], oriPath[512]; - int status; + int status = 0; hdbValue newValue; pDynString parData = NULL, result= NULL; Protocol protocol = normal_protocol; @@ -2584,7 +2584,7 @@ static int ZipReadHdbNode(SConnection * pCon, SicsInterp * pSics, { pHdb targetNode = NULL; char error[512], oriPath[512]; - int status; + int status = 0; pDynString parData = NULL, result= NULL; Protocol protocol = normal_protocol; OutCode outCode; diff --git a/singlex.c b/singlex.c index 56a80fe2..60a8f70f 100644 --- a/singlex.c +++ b/singlex.c @@ -70,7 +70,7 @@ static MotorFunction TextToFunc(char *txt) } count++; } - return -1; + return None; } /*---------------------------------------------------------------------------*/ @@ -112,7 +112,7 @@ static int ConfigureCmd(pSICSOBJ self, SConnection * pCon, } mf = TextToFunc(v.v.text); - if (mf < 0) { + if (mf == None) { SCPrintf(pCon, eError, "ERROR: failed to map %s to configuration parameter", v.v.text); @@ -167,7 +167,7 @@ static int MotorCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode, } mf = TextToFunc(par[0]->value.v.text); - if (mf < 0) { + if (mf == None) { SCPrintf(pCon, eError, "ERROR: %s is not a four circle motor", par[0]->value.v.text); return 0; @@ -198,7 +198,7 @@ static int MotorNamCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode, } mf = TextToFunc(par[0]->value.v.text); - if (mf < 0) { + if (mf == None) { SCPrintf(pCon, eError, "ERROR: %s is not a four circle motor", par[0]->value.v.text); return 0; diff --git a/singlex.h b/singlex.h index a1fcf6d8..35f5557f 100644 --- a/singlex.h +++ b/singlex.h @@ -16,7 +16,7 @@ #include "singlediff.h" typedef enum { - TwoTheta, Omega, Chi, Phi, Nu, Sgu, Sgl + TwoTheta, Omega, Chi, Phi, Nu, Sgu, Sgl, None } MotorFunction; pMotor SXGetMotor(MotorFunction m); const char *SXGetMotorName(MotorFunction m); diff --git a/splitter.c b/splitter.c index 562cdda3..c802a037 100644 --- a/splitter.c +++ b/splitter.c @@ -56,7 +56,7 @@ static TokenList *CreateToken(TokenList * pN, TokenList * pP) static CharType CheckSpecial(char *pWord) { - CharType eRes = eText; + CharType eRes = eeText; int iFlag = 0; if (isspace(pWord[0])) diff --git a/tasscanub.c b/tasscanub.c index 5e6cb5de..0fb62607 100644 --- a/tasscanub.c +++ b/tasscanub.c @@ -184,7 +184,7 @@ static float GetVarFloat(char *name) static int TASUBHeader(pScanData self) { pTASdata pTAS = (pTASdata) self->pSpecial; - int i, iCount, status, iFileNO; + int i, iCount, status, iFileNO = 0; char pBueffel[1024], pHeader[1024], pWork[132], pWork2[60], pTen[12], *pcPtr; time_t iDate; @@ -201,7 +201,7 @@ static int TASUBHeader(pScanData self) tasReflection r; double kfix; pSicsVariable sVar = NULL; - float f1, f2, f3, f4; + float f1=.0, f2=.0, f3=.0, f4=.0; assert(self); assert(pTAS); diff --git a/tasublib.c b/tasublib.c index 1ef9efa1..5e2a28ce 100644 --- a/tasublib.c +++ b/tasublib.c @@ -163,7 +163,7 @@ double tasAngleBetweenReflections(MATRIX B, tasReflection r1, tasReflection r2) { MATRIX chi1, chi2, h1, h2; - double angle; + double angle = .0; h1 = makeVector(); if (h1 == NULL) { diff --git a/ubfour.c b/ubfour.c index 2e38f220..e76578d4 100644 --- a/ubfour.c +++ b/ubfour.c @@ -588,7 +588,7 @@ int searchIndex(lattice direct, double lambda, double two_theta, double angleBetweenReflections(MATRIX B, reflection r1, reflection r2) { MATRIX chi1, chi2, h1, h2; - double angle; + double angle = .0; h1 = makeVector(); if (h1 == NULL) { From bff0473ed6225a4f6f76c026a1496a028e79f370 Mon Sep 17 00:00:00 2001 From: Mark Koennecke Date: Fri, 14 Mar 2014 09:50:31 +0100 Subject: [PATCH 2/2] Added forgotten files to commit for compiling on Maverick --- matrix/makefile_macosx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 matrix/makefile_macosx diff --git a/matrix/makefile_macosx b/matrix/makefile_macosx new file mode 100644 index 00000000..4faeb12a --- /dev/null +++ b/matrix/makefile_macosx @@ -0,0 +1,16 @@ +#--------------------------------------------------------------------------- +# Makefile for the Matrix library +# +# Mark Koennecke, November 1996 +# Markus Zolliker, March 2003 +#-------------------------------------------------------------------------- + +include ../linux_def + +CC = clang +CFLAGS = -g $(DFORTIFY) -MMD + +include make_gen + +-include $(OBJ:.o=.d) +