diff --git a/src/ca/client/tools/caget.c b/src/ca/client/tools/caget.c index 1ce588615..ac742fc73 100644 --- a/src/ca/client/tools/caget.c +++ b/src/ca/client/tools/caget.c @@ -210,7 +210,7 @@ static int caget (pv *pvs, int nPvs, RequestT request, OutputT format, return 1; } result = ca_array_get(pvs[n].dbrType, - pvs[n].nElems, + pvs[n].reqElems, pvs[n].chid, pvs[n].value); } diff --git a/src/ca/client/udpiiu.h b/src/ca/client/udpiiu.h index 5a0f869e1..2f9918e49 100644 --- a/src/ca/client/udpiiu.h +++ b/src/ca/client/udpiiu.h @@ -300,6 +300,7 @@ private: // These are needed for the vxWorks 5.5 compiler: friend class udpiiu::SearchDestUDP; friend class udpiiu::SearchRespCallback; + friend class udpiiu::M_repeaterTimerNotify; }; #endif // udpiiuh diff --git a/src/libCom/osi/os/Darwin/osdSock.h b/src/libCom/osi/os/Darwin/osdSock.h index 9e246c55b..bff7814e0 100644 --- a/src/libCom/osi/os/Darwin/osdSock.h +++ b/src/libCom/osi/os/Darwin/osdSock.h @@ -1,7 +1,6 @@ /*************************************************************************\ * Copyright (c) 2002 The University of Saskatchewan -* 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. \*************************************************************************/ /* @@ -13,10 +12,6 @@ #ifndef osdSockH #define osdSockH -#ifdef __cplusplus -extern "C" { -#endif - #include #include @@ -24,8 +19,6 @@ extern "C" { #include #include #include -/*#include -#include */ #include #include #include @@ -34,10 +27,6 @@ extern "C" { #include /* close() and others */ -#ifdef __cplusplus -} -#endif - typedef int SOCKET; #define INVALID_SOCKET (-1) #define SOCKERRNO errno diff --git a/src/libCom/osi/os/Linux/osdSock.h b/src/libCom/osi/os/Linux/osdSock.h index 8c1f65b70..e689526eb 100644 --- a/src/libCom/osi/os/Linux/osdSock.h +++ b/src/libCom/osi/os/Linux/osdSock.h @@ -3,8 +3,7 @@ * 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. \*************************************************************************/ @@ -26,10 +25,6 @@ #ifndef osdSockH #define osdSockH -#ifdef __cplusplus -extern "C" { -#endif - #include #include @@ -37,8 +32,6 @@ extern "C" { #include #include #include -/*#include -#include */ #include #include #include @@ -47,10 +40,6 @@ extern "C" { #include /* close() and others */ -#ifdef __cplusplus -} -#endif - typedef int SOCKET; #define INVALID_SOCKET (-1) #define SOCKERRNO errno diff --git a/src/libCom/osi/os/RTEMS/osdSock.h b/src/libCom/osi/os/RTEMS/osdSock.h index 461c5d9de..21a350822 100644 --- a/src/libCom/osi/os/RTEMS/osdSock.h +++ b/src/libCom/osi/os/RTEMS/osdSock.h @@ -1,7 +1,6 @@ /*************************************************************************\ * Copyright (c) 2002 The University of Saskatchewan -* 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. \*************************************************************************/ /* @@ -14,10 +13,6 @@ #ifndef osdSockH #define osdSockH -#ifdef __cplusplus -extern "C" { -#endif - #include #include @@ -32,6 +27,10 @@ extern "C" { #include #include +#ifdef __cplusplus +extern "C" { +#endif + int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); #ifdef __cplusplus diff --git a/src/libCom/osi/os/RTEMS/osdTime.cpp b/src/libCom/osi/os/RTEMS/osdTime.cpp index b7ff6ee08..acefa1b09 100644 --- a/src/libCom/osi/os/RTEMS/osdTime.cpp +++ b/src/libCom/osi/os/RTEMS/osdTime.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "epicsTime.h" #include "osdTime.h" #include "osiNTPTime.h" @@ -117,17 +118,21 @@ double rtemsTicksPerSecond_double, rtemsTicksPerTwoSeconds_double; * explicitly calls osdTimeRegister() at the appropriate time. * However if we are loaded dynamically we *do* register our * standard time providers at static constructor time; in this - * case the tick rate will have been set already. + * case the network is available already. */ static int staticTimeRegister(void) { - if (rtemsTicksPerSecond != 0) - osdTimeRegister(); - rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &rtemsTicksPerSecond); rtemsTicksPerSecond_double = rtemsTicksPerSecond; rtemsTicksPerTwoSeconds_double = rtemsTicksPerSecond_double * 2.0; + /* If networking is already up at the time static constructors + * are executed then we are probably run-time loaded and it's + * OK to osdTimeRegister() at this point. + */ + if (rtems_bsdnet_ticks_per_second != 0) + osdTimeRegister(); + return 1; } static int done = staticTimeRegister(); diff --git a/src/libCom/osi/os/WIN32/osdSock.h b/src/libCom/osi/os/WIN32/osdSock.h index f362ed8b3..e6567e178 100644 --- a/src/libCom/osi/os/WIN32/osdSock.h +++ b/src/libCom/osi/os/WIN32/osdSock.h @@ -3,15 +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 +* EPICS BASE is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ - -#ifdef __cplusplus -extern "C" { -#endif +#ifndef osdSockH +#define osdSockH #include #include @@ -25,9 +22,6 @@ extern "C" { #endif #include -#ifdef __cplusplus -} -#endif #define SOCKERRNO WSAGetLastError() @@ -79,3 +73,4 @@ typedef int osiSocklen_t; epicsShareFunc unsigned epicsShareAPI wsaMajorVersion (); +#endif /*osdSockH*/ diff --git a/src/libCom/osi/os/cygwin32/osdSock.h b/src/libCom/osi/os/cygwin32/osdSock.h index 8d8326ce5..0915cc069 100644 --- a/src/libCom/osi/os/cygwin32/osdSock.h +++ b/src/libCom/osi/os/cygwin32/osdSock.h @@ -3,8 +3,7 @@ * 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. \*************************************************************************/ /* @@ -15,10 +14,6 @@ #ifndef osdSockH #define osdSockH -#ifdef __cplusplus -extern "C" { -#endif - #include #include @@ -31,10 +26,7 @@ extern "C" { #include #include /* close() and others */ -#ifdef __cplusplus -} -#endif - + typedef int SOCKET; #define INVALID_SOCKET (-1) #define SOCKERRNO errno diff --git a/src/libCom/osi/os/freebsd/osdSock.h b/src/libCom/osi/os/freebsd/osdSock.h index 8c270b72a..40df63631 100644 --- a/src/libCom/osi/os/freebsd/osdSock.h +++ b/src/libCom/osi/os/freebsd/osdSock.h @@ -10,10 +10,6 @@ #ifndef osdSockH #define osdSockH -#ifdef __cplusplus -extern "C" { -#endif - #include #include @@ -29,10 +25,6 @@ extern "C" { #include /* close() and others */ -#ifdef __cplusplus -} -#endif - #ifndef IPPORT_USERRESERVED #define IPPORT_USERRESERVED 5000 #endif diff --git a/src/libCom/osi/os/iOS/osdSock.h b/src/libCom/osi/os/iOS/osdSock.h index 44c70a8a0..de8a1cf97 100644 --- a/src/libCom/osi/os/iOS/osdSock.h +++ b/src/libCom/osi/os/iOS/osdSock.h @@ -13,10 +13,6 @@ #ifndef osdSockH #define osdSockH -#ifdef __cplusplus -extern "C" { -#endif - #include #include @@ -24,8 +20,6 @@ extern "C" { #include #include #include -/*#include -#include */ #include #include #include @@ -34,10 +28,6 @@ extern "C" { #include /* close() and others */ -#ifdef __cplusplus -} -#endif - typedef int SOCKET; #define INVALID_SOCKET (-1) #define SOCKERRNO errno diff --git a/src/libCom/osi/os/posix/osdThread.c b/src/libCom/osi/os/posix/osdThread.c index df0321ae2..501826715 100644 --- a/src/libCom/osi/os/posix/osdThread.c +++ b/src/libCom/osi/os/posix/osdThread.c @@ -75,6 +75,13 @@ typedef struct epicsThreadOSD { char *name; } epicsThreadOSD; +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING +typedef struct { + int min_pri, max_pri; + int policy; +} priAvailable; +#endif + static pthread_key_t getpthreadInfo; static pthread_mutex_t onceLock; static pthread_mutex_t listLock; @@ -201,6 +208,90 @@ static void free_threadInfo(epicsThreadOSD *pthreadInfo) free(pthreadInfo); } +#if defined (_POSIX_THREAD_PRIORITY_SCHEDULING) +/* + * The actually available range priority range (at least under linux) + * may be restricted by resource limitations (but that is ignored + * by sched_get_priority_max()). See bug #835138 which is fixed by + * this code. + */ + +static int try_pri(int pri, int policy) +{ +struct sched_param schedp; + + schedp.sched_priority = pri; + return pthread_setschedparam(pthread_self(), policy, &schedp); +} + +static void* +find_pri_range(void *arg) +{ +priAvailable *prm = arg; +int min = sched_get_priority_min(prm->policy); +int max = sched_get_priority_max(prm->policy); +int low, try; + + prm->min_pri = -1; + prm->max_pri = -1; + + if ( -1 == min || -1 == max ) { + /* something is very wrong... */ + return 0; + } + + if ( try_pri(min, prm->policy) ) { + /* cannot create thread at minimum priority; + * probably no permission to use SCHED_FIFO + * at all. + */ + return 0; + } + + + /* Binary search through available priorities. + * The actually available range may be restricted + * by resource limitations (but that is ignored + * by sched_get_priority_max() [linux]). + */ + low = min; + + while ( low < max ) { + try = (max+low)/2; + if ( try_pri(try, prm->policy) ) { + max = try; + } else { + low = try + 1; + } + } + + prm->min_pri = min; + prm->max_pri = try_pri(max, prm->policy) ? max-1 : max; + + return 0; +} + +static void findPriorityRange(commonAttr *a_p) +{ +priAvailable arg; +pthread_t id; +void *dummy; +int status; + + arg.policy = a_p->schedPolicy; + + status = pthread_create(&id, 0, find_pri_range, &arg); + checkStatusQuit(status, "pthread_create","epicsThreadInit"); + + status = pthread_join(id, &dummy); + checkStatusQuit(status, "pthread_join","epicsThreadInit"); + + a_p->minPriority = arg.min_pri; + a_p->maxPriority = arg.max_pri; +} +#endif + + static void once(void) { epicsThreadOSD *pthreadInfo; @@ -230,13 +321,14 @@ static void once(void) status = pthread_attr_getschedparam( &pcommonAttr->attr,&pcommonAttr->schedParam); checkStatusOnce(status,"pthread_attr_getschedparam"); - pcommonAttr->maxPriority = sched_get_priority_max(pcommonAttr->schedPolicy); + + findPriorityRange(pcommonAttr); + if(pcommonAttr->maxPriority == -1) { pcommonAttr->maxPriority = pcommonAttr->schedParam.sched_priority; fprintf(stderr,"sched_get_priority_max failed set to %d\n", pcommonAttr->maxPriority); } - pcommonAttr->minPriority = sched_get_priority_min(pcommonAttr->schedPolicy); if(pcommonAttr->minPriority == -1) { pcommonAttr->minPriority = pcommonAttr->schedParam.sched_priority; fprintf(stderr,"sched_get_priority_min failed set to %d\n", @@ -422,7 +514,7 @@ static epicsThreadOSD *createImplicit(void) int status; tid = pthread_self(); - sprintf(name, "non-EPICS_%d", (int)tid); + sprintf(name, "non-EPICS_%ld", (long)tid); pthreadInfo = create_threadInfo(name); pthreadInfo->tid = tid; pthreadInfo->osiPriority = 0; diff --git a/src/libCom/osi/os/solaris/osdSock.h b/src/libCom/osi/os/solaris/osdSock.h index 93cd5eeab..bffcaf367 100644 --- a/src/libCom/osi/os/solaris/osdSock.h +++ b/src/libCom/osi/os/solaris/osdSock.h @@ -3,8 +3,7 @@ * 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. \*************************************************************************/ @@ -15,10 +14,6 @@ #ifndef osdSockH #define osdSockH -#ifdef __cplusplus -extern "C" { -#endif - #include #include @@ -35,10 +30,7 @@ extern "C" { #include #include /* close() and others */ -#ifdef __cplusplus -} -#endif - + typedef int SOCKET; #define INVALID_SOCKET (-1) #define SOCKERRNO errno