Merged changes from 3.14 branch
Includes all changes up to revno 12334 on 2012-04-04
This commit is contained in:
@@ -416,7 +416,7 @@ static long getCharChar(
|
||||
char *pbuffer = (char *)pto;
|
||||
char *psrc=(char *)(paddr->pfield);
|
||||
|
||||
if (paddr->pfldDes->field_type == DBF_STRING) {
|
||||
if (paddr->pfldDes && paddr->pfldDes->field_type == DBF_STRING) {
|
||||
/* This is a DBF_STRING field being read as a long string.
|
||||
* The buffer we return must be zero-terminated.
|
||||
*/
|
||||
@@ -443,7 +443,7 @@ static long getCharUchar(
|
||||
unsigned char *pbuffer = (unsigned char *)pto;
|
||||
char *psrc=(char *)(paddr->pfield);
|
||||
|
||||
if (paddr->pfldDes->field_type == DBF_STRING) {
|
||||
if (paddr->pfldDes && paddr->pfldDes->field_type == DBF_STRING) {
|
||||
/* This is a DBF_STRING field being read as a long string.
|
||||
* The buffer we return must be zero-terminated.
|
||||
*/
|
||||
@@ -2600,7 +2600,7 @@ static long putStringEnum(
|
||||
status = (*prset->get_enum_strs)(paddr,&enumStrs);
|
||||
if(!status) {
|
||||
nchoices = enumStrs.no_str;
|
||||
nargs = sscanf(pbuffer," %u %n",&ind,&nchars);
|
||||
nargs = sscanf(pbuffer,"%u%n",&ind,&nchars);
|
||||
if(nargs==1 && nchars==strlen(pbuffer) && ind<nchoices) {
|
||||
*pfield = ind;
|
||||
return(0);
|
||||
@@ -2649,7 +2649,7 @@ static long putStringMenu(
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
nargs = sscanf(pbuffer," %u %n",&ind,&nchars);
|
||||
nargs = sscanf(pbuffer,"%u%n",&ind,&nchars);
|
||||
if(nargs==1 && nchars==strlen(pbuffer) && ind<nChoice) {
|
||||
*pfield = ind;
|
||||
return(0);
|
||||
@@ -2687,7 +2687,7 @@ static long putStringDevice(
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
nargs = sscanf(pbuffer," %u %n",&ind,&nchars);
|
||||
nargs = sscanf(pbuffer,"%u%n",&ind,&nchars);
|
||||
if(nargs==1 && nchars==strlen(pbuffer) && ind<nChoice) {
|
||||
*pfield = ind;
|
||||
return(0);
|
||||
|
||||
@@ -272,7 +272,7 @@ static long cvt_st_e(
|
||||
status = (*prset->get_enum_strs)(paddr,&enumStrs);
|
||||
if(!status) {
|
||||
nchoices = enumStrs.no_str;
|
||||
nargs = sscanf(from," %u %n",&ind,&nchars);
|
||||
nargs = sscanf(from,"%u%n",&ind,&nchars);
|
||||
if(nargs==1 && nchars==strlen(from) && ind<nchoices) {
|
||||
*pfield = ind;
|
||||
return(0);
|
||||
@@ -315,7 +315,7 @@ static long cvt_st_menu(
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
nargs = sscanf(from," %u %n",&ind,&nchars);
|
||||
nargs = sscanf(from,"%u%n",&ind,&nchars);
|
||||
if(nargs==1 && nchars==strlen(from) && ind<nChoice) {
|
||||
*to = ind;
|
||||
return(0);
|
||||
@@ -347,7 +347,7 @@ static long cvt_st_device(
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
nargs = sscanf(from," %u %n",&ind,&nchars);
|
||||
nargs = sscanf(from,"%u%n",&ind,&nchars);
|
||||
if(nargs==1 && nchars==strlen(from) && ind<nChoice) {
|
||||
*to = ind;
|
||||
return(0);
|
||||
|
||||
@@ -238,7 +238,7 @@ MAIN(epicsCalcTest)
|
||||
const double a=1.0, b=2.0, c=3.0, d=4.0, e=5.0, f=6.0,
|
||||
g=7.0, h=8.0, i=9.0, j=10.0, k=11.0, l=12.0;
|
||||
|
||||
testPlan(566);
|
||||
testPlan(570);
|
||||
|
||||
/* LITERAL_OPERAND elements */
|
||||
testExpr(0);
|
||||
@@ -325,11 +325,15 @@ MAIN(epicsCalcTest)
|
||||
testExpr(isinf(NaN));
|
||||
testExpr(isnan(0));
|
||||
testExpr(isnan(Inf));
|
||||
testExpr(isnan(-Inf));
|
||||
testExpr(isnan(NaN));
|
||||
testCalc("isnan(0,1,2)", 0);
|
||||
testCalc("isnan(0,1,NaN)", 1);
|
||||
testCalc("isnan(0,NaN,2)", 1);
|
||||
testCalc("isnan(NaN,1,2)", 1);
|
||||
testCalc("isnan(0,1,Inf)", 0);
|
||||
testCalc("isnan(0,Inf,2)", 0);
|
||||
testCalc("isnan(Inf,1,2)", 0);
|
||||
testCalc("isnan(0,1,-Inf)", 0);
|
||||
testCalc("isnan(0,-Inf,2)", 0);
|
||||
testCalc("isnan(-Inf,1,2)", 0);
|
||||
|
||||
@@ -38,22 +38,17 @@ struct l_fp { /* NTP time stamp */
|
||||
epicsUInt32 l_uf; /* fractional seconds */
|
||||
};
|
||||
|
||||
epicsTime useSomeCPU;
|
||||
|
||||
static const unsigned mSecPerSec = 1000u;
|
||||
static const unsigned uSecPerSec = 1000u * mSecPerSec;
|
||||
static const unsigned nSecPerSec = 1000u * uSecPerSec;
|
||||
|
||||
static const double precisionEPICS = 1.0 / nSecPerSec;
|
||||
|
||||
MAIN(epicsTimeTest)
|
||||
{
|
||||
const unsigned wasteTime = 100000u;
|
||||
const int wasteTime = 100000;
|
||||
const int nTimes = 10;
|
||||
const double precisionEPICS = 1.0 / nSecPerSec;
|
||||
|
||||
testPlan(15 + nTimes * 18);
|
||||
|
||||
const epicsTime begin = epicsTime::getCurrent();
|
||||
testPlan(16 + nTimes * 18);
|
||||
|
||||
{
|
||||
const epicsTimeStamp epochTS = {0, 0};
|
||||
@@ -66,16 +61,6 @@ MAIN(epicsTimeTest)
|
||||
testOk1(epicsEpoch.ansi_tm.tm_year == 90);
|
||||
}
|
||||
|
||||
{
|
||||
epicsTime tsi = epicsTime::getCurrent ();
|
||||
l_fp ntp = tsi;
|
||||
epicsTime tsf = ntp;
|
||||
const double diff = fabs ( tsf - tsi );
|
||||
// the difference in the precision of the two time formats
|
||||
static const double precisionNTP = 1.0 / ( 1.0 + 0xffffffff );
|
||||
testOk1(diff <= precisionEPICS + precisionNTP);
|
||||
}
|
||||
|
||||
{ // badNanosecTest
|
||||
static const char * pFormat = "%a %b %d %Y %H:%M:%S.%4f";
|
||||
try {
|
||||
@@ -90,7 +75,7 @@ MAIN(epicsTimeTest)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
{ // strftime() output
|
||||
char buf[80];
|
||||
epicsTime et;
|
||||
|
||||
@@ -125,70 +110,87 @@ MAIN(epicsTimeTest)
|
||||
pFormat = "%%S.%%05f";
|
||||
et.strftime(buf, sizeof(buf), pFormat);
|
||||
testOk(strcmp(buf, "%S.%05f") == 0, "'%s' => '%s'", pFormat, buf);
|
||||
|
||||
char bigBuf [512];
|
||||
memset(bigBuf, '\a', sizeof(bigBuf));
|
||||
bigBuf[ sizeof(bigBuf) - 1] = '\0';
|
||||
et.strftime(buf, sizeof(buf), bigBuf);
|
||||
testOk(strcmp(buf, "<invalid format>") == 0, "bad format => '%s'", buf);
|
||||
}
|
||||
|
||||
{ // invalidFormatTest
|
||||
char bigBuf [512];
|
||||
char buf [32];
|
||||
memset(bigBuf, '\a', sizeof(bigBuf ));
|
||||
bigBuf[ sizeof(bigBuf) - 1] = '\0';
|
||||
begin.strftime(buf, sizeof(buf), bigBuf);
|
||||
testOk(strcmp(buf, "<invalid format>") == 0, "bad format => '%s'", buf);
|
||||
epicsTime now;
|
||||
try {
|
||||
now = epicsTime::getCurrent();
|
||||
testPass("default time provider");
|
||||
}
|
||||
catch ( ... ) {
|
||||
testFail("epicsTime::getCurrent() throws");
|
||||
testAbort("Can't continue, check your time provider");
|
||||
}
|
||||
|
||||
{
|
||||
l_fp ntp = now;
|
||||
epicsTime tsf = ntp;
|
||||
const double diff = fabs(tsf - now);
|
||||
// the difference in the precision of the two time formats
|
||||
static const double precisionNTP = 1.0 / (1.0 + 0xffffffff);
|
||||
testOk1(diff <= precisionEPICS + precisionNTP);
|
||||
}
|
||||
|
||||
testDiag("Running %d loops", nTimes);
|
||||
|
||||
for (int iTimes=0; iTimes < nTimes; ++iTimes) {
|
||||
for (unsigned i=0; i<wasteTime; i++) {
|
||||
useSomeCPU = epicsTime::getCurrent();
|
||||
const epicsTime begin = epicsTime::getCurrent();
|
||||
|
||||
for (int loop = 0; loop < nTimes; ++loop) {
|
||||
for (int i = 0; i < wasteTime; ++i) {
|
||||
now = epicsTime::getCurrent();
|
||||
}
|
||||
|
||||
const epicsTime end = epicsTime::getCurrent();
|
||||
const double diff = end - begin;
|
||||
const double diff = now - begin;
|
||||
|
||||
if (iTimes == 0) {
|
||||
if (loop == 0) {
|
||||
testDiag ("%d calls to epicsTime::getCurrent() "
|
||||
"averaged %6.3f usec each", wasteTime,
|
||||
diff*1e6/wasteTime);
|
||||
diff * 1e6 / wasteTime);
|
||||
}
|
||||
|
||||
epicsTime copy = end;
|
||||
testOk1(copy == end);
|
||||
testOk1(copy <= end);
|
||||
testOk1(copy >= end);
|
||||
epicsTime copy = now;
|
||||
testOk1(copy == now);
|
||||
testOk1(copy <= now);
|
||||
testOk1(copy >= now);
|
||||
|
||||
testOk1(end > begin);
|
||||
testOk1(end >= begin);
|
||||
testOk1(begin != end);
|
||||
testOk1(begin < end);
|
||||
testOk1(begin <= end);
|
||||
testOk1(now > begin);
|
||||
testOk1(now >= begin);
|
||||
testOk1(begin != now);
|
||||
testOk1(begin < now);
|
||||
testOk1(begin <= now);
|
||||
|
||||
testOk1(end - end == 0);
|
||||
testOk(fabs((end - begin) - diff) < precisionEPICS * 0.01,
|
||||
"end - begin ~= diff");
|
||||
testOk1(now - now == 0);
|
||||
testOk(fabs((now - begin) - diff) < precisionEPICS * 0.01,
|
||||
"now - begin ~= diff");
|
||||
|
||||
testOk1(begin + 0 == begin);
|
||||
testOk1(begin + diff == end);
|
||||
testOk1(end - 0 == end);
|
||||
testOk1(end - diff == begin);
|
||||
testOk1(begin + diff == now);
|
||||
testOk1(now - 0 == now);
|
||||
testOk1(now - diff == begin);
|
||||
|
||||
epicsTime end2 = begin;
|
||||
end2 += diff;
|
||||
testOk(end2 == end, "(begin += diff) == end");
|
||||
epicsTime end = begin;
|
||||
end += diff;
|
||||
testOk(end == now, "(begin += diff) == now");
|
||||
|
||||
end2 = end;
|
||||
end2 -= diff;
|
||||
testOk(end2 == begin, "(end -= diff) == begin");
|
||||
end = now;
|
||||
end -= diff;
|
||||
testOk(end == begin, "(now -= diff) == begin");
|
||||
|
||||
// test struct tm round-trip conversion
|
||||
local_tm_nano_sec ansiDate = begin;
|
||||
epicsTime beginANSI = ansiDate;
|
||||
testOk1(beginANSI + diff == end);
|
||||
testOk1(beginANSI + diff == now);
|
||||
|
||||
// test struct timespec round-trip conversion
|
||||
struct timespec ts = begin;
|
||||
epicsTime beginTS = ts;
|
||||
testOk1(beginTS + diff == end);
|
||||
testOk1(beginTS + diff == now);
|
||||
}
|
||||
|
||||
return testDone();
|
||||
|
||||
@@ -252,6 +252,7 @@ static long process(calcoutRecord *prec)
|
||||
if (doOutput) {
|
||||
if (prec->odly > 0.0) {
|
||||
prec->dlya = 1;
|
||||
recGblGetTimeStamp(prec);
|
||||
db_post_events(prec, &prec->dlya, DBE_VALUE);
|
||||
callbackRequestProcessCallbackDelayed(&prpvt->doOutCb,
|
||||
prec->prio, prec, (double)prec->odly);
|
||||
@@ -263,9 +264,11 @@ static long process(calcoutRecord *prec)
|
||||
prec->pact = TRUE;
|
||||
}
|
||||
}
|
||||
recGblGetTimeStamp(prec);
|
||||
} else { /* pact == TRUE */
|
||||
if (prec->dlya) {
|
||||
prec->dlya = 0;
|
||||
recGblGetTimeStamp(prec);
|
||||
db_post_events(prec, &prec->dlya, DBE_VALUE);
|
||||
/* Make pact FALSE for asynchronous device support*/
|
||||
prec->pact = FALSE;
|
||||
@@ -274,9 +277,9 @@ static long process(calcoutRecord *prec)
|
||||
prec->pact = TRUE;
|
||||
} else {/*Device Support is asynchronous*/
|
||||
writeValue(prec);
|
||||
recGblGetTimeStamp(prec);
|
||||
}
|
||||
}
|
||||
recGblGetTimeStamp(prec);
|
||||
monitor(prec);
|
||||
recGblFwdLink(prec);
|
||||
prec->pact = FALSE;
|
||||
|
||||
@@ -90,8 +90,6 @@ typedef struct callbackSeq {
|
||||
int index;
|
||||
}callbackSeq;
|
||||
|
||||
int processNextLink();
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
@@ -327,7 +325,9 @@ static long asyncFinish(seqRecord *prec)
|
||||
if (seqRecDebug > 5)
|
||||
printf("asyncFinish(%s) completing processing\n", prec->name);
|
||||
prec->udf = FALSE;
|
||||
|
||||
|
||||
recGblGetTimeStamp(prec);
|
||||
|
||||
MonitorMask = recGblResetAlarms(prec);
|
||||
|
||||
if (MonitorMask)
|
||||
@@ -336,8 +336,6 @@ static long asyncFinish(seqRecord *prec)
|
||||
/* process the forward scan link record */
|
||||
recGblFwdLink(prec);
|
||||
|
||||
recGblGetTimeStamp(prec);
|
||||
/* tsLocalTime(&prec->time); */
|
||||
prec->pact = FALSE;
|
||||
|
||||
return(0);
|
||||
@@ -377,6 +375,8 @@ static void processCallback(CALLBACK *arg)
|
||||
dbGetLink(&(pcb->plinks[pcb->index]->dol), DBR_DOUBLE,
|
||||
&(pcb->plinks[pcb->index]->dov),0,0);
|
||||
|
||||
recGblGetTimeStamp(prec);
|
||||
|
||||
/* Dump the value to the destination field */
|
||||
dbPutLink(&(pcb->plinks[pcb->index]->lnk), DBR_DOUBLE,
|
||||
&(pcb->plinks[pcb->index]->dov),1);
|
||||
|
||||
Reference in New Issue
Block a user