From 0e28ff55c6ea08e02ec649eb60c831114c6593ab Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 13 Jun 2014 15:37:10 -0400 Subject: [PATCH 1/5] add include --- src/ioc/db/dbConvert.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ioc/db/dbConvert.h b/src/ioc/db/dbConvert.h index a7e3dc70a..afd13c7c2 100644 --- a/src/ioc/db/dbConvert.h +++ b/src/ioc/db/dbConvert.h @@ -12,6 +12,7 @@ #define INCdbConverth #include "dbFldTypes.h" +#include "dbAddr.h" #include "shareLib.h" #ifdef __cplusplus From 1a0ba81d0dd87ebf17e1f3e417d884c55d77ebd9 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 13 Jun 2014 15:37:11 -0400 Subject: [PATCH 2/5] dbConvert: optimize copy w/o convert Use memcpy() where input and output memory representations are the exactly the same (integer and floating point types). Assumes 2s complement integer types and that signed and unsigned types have the same representation. --- src/ioc/db/dbConvert.c | 234 ++++++++++------------------------------- 1 file changed, 54 insertions(+), 180 deletions(-) diff --git a/src/ioc/db/dbConvert.c b/src/ioc/db/dbConvert.c index 2f8f89347..7223e97f2 100644 --- a/src/ioc/db/dbConvert.c +++ b/src/ioc/db/dbConvert.c @@ -38,6 +38,29 @@ #include "recGbl.h" #include "dbConvert.h" +/* Helper for copy as bytes with no type conversion. + * Assumes nRequest <= no_bytes + * nRequest, no_bytes, and offset should be given in bytes. + */ +static void copyNoConvert(const void *pfrom, + void *pto, + long nRequest, + long no_bytes, + long offset) +{ + if(offset>0 && offset < no_bytes && offset+nRequest > no_bytes) { + const size_t N = no_bytes - offset; + /* copy with wrap */ + memcpy(pto, pfrom + offset, N); + memcpy(pto + N, pfrom, nRequest - N); + } else { + /* no wrap, just copy */ + memcpy(pto, pfrom + offset, nRequest); + } +} +#define COPYNOCONVERT(N, FROM, TO, NREQ, NO_ELEM, OFFSET) \ + copyNoConvert(FROM, TO, (N)*(NREQ), (N)*(NO_ELEM), (N)*(OFFSET)) + /* DATABASE ACCESS GET CONVERSION SUPPORT */ static long getStringString ( @@ -427,12 +450,7 @@ static long getCharChar( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(char *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(char), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -454,12 +472,7 @@ static long getCharUchar( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(char *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(char), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -638,12 +651,7 @@ static long getUcharChar( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(unsigned char *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(unsigned char), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -658,12 +666,7 @@ static long getUcharUchar( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(unsigned char *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(unsigned char), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -870,6 +873,7 @@ static long getShortUchar( } return(0); } + static long getShortShort( const dbAddr *paddr, void *pto, long nRequest, long no_elements, long offset) @@ -881,12 +885,7 @@ static long getShortShort( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(short *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(short), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -901,12 +900,7 @@ static long getShortUshort( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(short *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(short), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -1084,12 +1078,7 @@ static long getUshortShort( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(unsigned short *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(unsigned short), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -1104,12 +1093,7 @@ static long getUshortUshort( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(unsigned short *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(unsigned short), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -1328,12 +1312,7 @@ static long getLongLong( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(epicsInt32 *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(long), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -1348,12 +1327,7 @@ static long getLongUlong( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(epicsInt32 *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(long), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -1532,12 +1506,7 @@ static long getUlongLong( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(epicsUInt32 *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(unsigned long), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -1552,12 +1521,7 @@ static long getUlongUlong( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(epicsUInt32 *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(unsigned long), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -1782,12 +1746,7 @@ static long getFloatFloat( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(float *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(float), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -2013,12 +1972,7 @@ static long getDoubleDouble( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(double *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(double), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -2228,12 +2182,7 @@ static long getEnumEnum( *pbuffer = *psrc; return(0); } - psrc += offset; - while (nRequest) { - *pbuffer++ = *psrc++; - if(++offset==no_elements) psrc=(epicsEnum16 *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(epicsEnum16), paddr->pfield, pto, nRequest, no_elements, offset); return(0); } @@ -2734,12 +2683,7 @@ static long putCharChar( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(char *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(char), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -2754,12 +2698,7 @@ static long putCharUchar( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(unsigned char *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(unsigned char), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -2940,12 +2879,7 @@ static long putUcharChar( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(char *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(unsigned char), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -2960,12 +2894,7 @@ static long putUcharUchar( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(unsigned char *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(unsigned char), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -3186,12 +3115,7 @@ static long putShortShort( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(short *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(short), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -3206,12 +3130,7 @@ static long putShortUshort( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(unsigned short *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(short), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -3392,12 +3311,7 @@ static long putUshortShort( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(short *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(unsigned short), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -3412,12 +3326,7 @@ static long putUshortUshort( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(unsigned short *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(unsigned short), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -3638,12 +3547,7 @@ static long putLongLong( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(epicsInt32 *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(epicsInt32), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -3658,12 +3562,7 @@ static long putLongUlong( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(epicsUInt32 *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(epicsInt32), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -3844,12 +3743,7 @@ static long putUlongLong( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(epicsInt32 *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(epicsUInt32), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -3864,12 +3758,7 @@ static long putUlongUlong( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(epicsUInt32 *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(epicsUInt32), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -4095,12 +3984,7 @@ static long putFloatFloat( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(float *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(float), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -4327,12 +4211,7 @@ static long putDoubleDouble( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(double *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(double), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } @@ -4553,12 +4432,7 @@ static long putEnumEnum( *pdest = *pbuffer; return(0); } - pdest += offset; - while (nRequest) { - *pdest++ = *pbuffer++; - if(++offset==no_elements) pdest=(epicsEnum16 *)paddr->pfield; - nRequest--; - } + COPYNOCONVERT(sizeof(epicsEnum16), pfrom, paddr->pfield, nRequest, no_elements, offset); return(0); } From fe61d4615354c8eff35be9e452d5a0b5e4a07bab Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 13 Jun 2014 15:37:11 -0400 Subject: [PATCH 3/5] add testdbConvert --- src/ioc/db/test/Makefile | 5 + src/ioc/db/test/epicsRunDbTests.c | 2 + src/ioc/db/test/testdbConvert.c | 166 ++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+) create mode 100644 src/ioc/db/test/testdbConvert.c diff --git a/src/ioc/db/test/Makefile b/src/ioc/db/test/Makefile index 2f428aa5b..242d28a1c 100644 --- a/src/ioc/db/test/Makefile +++ b/src/ioc/db/test/Makefile @@ -16,6 +16,11 @@ xRec_SRCS = xRecord.c PROD_LIBS = xRec dbCore ca Com +TESTPROD_HOST += testdbConvert +testdbConvert_SRCS += testdbConvert.c +testHarness_SRCS += testdbConvert.c +TESTS += testdbConvert + TESTPROD_HOST += callbackTest callbackTest_SRCS += callbackTest.c testHarness_SRCS += callbackTest.c diff --git a/src/ioc/db/test/epicsRunDbTests.c b/src/ioc/db/test/epicsRunDbTests.c index d8633702e..98b0b417a 100644 --- a/src/ioc/db/test/epicsRunDbTests.c +++ b/src/ioc/db/test/epicsRunDbTests.c @@ -16,6 +16,7 @@ #include "epicsExit.h" #include "dbmf.h" +int testdbConvert(void); int callbackTest(void); int dbStateTest(void); int testDbChannel(void); @@ -26,6 +27,7 @@ void epicsRunDbTests(void) { testHarness(); + runTest(testdbConvert); runTest(callbackTest); runTest(dbStateTest); runTest(testDbChannel); diff --git a/src/ioc/db/test/testdbConvert.c b/src/ioc/db/test/testdbConvert.c new file mode 100644 index 000000000..8a1f0a97f --- /dev/null +++ b/src/ioc/db/test/testdbConvert.c @@ -0,0 +1,166 @@ +/*************************************************************************\ +* Copyright (c) 2013 Brookhaven Science Assoc, as Operator of Brookhaven +* National Laboratory. +\*************************************************************************/ +#include "string.h" + +#include "cantProceed.h" +#include "dbConvert.h" +#include "dbDefs.h" +#include "epicsAssert.h" + +#include "epicsUnitTest.h" +#include "testMain.h" + +static const short s_input[] = {-1,0,1,2,3,4,5}; +static const size_t s_input_len = NELEMENTS(s_input); + +static void testBasicGet(void) +{ + short *scratch; + DBADDR addr; + GETCONVERTFUNC getter; + + getter = dbGetConvertRoutine[DBF_SHORT][DBF_SHORT]; + + scratch = callocMustSucceed(s_input_len, sizeof(s_input), "testBasicGet"); + + memset(&addr, 0, sizeof(addr)); + addr.field_type = DBF_SHORT; + addr.field_size = s_input_len*sizeof(*scratch); + addr.no_elements = s_input_len; + addr.pfield = (void*)s_input; + + testDiag("Test dbGetConvertRoutine[DBF_SHORT][DBF_SHORT]"); + + { + testDiag("Copy out first element"); + + getter(&addr, scratch, 1, s_input_len, 0); + + testOk1(scratch[0]==s_input[0]); + + memset(scratch, 0x42, sizeof(s_input)); + } + + { + testDiag("Copy out entire array"); + + getter(&addr, scratch, s_input_len, s_input_len, 0); + + testOk1(memcmp(scratch, s_input, sizeof(s_input))==0); + + memset(scratch, 0x42, sizeof(s_input)); + } + + { + testDiag("Copy out partial array"); + + getter(&addr, scratch, 2, s_input_len, 0); + + testOk1(memcmp(scratch, s_input, sizeof(short)*2)==0); + testOk1(scratch[2]==0x4242); + + memset(scratch, 0x42, sizeof(s_input)); + } + + { + testDiag("Copy out w/ offset"); + + getter(&addr, scratch, 2, s_input_len, 1); + + testOk1(memcmp(scratch, s_input+1, sizeof(short)*2)==0); + testOk1(scratch[2]==0x4242); + + memset(scratch, 0x42, sizeof(s_input)); + } + + { + testDiag("Copy out end of array"); + + getter(&addr, scratch, 2, s_input_len, s_input_len-2); + + testOk1(s_input_len-2 == 5); + + testOk1(memcmp(scratch, s_input+5, sizeof(short)*2)==0); + testOk1(scratch[2]==0x4242); + + memset(scratch, 0x42, sizeof(s_input)); + } + + { + testDiag("Copy out with wrap"); + + getter(&addr, scratch, 2, s_input_len, s_input_len-1); + + testOk1(s_input_len-2 == 5); + + testOk1(scratch[0] == s_input[6]); + testOk1(scratch[1] == s_input[0]); + testOk1(scratch[2]==0x4242); + + memset(scratch, 0x42, sizeof(s_input)); + } + + { + testDiag("Crazy copy from out of bounds offset"); + + addr.pfield = (short*)(2*sizeof(short)); + + getter(&addr, scratch, s_input_len, s_input_len, (long)(s_input-2)/sizeof(short)); + + testOk1(memcmp(scratch, s_input, sizeof(s_input))==0); + + memset(scratch, 0x42, sizeof(s_input)); + } + + free(scratch); +} + +static void testBasicPut(void) +{ + short *scratch; + DBADDR addr; + PUTCONVERTFUNC putter; + + putter = dbPutConvertRoutine[DBF_SHORT][DBF_SHORT]; + + scratch = callocMustSucceed(s_input_len, sizeof(s_input), "testBasicPut"); + + memset(&addr, 0, sizeof(addr)); + addr.field_type = DBF_SHORT; + addr.field_size = s_input_len*sizeof(*scratch); + addr.no_elements = s_input_len; + addr.pfield = (void*)scratch; + + testDiag("Test dbPutConvertRoutine[DBF_SHORT][DBF_SHORT]"); + + { + testDiag("Copy in first element"); + + putter(&addr, s_input, 1, s_input_len, 0); + + testOk1(scratch[0]==s_input[0]); + + memset(scratch, 0x42, sizeof(s_input)); + } + + { + testDiag("Copy in entire array"); + + putter(&addr, s_input, s_input_len, s_input_len, 0); + + testOk1(memcmp(scratch, s_input, sizeof(s_input))==0); + + memset(scratch, 0x42, sizeof(s_input)); + } + +} + +MAIN(testdbConvert) +{ + testPlan(16); + testBasicGet(); + testBasicPut(); + return testDone(); +} From ec576dd088a5c0206ed7179ebeb8dfda5fcb7de0 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 13 Jun 2014 15:37:12 -0400 Subject: [PATCH 4/5] benchmark dbConvert --- src/ioc/db/test/Makefile | 3 + src/ioc/db/test/benchdbConvert.c | 124 +++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 src/ioc/db/test/benchdbConvert.c diff --git a/src/ioc/db/test/Makefile b/src/ioc/db/test/Makefile index 242d28a1c..9d5aa6e37 100644 --- a/src/ioc/db/test/Makefile +++ b/src/ioc/db/test/Makefile @@ -61,6 +61,9 @@ testHarness_SRCS += arrShorthandTest_registerRecordDeviceDriver.cpp TESTFILES += $(COMMON_DIR)/arrShorthandTest.dbd TESTS += arrShorthandTest +TESTPROD_HOST += benchdbConvert +benchdbConvert_SRCS += benchdbConvert.c + # The testHarness runs all the test programs in a known working order. testHarness_SRCS += epicsRunDbTests.c diff --git a/src/ioc/db/test/benchdbConvert.c b/src/ioc/db/test/benchdbConvert.c new file mode 100644 index 000000000..cbc87ad24 --- /dev/null +++ b/src/ioc/db/test/benchdbConvert.c @@ -0,0 +1,124 @@ +/*************************************************************************\ +* Copyright (c) 2013 Brookhaven Science Assoc, as Operator of Brookhaven +* National Laboratory. +\*************************************************************************/ +#include "string.h" + +#include "cantProceed.h" +#include "dbAddr.h" +#include "dbConvert.h" +#include "dbDefs.h" +#include "epicsTime.h" +#include "epicsMath.h" +#include "epicsAssert.h" + +#include "epicsUnitTest.h" +#include "testMain.h" + +typedef struct { + size_t nelem, niter; + + short *output; + short *input; + + GETCONVERTFUNC getter; + + DBADDR addr; +} testData; + +static long runRep(testData *D) +{ + size_t i; + + for(i=0; initer; i++) { + D->getter(&D->addr, D->output, D->nelem, D->nelem, 0); + } + return 0; +} + +static void runBench(size_t nelem, size_t niter, size_t nrep) +{ + size_t i; + testData tdat; + double *reptimes; + testDiag("Using %lu element arrays.",(unsigned long)nelem); + testDiag("run %lu reps with %lu iterations each", + (unsigned long)nrep, (unsigned long)niter); + + reptimes = callocMustSucceed(nrep, sizeof(*reptimes), "runBench"); + tdat.output = callocMustSucceed(nelem, sizeof(*tdat.output), "runBench"); + tdat.input = callocMustSucceed(nelem, sizeof(*tdat.input), "runBench"); + + tdat.nelem = nelem; + tdat.niter = niter; + + tdat.getter = dbGetConvertRoutine[DBF_SHORT][DBF_SHORT]; + + memset(&tdat.addr, 0, sizeof(tdat.addr)); + tdat.addr.field_type = DBF_SHORT; + tdat.addr.field_size = nelem*sizeof(*tdat.input); + tdat.addr.no_elements = nelem; + tdat.addr.pfield = (void*)tdat.input; + + for(i=0; i Date: Fri, 13 Jun 2014 15:37:13 -0400 Subject: [PATCH 5/5] out of caution use memmove instead of memcpy --- src/ioc/db/dbConvert.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ioc/db/dbConvert.c b/src/ioc/db/dbConvert.c index 7223e97f2..00a87c896 100644 --- a/src/ioc/db/dbConvert.c +++ b/src/ioc/db/dbConvert.c @@ -51,11 +51,11 @@ static void copyNoConvert(const void *pfrom, if(offset>0 && offset < no_bytes && offset+nRequest > no_bytes) { const size_t N = no_bytes - offset; /* copy with wrap */ - memcpy(pto, pfrom + offset, N); - memcpy(pto + N, pfrom, nRequest - N); + memmove(pto, pfrom + offset, N); + memmove(pto + N, pfrom, nRequest - N); } else { /* no wrap, just copy */ - memcpy(pto, pfrom + offset, nRequest); + memmove(pto, pfrom + offset, nRequest); } } #define COPYNOCONVERT(N, FROM, TO, NREQ, NO_ELEM, OFFSET) \