diff --git a/src/ca/client/perl/caget.pl b/src/ca/client/perl/caget.pl index 7fe60d8c5..df8cb6d25 100644 --- a/src/ca/client/perl/caget.pl +++ b/src/ca/client/perl/caget.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; diff --git a/src/ca/client/perl/cainfo.pl b/src/ca/client/perl/cainfo.pl index 2f8231494..2196655b1 100644 --- a/src/ca/client/perl/cainfo.pl +++ b/src/ca/client/perl/cainfo.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; diff --git a/src/ca/client/perl/camonitor.pl b/src/ca/client/perl/camonitor.pl index 559ec1233..4d19272b2 100644 --- a/src/ca/client/perl/camonitor.pl +++ b/src/ca/client/perl/camonitor.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; diff --git a/src/ca/client/perl/capr.pl b/src/ca/client/perl/capr.pl index 4f8abac3d..04f1caa97 100644 --- a/src/ca/client/perl/capr.pl +++ b/src/ca/client/perl/capr.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl ####################################################################### # diff --git a/src/ca/client/perl/caput.pl b/src/ca/client/perl/caput.pl index bc62eead4..8d2e6b4b3 100644 --- a/src/ca/client/perl/caput.pl +++ b/src/ca/client/perl/caput.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; diff --git a/src/ca/client/perl/perlConfig.pl b/src/ca/client/perl/perlConfig.pl index 11a524595..01b9b9fdd 100644 --- a/src/ca/client/perl/perlConfig.pl +++ b/src/ca/client/perl/perlConfig.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # This script is used to extract information about the Perl build # configuration, so the EPICS build system uses the same settings. diff --git a/src/ca/legacy/gdd/Makefile b/src/ca/legacy/gdd/Makefile index cdbd10905..7276dfb72 100644 --- a/src/ca/legacy/gdd/Makefile +++ b/src/ca/legacy/gdd/Makefile @@ -64,6 +64,9 @@ aitGen_CFLAGS_linux-arm = -O2 CLEANS += $(COMMON_DIR)/aitConvertGenerated.cc +USR_CXXFLAGS_Linux = -fno-strict-aliasing +USR_CXXFLAGS_RTEMS = -fno-strict-aliasing + include $(TOP)/configure/RULES # Manual dependencies diff --git a/src/ioc/db/dbScan.c b/src/ioc/db/dbScan.c index 04005b40c..b0ea98a75 100644 --- a/src/ioc/db/dbScan.c +++ b/src/ioc/db/dbScan.c @@ -85,6 +85,7 @@ typedef struct scan_element{ typedef struct periodic_scan_list { scan_list scan_list; double period; + unsigned long overruns; volatile enum ctl scanCtl; epicsEventId loopEvent; } periodic_scan_list; @@ -350,7 +351,8 @@ int scanppl(double period) /* print periodic list */ ppsl = papPeriodic[i]; if (ppsl == NULL) continue; if (period > 0.0 && (fabs(period - ppsl->period) >.05)) continue; - sprintf(message, "Scan Period = %g seconds ", ppsl->period); + sprintf(message, "Scan Period = %g seconds (%lu over-runs)", + ppsl->period, ppsl->overruns); printList(&ppsl->scan_list, message); } return 0; @@ -561,19 +563,47 @@ static void initOnce(void) static void periodicTask(void *arg) { periodic_scan_list *ppsl = (periodic_scan_list *)arg; - - epicsTimeStamp start_time, end_time; - double delay; + epicsTimeStamp next, reported; + unsigned int overruns = 0; + double report_delay = 10.0; taskwdInsert(0, NULL, NULL); epicsEventSignal(startStopEvent); + epicsTimeGetCurrent(&next); + reported = next; + while (ppsl->scanCtl != ctlExit) { - epicsTimeGetCurrent(&start_time); - if (ppsl->scanCtl == ctlRun) scanList(&ppsl->scan_list); - epicsTimeGetCurrent(&end_time); - delay = ppsl->period - epicsTimeDiffInSeconds(&end_time, &start_time); - if (delay <= 0.0) delay = 0.1; + double delay; + epicsTimeStamp now; + + if (ppsl->scanCtl == ctlRun) + scanList(&ppsl->scan_list); + + epicsTimeAddSeconds(&next, ppsl->period); + epicsTimeGetCurrent(&now); + delay = epicsTimeDiffInSeconds(&next, &now); + if (delay <= 0.0) { + delay = 0.1; + ppsl->overruns++; + next = now; + if (++overruns >= 10 && + epicsTimeDiffInSeconds(&now, &reported) > report_delay) { + errlogPrintf("dbScan warning: %g second scan over-ran %u times\n", + ppsl->period, overruns); + + reported = now; + if (report_delay < 1800.0) + report_delay *= 2; + else + report_delay = 3600.0; /* At most hourly */ + } + } + else { + overruns = 0; + report_delay = 10.0; + } + epicsEventWaitWithTimeout(ppsl->loopEvent, delay); } diff --git a/src/ioc/rsrv/camessage.c b/src/ioc/rsrv/camessage.c index b71583e54..d80490c72 100644 --- a/src/ioc/rsrv/camessage.c +++ b/src/ioc/rsrv/camessage.c @@ -2054,6 +2054,15 @@ static int clear_channel_reply ( caHdrLargeArray *mp, cas_commit_msg ( client, 0u ); SEND_UNLOCK(client); + /* + * remove from access control list + */ + status = asRemoveClient(&pciu->asClientPVT); + if(status != 0 && status != S_asLib_asNotActive){ + errMessage(status, RECORD_NAME(pciu->dbch)); + return RSRV_ERROR; + } + epicsMutexMustLock ( client->chanListLock ); if ( pciu->state == rsrvCS_inService || pciu->state == rsrvCS_pendConnectResp ) { @@ -2073,15 +2082,6 @@ static int clear_channel_reply ( caHdrLargeArray *mp, } epicsMutexUnlock( client->chanListLock ); - /* - * remove from access control list - */ - status = asRemoveClient(&pciu->asClientPVT); - if(status != 0 && status != S_asLib_asNotActive){ - errMessage(status, RECORD_NAME(pciu->dbch)); - return RSRV_ERROR; - } - LOCK_CLIENTQ; status = bucketRemoveItemUnsignedId (pCaBucket, &pciu->sid); if(status != S_bucket_success){ diff --git a/src/libCom/osi/os/Darwin/osdTime.cpp b/src/libCom/osi/os/Darwin/osdTime.cpp new file mode 100644 index 000000000..f3e6db5dd --- /dev/null +++ b/src/libCom/osi/os/Darwin/osdTime.cpp @@ -0,0 +1,86 @@ +/*************************************************************************\ +* Copyright (c) 2013 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "osiSock.h" + +#define epicsExportSharedSymbols +#include "cantProceed.h" +#include "epicsTime.h" +#include "generalTimeSup.h" + +static clock_serv_t host_clock; + +extern "C" { +static int osdTimeGetCurrent (epicsTimeStamp *pDest) +{ + mach_timespec_t mts; + struct timespec ts; + + clock_get_time(host_clock, &mts); + ts.tv_sec = mts.tv_sec; + ts.tv_nsec = mts.tv_nsec; + *pDest = epicsTime(ts); + return epicsTimeOK; +} +} // extern "C" + + +static int timeRegister(void) +{ + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &host_clock); + + generalTimeCurrentTpRegister("MachTime", \ + LAST_RESORT_PRIORITY, osdTimeGetCurrent); + return 1; +} +static int done = timeRegister(); + + +int epicsTime_gmtime(const time_t *pAnsiTime, struct tm *pTM) +{ + return gmtime_r(pAnsiTime, pTM) ? + epicsTimeOK : epicsTimeERROR; +} + +int epicsTime_localtime(const time_t *clock, struct tm *result) +{ + return localtime_r(clock, result) ? + epicsTimeOK : epicsTimeERROR; +} + +extern "C" epicsShareFunc void +convertDoubleToWakeTime(double timeout, struct timespec *wakeTime) +{ + mach_timespec_t now; + struct timespec wait; + + clock_get_time(host_clock, &now); + + if (timeout<0.0) + timeout = 0.0; + else if(timeout>3600.0) + timeout = 3600.0; + + wait.tv_sec = static_cast< long >(timeout); + wait.tv_nsec = static_cast< long >((timeout - (double)wait.tv_sec) * 1e9); + + wakeTime->tv_sec = now.tv_sec + wait.tv_sec; + wakeTime->tv_nsec = now.tv_nsec + wait.tv_nsec; + if (wakeTime->tv_nsec >= 1000000000L) { + wakeTime->tv_nsec -= 1000000000L; + ++wakeTime->tv_sec; + } +} diff --git a/src/libCom/osi/os/posix/osdTime.cpp b/src/libCom/osi/os/posix/osdTime.cpp index 2f7dda287..679c6e376 100644 --- a/src/libCom/osi/os/posix/osdTime.cpp +++ b/src/libCom/osi/os/posix/osdTime.cpp @@ -24,7 +24,7 @@ #define TIME_INIT ClockTime_Init(CLOCKTIME_NOSYNC) #else - /* Some posix systems like Darwin don't have CLOCK_REALTIME */ + /* Some posix systems may not have CLOCK_REALTIME */ #define TIME_INIT generalTimeCurrentTpRegister("GetTimeOfDay", \ LAST_RESORT_PRIORITY, osdTimeGetCurrent) diff --git a/src/libCom/ring/epicsRingPointer.cpp b/src/libCom/ring/epicsRingPointer.cpp index 5118c9347..3a5cc8c72 100644 --- a/src/libCom/ring/epicsRingPointer.cpp +++ b/src/libCom/ring/epicsRingPointer.cpp @@ -3,9 +3,8 @@ * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. \*************************************************************************/ /*epicsRingPointer.cpp*/ /* Author: Marty Kraimer Date: 13OCT2000 */ @@ -63,7 +62,7 @@ epicsShareFunc int epicsShareAPI epicsRingPointerGetUsed(epicsRingPointerId id) return(pvoidPointer->getUsed()); } -epicsShareFunc int epicsShareAPI epicsRingPointerSize(epicsRingPointerId id) +epicsShareFunc int epicsShareAPI epicsRingPointerGetSize(epicsRingPointerId id) { voidPointer *pvoidPointer = reinterpret_cast(id); return(pvoidPointer->getSize()); diff --git a/src/libCom/ring/epicsRingPointer.h b/src/libCom/ring/epicsRingPointer.h index 57534586a..3332782a4 100644 --- a/src/libCom/ring/epicsRingPointer.h +++ b/src/libCom/ring/epicsRingPointer.h @@ -3,9 +3,8 @@ * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. \*************************************************************************/ /*epicsRingPointer.h */ @@ -67,6 +66,9 @@ epicsShareFunc int epicsShareAPI epicsRingPointerGetSize(epicsRingPointerId id) epicsShareFunc int epicsShareAPI epicsRingPointerIsEmpty(epicsRingPointerId id); epicsShareFunc int epicsShareAPI epicsRingPointerIsFull(epicsRingPointerId id); +/* This routine was incorrectly named in previous releases */ +#define epicsRingPointerSize epicsRingPointerGetSize + #ifdef __cplusplus } #endif diff --git a/src/template/base/makeBaseApp.pl b/src/template/base/makeBaseApp.pl index 7a816a0eb..cf65d290f 100755 --- a/src/template/base/makeBaseApp.pl +++ b/src/template/base/makeBaseApp.pl @@ -1,5 +1,4 @@ -eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*- - if $running_under_some_shell; # makeBaseApp +#!/usr/bin/env perl # Authors: Ralph Lange, Marty Kraimer, Andrew Johnson and Janet Anderson # $Revision-Id$ diff --git a/src/template/ext/makeBaseExt.pl b/src/template/ext/makeBaseExt.pl index 42855aa2f..307764823 100755 --- a/src/template/ext/makeBaseExt.pl +++ b/src/template/ext/makeBaseExt.pl @@ -1,5 +1,4 @@ -eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*- - if $running_under_some_shell; # makeBaseExt +#!/usr/bin/env perl # Authors: Ralph Lange, Marty Kraimer, Andrew Johnson and Janet Anderson # $Revision-Id$ diff --git a/src/tools/convertRelease.pl b/src/tools/convertRelease.pl index f6eb50e73..586e5ee35 100644 --- a/src/tools/convertRelease.pl +++ b/src/tools/convertRelease.pl @@ -1,5 +1,4 @@ -eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*- - if $running_under_some_shell; # convertRelease.pl +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne # National Laboratory. diff --git a/src/tools/cvsclean.pl b/src/tools/cvsclean.pl index 09ecdf77c..b1398fda5 100644 --- a/src/tools/cvsclean.pl +++ b/src/tools/cvsclean.pl @@ -1,5 +1,4 @@ -eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*- - if $running_under_some_shell; # cvsclean.pl +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2002 The University of Chicago, as Operator of Argonne # National Laboratory. diff --git a/src/tools/dos2unix.pl b/src/tools/dos2unix.pl index c10282a3e..4940fd5f2 100644 --- a/src/tools/dos2unix.pl +++ b/src/tools/dos2unix.pl @@ -1,5 +1,4 @@ -eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*- - if $running_under_some_shell; # makeConfigAppInclude.pl +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2002 The University of Chicago, as Operator of Argonne # National Laboratory. diff --git a/src/tools/expandVars.pl b/src/tools/expandVars.pl index 2100315da..5015fe07a 100644 --- a/src/tools/expandVars.pl +++ b/src/tools/expandVars.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Tool to expand @VAR@ variables while copying a file. # The file will *not* be copied if it already exists. diff --git a/src/tools/fullPathName.pl b/src/tools/fullPathName.pl index 27fc57a21..a553dbd3c 100644 --- a/src/tools/fullPathName.pl +++ b/src/tools/fullPathName.pl @@ -1,5 +1,4 @@ -eval 'exec perl -S -w $0 ${1+"$@"}' # -*- Mode: perl -*- - if 0; +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne # National Laboratory. diff --git a/src/tools/installEpics.pl b/src/tools/installEpics.pl index 4733f0256..f5a77de49 100644 --- a/src/tools/installEpics.pl +++ b/src/tools/installEpics.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne # National Laboratory. diff --git a/src/tools/makeIncludeDbd.pl b/src/tools/makeIncludeDbd.pl index b42f6f3d8..c0b8238db 100644 --- a/src/tools/makeIncludeDbd.pl +++ b/src/tools/makeIncludeDbd.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2002 The University of Chicago, as Operator of Argonne # National Laboratory. diff --git a/src/tools/makeMakefile.pl b/src/tools/makeMakefile.pl index 80383ab3f..ea48d1c9b 100644 --- a/src/tools/makeMakefile.pl +++ b/src/tools/makeMakefile.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2002 The University of Chicago, as Operator of Argonne # National Laboratory. diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 7b4f010bb..80f6f4d38 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne # National Laboratory. diff --git a/src/tools/mkmf.pl b/src/tools/mkmf.pl index b134abe18..b066edeb4 100644 --- a/src/tools/mkmf.pl +++ b/src/tools/mkmf.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2009 Helmholtz-Zentrum Berlin fuer Materialien und Energie. # Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne diff --git a/src/tools/munch.pl b/src/tools/munch.pl index a51c079c5..2ed6567fb 100644 --- a/src/tools/munch.pl +++ b/src/tools/munch.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2010 UChicago Argonne LLC, as Operator of Argonne # National Laboratory. diff --git a/src/tools/registerRecordDeviceDriver.pl b/src/tools/registerRecordDeviceDriver.pl index f221b4cb0..91a22c903 100755 --- a/src/tools/registerRecordDeviceDriver.pl +++ b/src/tools/registerRecordDeviceDriver.pl @@ -1,5 +1,4 @@ -eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*- - if $running_under_some_shell; # registerRecordDeviceDriver +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne # National Laboratory. diff --git a/src/tools/replaceVAR.pl b/src/tools/replaceVAR.pl index 4c50f1a19..82c76bb3d 100644 --- a/src/tools/replaceVAR.pl +++ b/src/tools/replaceVAR.pl @@ -1,5 +1,4 @@ -eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*- - if $running_under_some_shell; # replaceVAR.pl +#!/usr/bin/env perl #************************************************************************* # Copyright (c) 2002 The University of Chicago, as Operator of Argonne # National Laboratory. diff --git a/src/tools/useManifestTool.pl b/src/tools/useManifestTool.pl index 45986b662..9e59e9f1f 100644 --- a/src/tools/useManifestTool.pl +++ b/src/tools/useManifestTool.pl @@ -1,6 +1,4 @@ -eval 'exec perl -S -w $0 ${1+"$@"}' # -*- Mode: perl -*- - if 0; - +#!/usr/bin/env perl # # Use MS Visual C++ compiler version number to determine if # we want to use the Manifest Tool (status=1) or not (status=0)