From 1aeb6776c5b433370870c8433794f9c2ea338dee Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 14:24:55 +0200 Subject: [PATCH 01/12] fix wrong data type for readlink result --- pciApp/os/Linux/devLibPCIOSD.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pciApp/os/Linux/devLibPCIOSD.c b/pciApp/os/Linux/devLibPCIOSD.c index 35a11ab..5b2927b 100644 --- a/pciApp/os/Linux/devLibPCIOSD.c +++ b/pciApp/os/Linux/devLibPCIOSD.c @@ -772,7 +772,7 @@ linuxDevPCIFindCB( static const char* fd2filename(int fd, char* buffer, size_t buffersize) { char procfile[32]; - size_t n; + ssize_t n; sprintf(procfile, "/proc/self/fd/%d", fd); n = readlink(procfile, buffer, buffersize-1); From f5cb22fc42db02ad4fb129c4c89721ade5761a60 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 15:37:20 +0200 Subject: [PATCH 02/12] avoid pointless casting which generates warnings with some compilers --- exploreApp/src/devexplore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exploreApp/src/devexplore.cpp b/exploreApp/src/devexplore.cpp index 833dd86..33352fb 100644 --- a/exploreApp/src/devexplore.cpp +++ b/exploreApp/src/devexplore.cpp @@ -138,7 +138,7 @@ struct priv { template VAL read(epicsUInt32 off=0) const { - epicsUInt32 OV(readraw(off)); + epicsUInt32 OV(readraw(off)); if(vmask) OV &= vmask; OV >>= vshift; return OV; @@ -152,7 +152,7 @@ struct priv { unsigned i; for(i=0; i(addr); + epicsUInt32 OV = read(addr); *val++ = castval::op(OV); } return i; From deabaf353571e06ca9addcce763b1f74533fdcf7 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 15:37:47 +0200 Subject: [PATCH 03/12] cannot initialize unsigned with -1 --- exploreApp/src/devexplore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exploreApp/src/devexplore.cpp b/exploreApp/src/devexplore.cpp index 33352fb..44d8310 100644 --- a/exploreApp/src/devexplore.cpp +++ b/exploreApp/src/devexplore.cpp @@ -485,7 +485,7 @@ long explore_write_wf(waveformRecord *prec) { TRY { Guard G(pvt->lock); - unsigned nwritten = -1; + unsigned nwritten = 0; switch(prec->ftvl) { case menuFtypeCHAR : case menuFtypeUCHAR : nwritten = pvt->writeArray((epicsUInt8*) prec->bptr, prec->nord); break; From 04d6582f9aafa2c0926d9ea93bd42bc7aecfb009 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 14:48:45 +0200 Subject: [PATCH 04/12] fix for Windows function name --- pciApp/devLibPCI.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pciApp/devLibPCI.c b/pciApp/devLibPCI.c index 1325ff8..e0f92cd 100644 --- a/pciApp/devLibPCI.c +++ b/pciApp/devLibPCI.c @@ -39,6 +39,11 @@ #define strdup(x) ({char*s=malloc(strlen(x)+1);s?strcpy(s,x):s;}) #endif +#ifdef _WIN32 +/* Windows uses different name for strtok_r */ + #define strtok_r strtok_s +#endif + int devPCIDebug = 0; static ELLLIST pciDrivers; From e61c82f73bbbeb5971741439fdccef51baa1145a Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 15:55:59 +0200 Subject: [PATCH 05/12] print pointers with %p --- vmeApp/vmesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vmeApp/vmesh.c b/vmeApp/vmesh.c index ccfa34a..bbd2a65 100644 --- a/vmeApp/vmesh.c +++ b/vmeApp/vmesh.c @@ -67,7 +67,7 @@ int validate_widths(epicsUInt32 addr, int amod, int dmod, int count, volatile vo return 1; } - epicsPrintf("Mapped to 0x%08lx\n",(unsigned long)*mptr); + epicsPrintf("Mapped to 0x%p\n",*mptr); return 0; } From 9498ed16d63ed5b66412b0ab40abc0973446ed82 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 16:08:41 +0200 Subject: [PATCH 06/12] avoid mixed epicsFloat32/64 caclulations --- exploreApp/src/devexplore.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/exploreApp/src/devexplore.cpp b/exploreApp/src/devexplore.cpp index 44d8310..e467f7f 100644 --- a/exploreApp/src/devexplore.cpp +++ b/exploreApp/src/devexplore.cpp @@ -408,14 +408,14 @@ long explore_read_real_val(REC *prec) Guard G(pvt->lock); ival = pun.ival = pvt->read(); } + epicsFloat64 dval = pun.fval; + dval += prec->roff; + if(prec->aslo) dval *= prec->aslo; + dval += prec->aoff; + if(prec->eslo) dval *= prec->eslo; + dval += prec->eoff; - pun.fval += prec->roff; - if(prec->aslo) pun.fval *= prec->aslo; - pun.fval += prec->aoff; - if(prec->eslo) pun.fval *= prec->eslo; - pun.fval += prec->eoff; - - prec->val = pun.fval; + prec->val = dval; if(prec->tpro>1) { errlogPrintf("%s: read %08x -> %08x -> VAL=%g\n", prec->name, (unsigned)pvt->offset, (unsigned)ival, prec->val); @@ -430,13 +430,14 @@ long explore_write_real_val(REC *prec) { TRY { punny32 pun; - pun.fval = prec->val; - - pun.fval -= prec->eoff; - if(prec->eslo) pun.fval /= prec->eslo; - pun.fval -= prec->aoff; - if(prec->aslo) pun.fval /= prec->aslo; - pun.fval -= prec->roff; + epicsFloat64 dval = prec->val; + + dval -= prec->eoff; + if(prec->eslo) dval /= prec->eslo; + dval -= prec->aoff; + if(prec->aslo) dval /= prec->aslo; + dval -= prec->roff; + pun.fval = (epicsFloat32)dval; if(prec->tpro>1) { errlogPrintf("%s: write %08x <- %08x <- VAL=%g\n", prec->name, (unsigned)pvt->offset, (unsigned)pun.ival, prec->val); From 0b10c1cc28329c99efa92ddac6ce6097279c7298 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 16:11:09 +0200 Subject: [PATCH 07/12] Windows needs #define NOMINMAX and #include for std::min --- exploreApp/src/devexplore_frib.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exploreApp/src/devexplore_frib.cpp b/exploreApp/src/devexplore_frib.cpp index 21ae974..a33dd7a 100644 --- a/exploreApp/src/devexplore_frib.cpp +++ b/exploreApp/src/devexplore_frib.cpp @@ -4,6 +4,8 @@ */ // FRIB specific operations +#define NOMINMAX +#include #include #include #include From 373d8fce0223086c4e4deeb4c8913328850fe07e Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 16:12:59 +0200 Subject: [PATCH 08/12] Windows needs extra libs for program *and* libraries --- exploreApp/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exploreApp/src/Makefile b/exploreApp/src/Makefile index 57e5865..8fbb8c7 100644 --- a/exploreApp/src/Makefile +++ b/exploreApp/src/Makefile @@ -7,7 +7,7 @@ include $(TOP)/configure/CONFIG USR_CPPFLAGS += -I$(TOP)/common -PROD_SYS_LIBS_WIN32 += ws2_32 advapi32 user32 +USR_SYS_LIBS_WIN32 += ws2_32 advapi32 user32 # explore app doesn't build with older vxworks (eg. tornado22) # don't build at all until someone asks From 1891a6d03b46c98989ec80b77b7a65fb205f0733 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 16:14:44 +0200 Subject: [PATCH 09/12] Windows needs #include for pdbbase --- exploreApp/src/devexplore_frib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/exploreApp/src/devexplore_frib.cpp b/exploreApp/src/devexplore_frib.cpp index a33dd7a..4c8214e 100644 --- a/exploreApp/src/devexplore_frib.cpp +++ b/exploreApp/src/devexplore_frib.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include From 82168cba38ee4d0c597c08a140e39b876121fc5d Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 16:17:31 +0200 Subject: [PATCH 10/12] Windows needs dsets to be exported extern "C" --- exploreApp/src/devexplore.cpp | 3 +++ exploreApp/src/devexplore_frib.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/exploreApp/src/devexplore.cpp b/exploreApp/src/devexplore.cpp index e467f7f..b0438ee 100644 --- a/exploreApp/src/devexplore.cpp +++ b/exploreApp/src/devexplore.cpp @@ -528,6 +528,8 @@ struct dset6 { } // namespace +extern "C" { + #define SUP(NAME, REC, OP, DIR, SIZE, END) static dset6 NAME = \ {6, NULL, NULL, &explore_init_record_##OP, NULL, &explore_##DIR##_##OP, NULL}; \ epicsExportAddress(dset, NAME) @@ -638,3 +640,4 @@ SUP(devExploreWfWriteU16MSB, write, 2, priv::BE); SUP(devExploreWfWriteU32NAT, write, 4, priv::NAT); SUP(devExploreWfWriteU32LSB, write, 4, priv::LE); SUP(devExploreWfWriteU32MSB, write, 4, priv::BE); +} // extern "C" diff --git a/exploreApp/src/devexplore_frib.cpp b/exploreApp/src/devexplore_frib.cpp index 4c8214e..2b5f002 100644 --- a/exploreApp/src/devexplore_frib.cpp +++ b/exploreApp/src/devexplore_frib.cpp @@ -443,6 +443,9 @@ struct dset6 { } // namespace +extern "C" { DSET(devExploreFRIBFlashWf, &init_record_common, NULL, &load_bitfile_wf); DSET(devExploreFRIBFlashLo, &init_record_common, NULL, &startstop_lo); DSET(devExploreFRIBFlashMbbi, &init_record_common, &status_get_iointr_info, &status_mbbi); +} // extern "C" + From c4e03e049131f67a438b31ae0ce4246a43b3e55f Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 16:23:02 +0200 Subject: [PATCH 11/12] fix type cast related Windows warnings --- exploreApp/src/devexplore_frib.cpp | 2 +- exploreApp/src/testexplore.cpp | 2 +- vmeApp/vmesh.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/exploreApp/src/devexplore_frib.cpp b/exploreApp/src/devexplore_frib.cpp index 2b5f002..02d853b 100644 --- a/exploreApp/src/devexplore_frib.cpp +++ b/exploreApp/src/devexplore_frib.cpp @@ -164,7 +164,7 @@ struct flashProg : public epicsThreadRunable { assert((file.size()%16u==0)); const epicsUInt32 fstart = flash_offset, - fend = flash_offset + std::min(file.size(), (size_t)flash_size); + fend = flash_offset + std::min((epicsUInt32)file.size(), flash_size); epicsUInt32 id = read32(REG_LOCKOUT); if(id!=0xF1A54001) diff --git a/exploreApp/src/testexplore.cpp b/exploreApp/src/testexplore.cpp index 250cba2..e2bdcde 100644 --- a/exploreApp/src/testexplore.cpp +++ b/exploreApp/src/testexplore.cpp @@ -50,7 +50,7 @@ struct Channel { val.resize(nReq); } void put_int32(const std::vector& val) { - if(dbChannelPutField(chan, DBF_ULONG, &val[0], val.size())) + if(dbChannelPutField(chan, DBF_ULONG, &val[0], (long)val.size())) testAbort("get %s fails", dbChannelName(chan)); } }; diff --git a/vmeApp/vmesh.c b/vmeApp/vmesh.c index bbd2a65..ec80b06 100644 --- a/vmeApp/vmesh.c +++ b/vmeApp/vmesh.c @@ -182,7 +182,7 @@ static void vmesh_handler(void *raw) { volatile epicsUInt8 *ent = raw; - unsigned vect = ent-vmeautodisable; + unsigned char vect = (unsigned char)(ent-vmeautodisable); char msg[] = "VME IRQ on vector 0xXY\n"; unsigned I = sizeof(msg)-3; From 890e8d51d340a74e50880f4e1ff1c42d40c04697 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 20 Aug 2020 17:06:37 +0200 Subject: [PATCH 12/12] backward compatibility with base R3.14 --- exploreApp/src/devexplore_frib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exploreApp/src/devexplore_frib.cpp b/exploreApp/src/devexplore_frib.cpp index 02d853b..2b00067 100644 --- a/exploreApp/src/devexplore_frib.cpp +++ b/exploreApp/src/devexplore_frib.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include