merge with 3.14.12-pre1

This commit is contained in:
zimoch
2013-11-27 13:59:50 +00:00
parent 4782e22cb7
commit 1d6de601e5
30 changed files with 334 additions and 214 deletions

View File

@@ -300,11 +300,6 @@ epicsShareFunc long locationProbe (epicsAddressType addrType, char *pLocation);
#endif /* NO_DEVLIB_OLD_INTERFACE */
/*
* Some vxWorks convenience routines
*/
void bcopyLongs(char *source, char *destination, int nlongs);
#ifdef __cplusplus
}
#endif

View File

@@ -94,6 +94,7 @@ epicsShareExtern devLibVME *pdevLibVME;
#ifndef NO_DEVLIB_COMPAT
# define pdevLibVirtualOS pdevLibVME
typedef devLibVME devLibVirtualOS;
#endif

View File

@@ -3,11 +3,13 @@
* 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.
\*************************************************************************/
#ifndef INC_epicsSignal_H
#define INC_epicsSignal_H
#ifdef __cplusplus
extern "C" {
#endif
@@ -44,3 +46,4 @@ epicsShareFunc void epicsShareAPI epicsSignalRaiseSigAlarm ( struct epicsThreadO
}
#endif
#endif /* INC_epicsSignal_H */

View File

@@ -6,7 +6,7 @@
\*************************************************************************/
/*
* RTEMS osdThread.c
* Revision-Id: anj@aps.anl.gov-20101005192737-disfz3vs0f3fiixd
* Revision-Id: anj@aps.anl.gov-20120618195203-fn89v5ir0faou35v
* Author: W. Eric Norum
* eric@cls.usask.ca
* (306) 966-6055
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <assert.h>
#include <syslog.h>
#include <limits.h>
#include <rtems.h>
#include <rtems/error.h>
@@ -364,16 +365,15 @@ epicsThreadSleep (double seconds)
{
rtems_status_code sc;
rtems_interval delay;
extern double rtemsTicksPerTwoSeconds_double;
if (seconds <= 0.0) {
delay = 0;
extern double rtemsTicksPerSecond_double;
if (seconds > 0.0) {
seconds *= rtemsTicksPerSecond_double;
seconds += 0.99999999; /* 8 9s here is optimal */
delay = (seconds >= INT_MAX) ? INT_MAX : (int) seconds;
}
else {
delay = seconds * rtemsTicksPerTwoSeconds_double;
delay = (delay + 1) / 2;
if (delay == 0)
delay++;
else { /* seconds <= 0 or NAN */
delay = 0;
}
sc = rtems_task_wake_after (delay);
if(sc != RTEMS_SUCCESSFUL)

View File

@@ -7,7 +7,7 @@
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* Revision-Id: anj@aps.anl.gov-20101005192737-disfz3vs0f3fiixd */
/* Revision-Id: anj@aps.anl.gov-20130328221741-gjmdorru0oolmpt3 */
/*
* OS-dependent VME support
@@ -19,3 +19,5 @@
#endif
#endif
#endif
void bcopyLongs(char *source, char *destination, int nlongs);

View File

@@ -9,7 +9,7 @@
\*************************************************************************/
/* osdMutex.c */
/*
* Revision-Id: anj@aps.anl.gov-20101005192737-disfz3vs0f3fiixd
* Revision-Id: anj@aps.anl.gov-20131120004245-drexj41vy3vynah9
* WIN32 version
*
* Author Jeffrey O. Hill
@@ -38,7 +38,9 @@
* It appears that the only entry point used here that causes
* portability problems with W95\W98\WME is TryEnterCriticalSection.
*/
#define _WIN32_WINNT 0x0400
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400
#endif
#include <windows.h>
#define epicsExportSharedSymbols

View File

@@ -11,6 +11,11 @@
#include <stdio.h>
#include <stdarg.h>
#ifndef _MSC_VER
/* Older versions of MinGW omitted this prototype from stdio.h */
_CRTIMP int __cdecl __MINGW_NOTHROW _vscprintf (const char*, va_list);
#endif
#define epicsExportSharedSymbols
#include "epicsStdio.h"
@@ -18,26 +23,12 @@ int epicsShareAPI epicsVsnprintf(char *str, size_t len,
const char *fmt, va_list ap)
{
int retval = _vsnprintf(str, len, fmt, ap);
#ifdef _MSC_VER
int needed = _vscprintf(fmt, ap);
if ((int) len < needed + 1) {
str[len - 1] = 0;
return needed;
}
#else
/* Unfortunately MINGW doesn't provide _vscprintf and their
* _vsnprintf follows MS' broken return value semantics.
*/
if (retval == -1) {
if (len)
str[len - 1] = 0;
return len;
} else if (retval == (int) len) {
str[--retval] = 0;
}
#endif
return retval;
}

View File

@@ -3,13 +3,12 @@
* 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.
\*************************************************************************/
/*
* Revision-Id: anj@aps.anl.gov-20111108215715-d8j6l4lycpi3gvvb
* Revision-Id: anj@aps.anl.gov-20131120004245-drexj41vy3vynah9
*
* Author: Jeff Hill
*
@@ -23,8 +22,8 @@
#define VC_EXTRALEAN
#define STRICT
#if _WIN64
# define _WIN32_WINNT 0x400 /* defining this drops support for W95 */
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x400 /* No support for W95 */
#endif
#include <windows.h>
#include <process.h> /* for _endthread() etc */
@@ -246,10 +245,7 @@ static void epicsParmCleanupWIN32 ( win32ThreadParam * pParm )
ellDelete ( & pGbl->threadList, & pParm->node );
LeaveCriticalSection ( & pGbl->mutex );
/* close the handle if its an implicit thread id */
if ( ! pParm->funptr ) {
CloseHandle ( pParm->handle );
}
CloseHandle ( pParm->handle );
free ( pParm );
TlsSetValue ( pGbl->tlsIndexThreadLibraryEPICS, 0 );
}
@@ -446,7 +442,10 @@ epicsShareFunc epicsThreadBooleanStatus epicsShareAPI epicsThreadHighestPriority
epicsShareFunc unsigned int epicsShareAPI
epicsThreadGetStackSize ( epicsThreadStackSizeClass stackSizeClass )
{
static const unsigned stackSizeTable[epicsThreadStackBig+1] = {4000, 6000, 11000};
#define STACK_SIZE(f) (f * 0x10000 * sizeof(void *))
static const unsigned stackSizeTable[epicsThreadStackBig+1] = {
STACK_SIZE(1), STACK_SIZE(2), STACK_SIZE(4)
};
if (stackSizeClass<epicsThreadStackSmall) {
fprintf ( stderr,
@@ -776,18 +775,15 @@ epicsShareFunc void epicsShareAPI epicsThreadSleep ( double seconds )
static const unsigned mSecPerSec = 1000;
DWORD milliSecDelay;
if ( seconds <= 0.0 ) {
if ( seconds > 0.0 ) {
seconds *= mSecPerSec;
seconds += 0.99999999; /* 8 9s here is optimal */
milliSecDelay = ( seconds >= INFINITE ) ?
INFINITE - 1 : ( DWORD ) seconds;
}
else { /* seconds <= 0 or NAN */
milliSecDelay = 0u;
}
else if ( seconds >= INFINITE / mSecPerSec ) {
milliSecDelay = INFINITE - 1;
}
else {
milliSecDelay = ( DWORD ) ( ( seconds * mSecPerSec ) + 0.5 );
if ( milliSecDelay == 0 ) {
milliSecDelay = 1;
}
}
Sleep ( milliSecDelay );
}

View File

@@ -8,7 +8,7 @@
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* Revision-Id: anj@aps.anl.gov-20101104192413-fxlfgfq0kuhsi23a */
/* Revision-Id: anj@aps.anl.gov-20131120004103-rrs4qf6hlp20naol */
/*
* Author: Jeff Hill
*/
@@ -21,8 +21,8 @@
enum epicsSocketSystemCallInterruptMechanismQueryInfo
epicsSocketSystemCallInterruptMechanismQuery ()
{
#if (CYGWIN_VERSION_DLL_MAJOR >= 1007)
// Behaviour changed in Cygwin 1.7 release.
#if 0
// Some broken versions of cygwin needed this:
return esscimqi_socketCloseRequired;
#else
return esscimqi_socketBothShutdownRequired;

View File

@@ -6,12 +6,13 @@
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* Revision-Id: anj@aps.anl.gov-20101005192737-disfz3vs0f3fiixd */
/* Revision-Id: anj@aps.anl.gov-20131120004245-drexj41vy3vynah9 */
#include <stdlib.h>
#define epicsExportSharedSymbols
#include "devLibVME.h"
/* This file must contain no definitions other than the following: */
devLibVME *pdevLibVME;
epicsShareDef devLibVME *pdevLibVME;

View File

@@ -5,7 +5,7 @@
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* Revision-Id: anj@aps.anl.gov-20101005192737-disfz3vs0f3fiixd */
/* Revision-Id: anj@aps.anl.gov-20120831210514-z6b2h7o317s14cqi */
/* Author: Eric Norum Date: 12DEC2001 */
#include <stdio.h>
@@ -190,8 +190,7 @@ epicsReadlineEnd (void *context)
#define LEDLIB_LINESIZE 1000
#ifndef _WRS_VXWORKS_MAJOR
/* vxWorks 5 uses int but vxWorks 6 uses LED_ID */
#define LED_ID int
typedef int LED_ID;
#endif
struct readlineContext {
@@ -210,7 +209,7 @@ epicsReadlineBegin(FILE *in)
readlineContext = malloc(sizeof *readlineContext);
if (readlineContext != NULL) {
readlineContext->ledId = (LED_ID)ERROR;
readlineContext->ledId = (LED_ID) ERROR;
readlineContext->in = in;
if (in == NULL) {
long i = 50;
@@ -218,7 +217,7 @@ epicsReadlineBegin(FILE *in)
envGetLongConfigParam(&IOCSH_HISTSIZE, &i);
if (i < 1) i = 1;
readlineContext->ledId = ledOpen(fileno(stdin), fileno(stdout), i);
if (readlineContext->ledId == (LED_ID)ERROR) {
if (readlineContext->ledId == (LED_ID) ERROR) {
readlineContext->in = stdin;
printf("Warning -- Unabled to allocate space for command-line history.\n");
printf("Warning -- Command-line editting disabled.\n");
@@ -241,7 +240,7 @@ epicsReadline (const char *prompt, void *context)
fputs(prompt, stdout);
fflush(stdout);
}
if (readlineContext->ledId != (LED_ID)ERROR) {
if (readlineContext->ledId != (LED_ID) ERROR) {
i = ledRead(readlineContext->ledId, readlineContext->line, LEDLIB_LINESIZE-1);
if (i < 0)
return NULL;
@@ -267,7 +266,7 @@ epicsReadlineEnd (void *context)
struct readlineContext *readlineContext = context;
if (readlineContext) {
if (readlineContext->ledId != (LED_ID)ERROR)
if (readlineContext->ledId != (LED_ID) ERROR)
ledClose(readlineContext->ledId);
free(readlineContext);
}

View File

@@ -398,9 +398,6 @@ static void epicsThreadInit(void)
}
#define ARCH_STACK_FACTOR 1024
epicsShareFunc unsigned int epicsShareAPI epicsThreadGetStackSize (epicsThreadStackSizeClass stackSizeClass)
{
#if ! defined (_POSIX_THREAD_ATTR_STACKSIZE)
@@ -408,8 +405,10 @@ epicsShareFunc unsigned int epicsShareAPI epicsThreadGetStackSize (epicsThreadSt
#elif defined (OSITHREAD_USE_DEFAULT_STACK)
return 0;
#else
static const unsigned stackSizeTable[epicsThreadStackBig+1] =
{128*ARCH_STACK_FACTOR, 256*ARCH_STACK_FACTOR, 512*ARCH_STACK_FACTOR};
#define STACK_SIZE(f) (f * 0x10000 * sizeof(void *))
static const unsigned stackSizeTable[epicsThreadStackBig+1] = {
STACK_SIZE(1), STACK_SIZE(2), STACK_SIZE(4)
};
if (stackSizeClass<epicsThreadStackSmall) {
errlogPrintf("epicsThreadGetStackSize illegal argument (too small)");
return stackSizeTable[epicsThreadStackBig];
@@ -674,9 +673,15 @@ epicsShareFunc void epicsShareAPI epicsThreadSleep(double seconds)
struct timespec remainingTime;
double nanoseconds;
delayTime.tv_sec = (time_t)seconds;
nanoseconds = (seconds - (double)delayTime.tv_sec) *1e9;
delayTime.tv_nsec = (long)nanoseconds;
if (seconds > 0) {
delayTime.tv_sec = seconds;
nanoseconds = (seconds - delayTime.tv_sec) *1e9;
delayTime.tv_nsec = nanoseconds;
}
else {
delayTime.tv_sec = 0;
delayTime.tv_nsec = 0;
}
while (nanosleep(&delayTime, &remainingTime) == -1 &&
errno == EINTR)
delayTime = remainingTime;

View File

@@ -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)

View File

@@ -1,10 +1,9 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* 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 Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* atReboot.cpp */
@@ -16,34 +15,28 @@
#include "epicsDynLink.h"
#include "epicsExit.h"
/* osdThread references atRebootExtern just to make this module load*/
int atRebootExtern;
extern "C" {
typedef int (*sysAtReboot_t)(void(func)(void));
class atRebootRegister {
public:
atRebootRegister();
};
atRebootRegister::atRebootRegister()
void atRebootRegister(void)
{
STATUS status;
sysAtReboot_t sysAtReboot;
SYM_TYPE type;
status = symFindByNameEPICS(sysSymTbl, "_sysAtReboot",
(char **)&sysAtReboot, &type);
(char **)&sysAtReboot, &type);
if (status == OK) {
status = sysAtReboot(epicsExitCallAtExits);
if (status != OK) {
printf("atReboot: sysAtReboot returned error %d\n", status);
}
} else {
printf("BSP routine sysAtReboot() not found, epicsExit() will not be\n"
"called by reboot. For reduced functionality, call\n"
" rebootHookAdd(epicsExitCallAtExits)\n");
printf("BSP routine sysAtReboot() not found, epicsExit() will not be\n"
"called by reboot. For reduced functionality, call\n"
" rebootHookAdd(epicsExitCallAtExits)\n");
}
}
static atRebootRegister atRebootRegisterObj;
}

View File

@@ -30,9 +30,7 @@ static size_t osdMaxBlockSize = 0;
static void osdSufficentSpaceInPoolQuery ()
{
int temp = memFindMax ();
osdMaxBlockSize = ( temp > 0 ) ? (size_t) temp : 0;
osdMaxBlockSize = (size_t) memFindMax ();
}
static void osdSufficentSpaceInPoolPoll ( void *pArgIn )

View File

@@ -27,7 +27,7 @@
int osiSockAttach()
{
return 1;
return 1;
}
void osiSockRelease()
@@ -112,27 +112,25 @@ epicsShareFunc unsigned epicsShareAPI ipAddrToHostName
/*
* hostToIPAddr ()
*/
epicsShareFunc int epicsShareAPI hostToIPAddr
(const char *pHostName, struct in_addr *pIPA)
epicsShareFunc int epicsShareAPI
hostToIPAddr(const char *pHostName, struct in_addr *pIPA)
{
int addr;
int addr;
addr = hostGetByName ((char *)pHostName);
if (addr==ERROR) {
addr = inet_addr ((char *)pHostName);
if (addr==ERROR) {
/*
* return indicating an error
*/
return -1;
}
addr = hostGetByName((char *)pHostName);
if (addr != ERROR) {
pIPA->s_addr = (unsigned long) addr;
}
else if (inet_aton((char *)pHostName, pIPA) == ERROR) {
/*
* return indicating an error
*/
return -1;
}
pIPA->s_addr = (unsigned long) addr;
/*
* success
*/
return 0;
/*
* success
*/
return 0;
}

View File

@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <limits.h>
#include <vxWorks.h>
#include <taskLib.h>
@@ -42,12 +43,8 @@
static const unsigned stackSizeTable[epicsThreadStackBig+1] =
{4000*ARCH_STACK_FACTOR, 6000*ARCH_STACK_FACTOR, 11000*ARCH_STACK_FACTOR};
/*The following forces atReboot to be loaded*/
extern int atRebootExtern;
static struct pext {
int *pExtern;
struct pext *pext;
} pext = {&atRebootExtern, &pext};
/* This routine is found in atReboot.cpp */
extern void atRebootRegister(void);
/* definitions for implementation of epicsThreadPrivate */
static void **papTSD = 0;
@@ -92,6 +89,7 @@ static void epicsThreadInit(void)
epicsThreadOnceMutex = semMCreate(
SEM_DELETE_SAFE|SEM_INVERSION_SAFE|SEM_Q_PRIORITY);
assert(epicsThreadOnceMutex);
atRebootRegister();
}
lock = 0;
}
@@ -279,11 +277,13 @@ void epicsThreadSleep(double seconds)
STATUS status;
int ticks;
if(seconds<=0.0) {
if (seconds > 0.0) {
seconds *= sysClkRateGet();
seconds += 0.99999999; /* 8 9s here is optimal */
ticks = (seconds >= INT_MAX) ? INT_MAX : (int) seconds;
}
else { /* seconds <= 0 or NAN */
ticks = 0;
} else {
ticks = seconds*sysClkRateGet() + 0.5;
if(ticks<=0) ticks = 1;
}
status = taskDelay(ticks);
if(status) errlogPrintf("epicsThreadSleep\n");

View File

@@ -67,14 +67,18 @@ void osdNTPReport(void)
}
// vxWorks localtime_r interface does not match POSIX standards
// vxWorks localtime_r returns different things in different versions.
// It can't fail though, so we just ignore the return value.
int epicsTime_localtime(const time_t *clock, struct tm *result)
{
return localtime_r(clock, result) == OK ? epicsTimeOK : epicsTimeERROR;
localtime_r(clock, result);
return epicsTimeOK;
}
// vxWorks gmtime_r interface does not match POSIX standards
// vxWorks gmtime_r returns different things in different versions.
// It can't fail though, so we just ignore the return value.
int epicsTime_gmtime ( const time_t *pAnsiTime, struct tm *pTM )
{
return gmtime_r(pAnsiTime, pTM) == OK ? epicsTimeOK : epicsTimeERROR;
gmtime_r(pAnsiTime, pTM);
return epicsTimeOK;
}

View File

@@ -3,13 +3,15 @@
* 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.
\*************************************************************************/
#ifndef INC_osiPoolStatus_H
#define INC_osiPoolStatus_H
/*
* Revision-Id: anj@aps.anl.gov-20101005192737-disfz3vs0f3fiixd
* Revision-Id: anj@aps.anl.gov-20130411175656-dor1h3zt7zo46epw
*
* Author: Jeff Hill
*
@@ -39,3 +41,4 @@ epicsShareFunc int epicsShareAPI osiSufficentSpaceInPool ( size_t contiguousBloc
#include "osdPoolStatus.h"
#endif /* INC_osiPoolStatus_H */

View File

@@ -3,13 +3,15 @@
* 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.
\*************************************************************************/
#ifndef INC_osiProcess_H
#define INC_osiProcess_H
/*
* Revision-Id: anj@aps.anl.gov-20101005192737-disfz3vs0f3fiixd
* Revision-Id: anj@aps.anl.gov-20130411175656-dor1h3zt7zo46epw
*
* Operating System Independent Interface to Process Environment
*
@@ -44,3 +46,4 @@ epicsShareFunc osiSpawnDetachedProcessReturn epicsShareAPI osiSpawnDetachedProce
}
#endif
#endif /* INC_osiProcess_H */

View File

@@ -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<voidPointer*>(id);
return(pvoidPointer->getSize());

View File

@@ -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

View File

@@ -69,8 +69,8 @@ static epicsMutexId fLock;
static ELLLIST fList = ELLLIST_INIT;
/* Watchdog task control */
static enum {
twdctlRun, twdctlDisable, twdctlExit
static volatile enum {
twdctlInit, twdctlRun, twdctlDisable, twdctlExit
} twdCtl;
static epicsEventId loopEvent;
static epicsEventId exitEvent;

View File

@@ -47,6 +47,12 @@ epicsStdioTest_SRCS += epicsStdioTest.c
testHarness_SRCS += epicsStdioTest.c
TESTS += epicsStdioTest
TESTPROD_HOST += epicsSockResolveTest
epicsSockResolveTest_SRCS += epicsSockResolveTest.c
testHarness_SRCS += epicsSockResolveTest.c
epicsSockResolveTest_SYS_LIBS_WIN32 = ws2_32
TESTS += epicsSockResolveTest
TESTPROD_HOST += epicsStringTest
epicsStringTest_SRCS += epicsStringTest.c
testHarness_SRCS += epicsStringTest.c

View File

@@ -60,9 +60,9 @@ void Test :: execute ()
for ( unsigned i = 0; i < 3; i++ ) {
double mVal = rand ();
mVal /= (RAND_MAX + 1);
mVal /= (RAND_MAX + 1.0);
double fEVal = rand ();
fEVal /= (RAND_MAX + 1);
fEVal /= (RAND_MAX + 1.0);
fEVal *= DBL_MAX_EXP - DBL_MIN_EXP;
fEVal += DBL_MIN_EXP;
int eVal = static_cast < int > ( fEVal + 0.5 );
@@ -72,7 +72,7 @@ void Test :: execute ()
_measure ();
}
_srcVal = rand ();
_srcVal /= (RAND_MAX + 1);
_srcVal /= (RAND_MAX + 1.0);
_srcVal *= 10.0;
_srcVal -= 5.0;
for ( _prec = lowPrecision;

View File

@@ -4,7 +4,7 @@
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
// Revision-Id: anj@aps.anl.gov-20110407222502-um4y5q4rzq5vlk3e
// Revision-Id: anj@aps.anl.gov-20121203185826-cd68u8o9fu5vbr7u
// Author: Andrew Johnson
#include "epicsUnitTest.h"
@@ -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(577);
/* LITERAL_OPERAND elements */
testExpr(0);
@@ -253,6 +253,11 @@ MAIN(epicsCalcTest)
testExpr(9);
testExpr(.1);
testExpr(0.1);
testExpr(0X0);
testExpr(0x10);
testExpr(0x7fffffff);
testCalc("0x80000000", -2147483648.0);
testCalc("0xffffffff", -1);
testExpr(Inf);
testCalc("Infinity", Inf);
testExpr(NaN);
@@ -287,6 +292,7 @@ MAIN(epicsCalcTest)
testExpr(-1);
testExpr(-Inf);
testExpr(- -1);
testCalc("-0x80000000", 2147483648.0);
/* UNARY_OPERATOR elements */
testExpr((1));
@@ -325,11 +331,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);
@@ -851,6 +861,7 @@ MAIN(epicsCalcTest)
testArgs("13.1;B:=A;A:=B;C:=D;D:=C", A_A|A_D, A_A|A_B|A_C|A_D);
// Malformed expressions
testBadExpr("0x0.1", CALC_ERR_SYNTAX);
testBadExpr("1*", CALC_ERR_INCOMPLETE);
testBadExpr("*1", CALC_ERR_SYNTAX);
testBadExpr("MIN", CALC_ERR_INCOMPLETE);

View File

@@ -38,6 +38,7 @@ int macEnvExpandTest(void);
int ringPointerTest(void);
int ringBytesTest(void);
int blockingSockTest(void);
int epicsSockResolveTest(void);
int taskwdTest(void);
int epicsExitTest(void);
@@ -94,6 +95,8 @@ void epicsRunLibComTests(void)
runTest(ringBytesTest);
runTest(blockingSockTest);
runTest(epicsSockResolveTest);
runTest(taskwdTest);

View File

@@ -0,0 +1,92 @@
/*************************************************************************\
* Copyright (c) 2012 Brookhaven Science Associates as Operator of
* Brookhaven National Lab.
* Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
\*************************************************************************/
#include "dbDefs.h"
#include "osiSock.h"
#include "epicsUnitTest.h"
#include "testMain.h"
#define DEFAULT_PORT 4000
typedef struct {
const char *input;
unsigned long IP;
unsigned short port;
} testData;
static testData okdata[] = {
{"127.0.0.1", 0x7f000001, DEFAULT_PORT},
{"127.0.0.1:42", 0x7f000001, 42},
{"localhost", 0x7f000001, DEFAULT_PORT},
{"localhost:42", 0x7f000001, 42},
{"2424", 2424, DEFAULT_PORT},
{"2424:42", 2424, 42},
{"255.255.255.255", 0xffffffff, DEFAULT_PORT},
{"255.255.255.255:65535", 0xffffffff, 65535},
};
static const char * baddata[] = {
"127.0.0.hi",
"127.0.0.hi:42",
"16invalidhostname",
"16invalidhostname:42",
"256.255.255.255",
"255.256.255.255",
"255.255.256.255",
"255.255.255.256",
"255.255.255.255:65536",
};
MAIN(epicsSockResolveTest)
{
int i;
testPlan(3*NELEMENTS(okdata) + NELEMENTS(baddata));
{
struct in_addr addr;
if (hostToIPAddr("obviously.invalid.host", &addr) == 0) {
testAbort("hostToIPAddr() is broken, testing not possible");
}
}
testDiag("Tests of aToIPAddr");
for (i=0; i<NELEMENTS(okdata); i++) {
struct sockaddr_in addr;
int ret;
ret = aToIPAddr(okdata[i].input, DEFAULT_PORT, &addr);
testOk(ret==0, "aToIPAddr(\"%s\", %u) -> %d",
okdata[i].input, DEFAULT_PORT, ret);
if (ret) {
testSkip(2, " aToIPAddr() failed");
}
else {
testOk(addr.sin_addr.s_addr == htonl(okdata[i].IP), " IP correct");
testOk(addr.sin_port == htons(okdata[i].port), " Port correct");
}
}
for (i=0; i<NELEMENTS(baddata); i++) {
struct sockaddr_in addr;
int ret;
ret = aToIPAddr(baddata[i], DEFAULT_PORT, &addr);
testOk(ret!=0, "aToIPAddr(\"%s\", %u) -> %d",
baddata[i], DEFAULT_PORT, ret);
if (ret==0) {
testDiag(" IP=0x%lx, port=%d",
(unsigned long) ntohl(addr.sin_addr.s_addr),
ntohs(addr.sin_port));
}
}
return testDone();
}

View File

@@ -85,8 +85,13 @@ void testStdoutRedir (const char *report)
testOk1(stdout == realStdout);
errno = 0;
if (!testOk1(!fclose(stream)))
testDiag("fclose error: %s\n", strerror(errno));
if (!testOk1(!fclose(stream))) {
testDiag("fclose error: %s", strerror(errno));
#ifdef vxWorks
testDiag("The above test fails if you don't cd to a writable directory");
testDiag("before running the test. The next test will also fail...");
#endif
}
if (!testOk1((stream = fopen(report, "r")) != NULL)) {
testDiag("'%s' could not be opened for reading: %s",

View File

@@ -38,42 +38,33 @@ 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);
testPlan(12 + nTimes * 18);
const epicsTime begin = epicsTime::getCurrent();
{
try {
const epicsTimeStamp epochTS = {0, 0};
epicsTime epochET = epochTS;
struct gm_tm_nano_sec epicsEpoch = epochET;
testOk1(epicsEpoch.ansi_tm.tm_sec == 0);
testOk1(epicsEpoch.ansi_tm.tm_min == 0);
testOk1(epicsEpoch.ansi_tm.tm_hour == 0);
testOk1(epicsEpoch.ansi_tm.tm_yday == 0);
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);
testOk(epicsEpoch.ansi_tm.tm_sec == 0 &&
epicsEpoch.ansi_tm.tm_min == 0 &&
epicsEpoch.ansi_tm.tm_hour == 0 &&
epicsEpoch.ansi_tm.tm_yday == 0 &&
epicsEpoch.ansi_tm.tm_year == 90,
"epicsTime_gmtime() for EPICS epoch");
}
catch ( ... ) {
testFail("epicsTime_gmtime() failed");
testAbort("Can't continue, check your OS!");
}
{ // badNanosecTest
@@ -90,7 +81,7 @@ MAIN(epicsTimeTest)
}
}
{
{ // strftime() output
char buf[80];
epicsTime et;
@@ -125,70 +116,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();