From 2b65025d93bde3a5b61eb0cc66a61ab4440cd977 Mon Sep 17 00:00:00 2001 From: Till Straumann Date: Tue, 23 Aug 2011 13:20:00 -0500 Subject: [PATCH 1/8] RTEMS: Time registration when dynamically loading The old test for discriminating between statically and dynamically linked applications (os/RTEMS/osdTime.cpp:staticTimeRegister()) is wrong, it never detects a dynamically loaded app. fixes lp:831648 -------------- This line and the following will be ignored -------------- modified: src/libCom/osi/os/RTEMS/osdTime.cpp --- src/libCom/osi/os/RTEMS/osdTime.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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(); From 14e7111e72a0d8e36959f0457ff6793b53a3b4ff Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Thu, 25 Aug 2011 17:41:53 +0200 Subject: [PATCH 2/8] catools: Fixed caget (w/o -c) always fetching max. array count --- src/catools/caget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/catools/caget.c b/src/catools/caget.c index 1ce588615..ac742fc73 100644 --- a/src/catools/caget.c +++ b/src/catools/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); } From f203e9a48bef3d812d4bdf155db4f5b59cdac52b Mon Sep 17 00:00:00 2001 From: Till Straumann Date: Tue, 30 Aug 2011 14:47:31 -0500 Subject: [PATCH 3/8] libCom: Fix OS priority mapping on Posix Fixes lp:835138 --- src/libCom/osi/os/posix/osdThread.c | 96 ++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/src/libCom/osi/os/posix/osdThread.c b/src/libCom/osi/os/posix/osdThread.c index df0321ae2..954e04dc9 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", From 83e5247ed4d22e89f0a6ae20c3a078204419fb12 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 8 Sep 2011 17:57:14 -0600 Subject: [PATCH 4/8] workaround for non-standard vxWorks 5.5.2 gnu compiler --- src/ca/udpiiu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ca/udpiiu.h b/src/ca/udpiiu.h index 5a0f869e1..2f9918e49 100644 --- a/src/ca/udpiiu.h +++ b/src/ca/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 From 3cfa011760bf35e7a2bda6d6accfbf4331fd146f Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 9 Sep 2011 17:10:32 -0500 Subject: [PATCH 5/8] libCom: Clean up warning from Darwin. --- src/libCom/osi/os/posix/osdThread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libCom/osi/os/posix/osdThread.c b/src/libCom/osi/os/posix/osdThread.c index 954e04dc9..501826715 100644 --- a/src/libCom/osi/os/posix/osdThread.c +++ b/src/libCom/osi/os/posix/osdThread.c @@ -514,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; From 75aa05d30f4abc479f7eba72e349239c5b394f26 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 9 Sep 2011 17:14:35 -0500 Subject: [PATCH 6/8] libCom: Remove extern "C" { #include <...> } from osdSock.h Our joint conclusion was that wrapping system includes with extern "C" used to be necessary on some OS builds when C++ was much less common, but is now wrong. --- src/libCom/osi/os/Darwin/osdSock.h | 13 +------------ src/libCom/osi/os/Linux/osdSock.h | 13 +------------ src/libCom/osi/os/RTEMS/osdSock.h | 11 +++++------ src/libCom/osi/os/WIN32/osdSock.h | 13 ++++--------- src/libCom/osi/os/cygwin32/osdSock.h | 12 ++---------- src/libCom/osi/os/freebsd/osdSock.h | 8 -------- src/libCom/osi/os/iOS/osdSock.h | 10 ---------- src/libCom/osi/os/solaris/osdSock.h | 12 ++---------- src/libCom/osi/os/vxWorks/osdSock.h | 14 ++++++++------ 9 files changed, 23 insertions(+), 83 deletions(-) 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/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/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 diff --git a/src/libCom/osi/os/vxWorks/osdSock.h b/src/libCom/osi/os/vxWorks/osdSock.h index 3ebc5799a..f220ea8bd 100644 --- a/src/libCom/osi/os/vxWorks/osdSock.h +++ b/src/libCom/osi/os/vxWorks/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. \*************************************************************************/ /* @@ -14,12 +13,10 @@ #ifndef osdSockH #define osdSockH -#ifdef __cplusplus -extern "C" { -#endif - /* This is needed for vxWorks 6.8 to prevent an obnoxious compiler warning */ +#ifndef _VSB_CONFIG_FILE #define _VSB_CONFIG_FILE <../lib/h/config/vsbConfig.h> +#endif #include @@ -36,6 +33,11 @@ extern "C" { #include #include #include + +#ifdef __cplusplus +extern "C" { +#endif + /*This following is not defined in any vxWorks header files*/ int sysClkRateGet(void); From 46ea687c6d2cad28785499765e145cdba226b881 Mon Sep 17 00:00:00 2001 From: Janet Anderson Date: Thu, 15 Sep 2011 11:00:41 -0500 Subject: [PATCH 7/8] Fixed TARGET_SRCS definition --- configure/CONFIG_COMMON | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON index d5de9cbbc..20aa9ccec 100644 --- a/configure/CONFIG_COMMON +++ b/configure/CONFIG_COMMON @@ -336,7 +336,7 @@ HDEPENDS_CFLAGS = $(HDEPENDS_CFLAGS_$(HDEPENDS)) #-------------------------------------------------- # depends definition -TARGET_SRCS = $(foreach name, $(TESTPROD) $(PROD) $(LIBRARY), $($(name)_SRCS)) +TARGET_SRCS = $(foreach name, $(TESTPROD) $(PROD) $(LIBRARY) $(LOADABLE_LIBRARY), $($(name)_SRCS)) SRC_FILES = $(LIB_SRCS) $(LIBSRCS) $(SRCS) $(USR_SRCS) $(PROD_SRCS) $(TARGET_SRCS) HDEPENDS_FILES_YES = $(addsuffix $(DEP),$(notdir $(basename $(SRC_FILES)))) HDEPENDS_FILES = $(if $(filter NO,$(HDEPENDS)),,$(HDEPENDS_FILES_YES)) From 3a101aa697ea9470de8c64c6035a94434e90f64f Mon Sep 17 00:00:00 2001 From: Janet Anderson Date: Thu, 15 Sep 2011 11:03:20 -0500 Subject: [PATCH 8/8] Fixed DBDINC_NAME definition --- configure/RULES.Db | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure/RULES.Db b/configure/RULES.Db index 9eb27e527..e0d0fcf70 100644 --- a/configure/RULES.Db +++ b/configure/RULES.Db @@ -48,7 +48,7 @@ DBFLAGS = $($*_DBFLAGS) $(USR_DBFLAGS) -I. -I.. $(INSTALL_DBFLAGS) $(RELEASE_DBF # Following line added for backward compatibilty DBD += $(DBDNAME) -DBDINC_NAME = $(patsubst %.h,%,$(patsubst %.db,%,$(DBDINC))) +DBDINC_NAME = $(patsubst %.h,%,$(patsubst %.dbd,%,$(DBDINC))) DBD += $(addsuffix .dbd,$(DBDINC_NAME)) INC += $(addsuffix .h,$(DBDINC_NAME))