From 8eacc2f05aa11090068e97810e75e8355fde8b09 Mon Sep 17 00:00:00 2001 From: Ben Franksen Date: Mon, 27 Feb 2017 08:14:31 +0100 Subject: [PATCH 1/5] Adapt motorRecord.cc to base-3.16 with typed rset --- motorApp/MotorSrc/motorRecord.cc | 55 +++++++++++++++++++------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/motorApp/MotorSrc/motorRecord.cc b/motorApp/MotorSrc/motorRecord.cc index dd8cacb7..b393cbc3 100644 --- a/motorApp/MotorSrc/motorRecord.cc +++ b/motorApp/MotorSrc/motorRecord.cc @@ -194,6 +194,16 @@ USAGE... Motor Record Support. #define VERSION 6.10 +#include "epicsVersion.h" + +#define VERSION_INT_3_16 VERSION_INT(3,16,0,0) +#if EPICS_VERSION_INT < VERSION_INT_3_16 +#define RECSUPFUN_CAST (RECSUPFUN) +#else +#define RECSUPFUN_CAST +#define REC_TYPE motorRecord +#endif + #include #include #include @@ -249,38 +259,39 @@ static void syncTargetPosition(motorRecord *); /*** Record Support Entry Table (RSET) functions. ***/ -static long init_record(dbCommon *, int); -static long process(dbCommon *); +extern "C" { +static long init_record(motorRecord *, int); +static long process(motorRecord *); static long special(DBADDR *, int); -static long get_units(const DBADDR *, char *); -static long get_precision(const DBADDR *, long *); -static long get_graphic_double(const DBADDR *, struct dbr_grDouble *); -static long get_control_double(const DBADDR *, struct dbr_ctrlDouble *); -static long get_alarm_double(const DBADDR *, struct dbr_alDouble *); - +static long get_units(DBADDR *, char *); +static long get_precision(DBADDR *, long *); +static long get_graphic_double(DBADDR *, struct dbr_grDouble *); +static long get_control_double(DBADDR *, struct dbr_ctrlDouble *); +static long get_alarm_double(DBADDR *, struct dbr_alDouble *); rset motorRSET = { RSETNUMBER, NULL, NULL, - (RECSUPFUN) init_record, - (RECSUPFUN) process, - (RECSUPFUN) special, + RECSUPFUN_CAST init_record, + RECSUPFUN_CAST process, + RECSUPFUN_CAST special, NULL, NULL, NULL, NULL, - (RECSUPFUN) get_units, - (RECSUPFUN) get_precision, + RECSUPFUN_CAST get_units, + RECSUPFUN_CAST get_precision, NULL, NULL, NULL, - (RECSUPFUN) get_graphic_double, - (RECSUPFUN) get_control_double, - (RECSUPFUN) get_alarm_double + RECSUPFUN_CAST get_graphic_double, + RECSUPFUN_CAST get_control_double, + RECSUPFUN_CAST get_alarm_double }; -extern "C" {epicsExportAddress(rset, motorRSET);} +epicsExportAddress(rset, motorRSET); +} /******************************************************************************* @@ -3116,7 +3127,7 @@ velcheckA: /****************************************************************************** get_units() *******************************************************************************/ -static long get_units(const DBADDR *paddr, char *units) +static long get_units(DBADDR *paddr, char *units) { motorRecord *pmr = (motorRecord *) paddr->precord; int siz = dbr_units_size - 1; /* "dbr_units_size" from dbAccess.h */ @@ -3173,7 +3184,7 @@ static long get_units(const DBADDR *paddr, char *units) /****************************************************************************** get_graphic_double() *******************************************************************************/ -static long get_graphic_double(const DBADDR *paddr, struct dbr_grDouble * pgd) +static long get_graphic_double(DBADDR *paddr, struct dbr_grDouble * pgd) { motorRecord *pmr = (motorRecord *) paddr->precord; int fieldIndex = dbGetFieldIndex(paddr); @@ -3224,7 +3235,7 @@ static long get_graphic_double(const DBADDR *paddr, struct dbr_grDouble * pgd) get_control_double() *******************************************************************************/ static long - get_control_double(const DBADDR *paddr, struct dbr_ctrlDouble * pcd) + get_control_double(DBADDR *paddr, struct dbr_ctrlDouble * pcd) { motorRecord *pmr = (motorRecord *) paddr->precord; int fieldIndex = dbGetFieldIndex(paddr); @@ -3273,7 +3284,7 @@ static long /****************************************************************************** get_precision() *******************************************************************************/ -static long get_precision(const DBADDR *paddr, long *precision) +static long get_precision(DBADDR *paddr, long *precision) { motorRecord *pmr = (motorRecord *) paddr->precord; int fieldIndex = dbGetFieldIndex(paddr); @@ -3304,7 +3315,7 @@ static long get_precision(const DBADDR *paddr, long *precision) /****************************************************************************** get_alarm_double() *******************************************************************************/ -static long get_alarm_double(const DBADDR *paddr, struct dbr_alDouble * pad) +static long get_alarm_double(DBADDR *paddr, struct dbr_alDouble * pad) { motorRecord *pmr = (motorRecord *) paddr->precord; int fieldIndex = dbGetFieldIndex(paddr); From eb3566976d75f127133856c0f69400ac64571b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Tue, 18 Sep 2018 16:25:11 +0200 Subject: [PATCH 2/5] More adaptions to base-3.16/7.0 with typed rset Remove more compiler warnings when compiling against the base 7.0 branch. Note: Some of the model1/2 drivers still give a warning. As I can not test the code, leave those files untouched. --- motorApp/MotorSrc/devMotorAsyn.c | 11 +++++++++++ motorApp/MotorSrc/motorRecord.cc | 9 +++++---- motorApp/MotorSrc/motorUtilAux.cc | 11 +++++++++++ motorApp/MotorSrc/motordevCom.cc | 11 +++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/motorApp/MotorSrc/devMotorAsyn.c b/motorApp/MotorSrc/devMotorAsyn.c index a3b915e8..652c9edd 100644 --- a/motorApp/MotorSrc/devMotorAsyn.c +++ b/motorApp/MotorSrc/devMotorAsyn.c @@ -45,6 +45,17 @@ * */ +#include "epicsVersion.h" + +#define VERSION_INT_3_16 VERSION_INT(3,16,0,0) +#if EPICS_VERSION_INT < VERSION_INT_3_16 +#define RECSUPFUN_CAST (RECSUPFUN) +#else +#define RECSUPFUN_CAST +#define REC_TYPE motorRecord +#define USE_TYPED_RSET +#endif + #include #include #include diff --git a/motorApp/MotorSrc/motorRecord.cc b/motorApp/MotorSrc/motorRecord.cc index b393cbc3..bf0decda 100644 --- a/motorApp/MotorSrc/motorRecord.cc +++ b/motorApp/MotorSrc/motorRecord.cc @@ -202,6 +202,7 @@ USAGE... Motor Record Support. #else #define RECSUPFUN_CAST #define REC_TYPE motorRecord +#define USE_TYPED_RSET #endif #include @@ -260,11 +261,11 @@ static void syncTargetPosition(motorRecord *); /*** Record Support Entry Table (RSET) functions. ***/ extern "C" { -static long init_record(motorRecord *, int); -static long process(motorRecord *); +static long init_record(struct dbCommon*, int); +static long process(struct dbCommon*); static long special(DBADDR *, int); static long get_units(DBADDR *, char *); -static long get_precision(DBADDR *, long *); +static long get_precision(const struct dbAddr *, long *); static long get_graphic_double(DBADDR *, struct dbr_grDouble *); static long get_control_double(DBADDR *, struct dbr_ctrlDouble *); static long get_alarm_double(DBADDR *, struct dbr_alDouble *); @@ -3284,7 +3285,7 @@ static long /****************************************************************************** get_precision() *******************************************************************************/ -static long get_precision(DBADDR *paddr, long *precision) +static long get_precision(const DBADDR *paddr, long *precision) { motorRecord *pmr = (motorRecord *) paddr->precord; int fieldIndex = dbGetFieldIndex(paddr); diff --git a/motorApp/MotorSrc/motorUtilAux.cc b/motorApp/MotorSrc/motorUtilAux.cc index 9b915d9d..5b5bbb79 100644 --- a/motorApp/MotorSrc/motorUtilAux.cc +++ b/motorApp/MotorSrc/motorUtilAux.cc @@ -28,6 +28,17 @@ USAGE... Motor Record Utility Support. * .03 09-09-08 rls Visual C++ link errors on improper pdbbase declaration. */ +#include "epicsVersion.h" + +#define VERSION_INT_3_16 VERSION_INT(3,16,0,0) +#if EPICS_VERSION_INT < VERSION_INT_3_16 +#define RECSUPFUN_CAST (RECSUPFUN) +#else +#define RECSUPFUN_CAST +#define REC_TYPE motorRecord +#define USE_TYPED_RSET +#endif + #include #include diff --git a/motorApp/MotorSrc/motordevCom.cc b/motorApp/MotorSrc/motordevCom.cc index c9a467e6..cbe539a7 100644 --- a/motorApp/MotorSrc/motordevCom.cc +++ b/motorApp/MotorSrc/motordevCom.cc @@ -59,6 +59,17 @@ USAGE... This file contains device functions that are common to all motor * motor_init_record_com(). See README R6-10 item #6 for details. */ +#include "epicsVersion.h" + +#define VERSION_INT_3_16 VERSION_INT(3,16,0,0) +#if EPICS_VERSION_INT < VERSION_INT_3_16 +#define RECSUPFUN_CAST (RECSUPFUN) +#else +#define RECSUPFUN_CAST +#define REC_TYPE motorRecord +#define USE_TYPED_RSET +#endif + #include #include From 71e417b4dbd6da543ff8a87649958d7c107069d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Tue, 18 Sep 2018 18:04:05 +0200 Subject: [PATCH 3/5] define VERSION_INT when using older EPICS bases Newer EPICS base versions define VERSION_INT, but older don't. Add a conditional #define to compile against those older bases, like 3.14 --- motorApp/MotorSrc/devMotorAsyn.c | 4 ++++ motorApp/MotorSrc/motorRecord.cc | 4 ++++ motorApp/MotorSrc/motorUtilAux.cc | 4 ++++ motorApp/MotorSrc/motordevCom.cc | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/motorApp/MotorSrc/devMotorAsyn.c b/motorApp/MotorSrc/devMotorAsyn.c index 652c9edd..42f0180a 100644 --- a/motorApp/MotorSrc/devMotorAsyn.c +++ b/motorApp/MotorSrc/devMotorAsyn.c @@ -47,6 +47,10 @@ #include "epicsVersion.h" +#ifndef VERSION_INT +# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) +#endif + #define VERSION_INT_3_16 VERSION_INT(3,16,0,0) #if EPICS_VERSION_INT < VERSION_INT_3_16 #define RECSUPFUN_CAST (RECSUPFUN) diff --git a/motorApp/MotorSrc/motorRecord.cc b/motorApp/MotorSrc/motorRecord.cc index bf0decda..befd4945 100644 --- a/motorApp/MotorSrc/motorRecord.cc +++ b/motorApp/MotorSrc/motorRecord.cc @@ -196,6 +196,10 @@ USAGE... Motor Record Support. #include "epicsVersion.h" +#ifndef VERSION_INT +# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) +#endif + #define VERSION_INT_3_16 VERSION_INT(3,16,0,0) #if EPICS_VERSION_INT < VERSION_INT_3_16 #define RECSUPFUN_CAST (RECSUPFUN) diff --git a/motorApp/MotorSrc/motorUtilAux.cc b/motorApp/MotorSrc/motorUtilAux.cc index 5b5bbb79..018cb816 100644 --- a/motorApp/MotorSrc/motorUtilAux.cc +++ b/motorApp/MotorSrc/motorUtilAux.cc @@ -30,6 +30,10 @@ USAGE... Motor Record Utility Support. #include "epicsVersion.h" +#ifndef VERSION_INT +# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) +#endif + #define VERSION_INT_3_16 VERSION_INT(3,16,0,0) #if EPICS_VERSION_INT < VERSION_INT_3_16 #define RECSUPFUN_CAST (RECSUPFUN) diff --git a/motorApp/MotorSrc/motordevCom.cc b/motorApp/MotorSrc/motordevCom.cc index cbe539a7..540da34f 100644 --- a/motorApp/MotorSrc/motordevCom.cc +++ b/motorApp/MotorSrc/motordevCom.cc @@ -61,6 +61,10 @@ USAGE... This file contains device functions that are common to all motor #include "epicsVersion.h" +#ifndef VERSION_INT +# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) +#endif + #define VERSION_INT_3_16 VERSION_INT(3,16,0,0) #if EPICS_VERSION_INT < VERSION_INT_3_16 #define RECSUPFUN_CAST (RECSUPFUN) From 5198a2d552f1b911d5a96189c3ac4530d1af3c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Wed, 19 Sep 2018 07:45:07 +0200 Subject: [PATCH 4/5] Clean up the EPICS_VERSION/rec sup, use motor_epics_inc.h Refactor the changes for the deprecated RECSUP in later EPICS base version, which need a typedef for struct rset. Unite all common code and put it into a single include file. Add motor_epics_inc.h. --- motorApp/MotorSrc/devMotorAsyn.c | 25 +--------------------- motorApp/MotorSrc/motorRecord.cc | 25 ++-------------------- motorApp/MotorSrc/motorUtilAux.cc | 17 ++------------- motorApp/MotorSrc/motor_epics_inc.h | 33 +++++++++++++++++++++++++++++ motorApp/MotorSrc/motordevCom.cc | 22 +------------------ 5 files changed, 39 insertions(+), 83 deletions(-) create mode 100644 motorApp/MotorSrc/motor_epics_inc.h diff --git a/motorApp/MotorSrc/devMotorAsyn.c b/motorApp/MotorSrc/devMotorAsyn.c index 42f0180a..c09834e9 100644 --- a/motorApp/MotorSrc/devMotorAsyn.c +++ b/motorApp/MotorSrc/devMotorAsyn.c @@ -45,36 +45,13 @@ * */ -#include "epicsVersion.h" - -#ifndef VERSION_INT -# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) -#endif - -#define VERSION_INT_3_16 VERSION_INT(3,16,0,0) -#if EPICS_VERSION_INT < VERSION_INT_3_16 -#define RECSUPFUN_CAST (RECSUPFUN) -#else -#define RECSUPFUN_CAST -#define REC_TYPE motorRecord -#define USE_TYPED_RSET -#endif - #include #include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include /* !! for callocMustSucceed() */ -#include +#include "motor_epics_inc.h" #include #include diff --git a/motorApp/MotorSrc/motorRecord.cc b/motorApp/MotorSrc/motorRecord.cc index befd4945..0129b879 100644 --- a/motorApp/MotorSrc/motorRecord.cc +++ b/motorApp/MotorSrc/motorRecord.cc @@ -194,35 +194,14 @@ USAGE... Motor Record Support. #define VERSION 6.10 -#include "epicsVersion.h" - -#ifndef VERSION_INT -# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) -#endif - -#define VERSION_INT_3_16 VERSION_INT(3,16,0,0) -#if EPICS_VERSION_INT < VERSION_INT_3_16 -#define RECSUPFUN_CAST (RECSUPFUN) -#else -#define RECSUPFUN_CAST -#define REC_TYPE motorRecord -#define USE_TYPED_RSET -#endif - #include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include "motor_epics_inc.h" + #define GEN_SIZE_OFFSET #include "motorRecord.h" #undef GEN_SIZE_OFFSET diff --git a/motorApp/MotorSrc/motorUtilAux.cc b/motorApp/MotorSrc/motorUtilAux.cc index 018cb816..fef1690c 100644 --- a/motorApp/MotorSrc/motorUtilAux.cc +++ b/motorApp/MotorSrc/motorUtilAux.cc @@ -28,22 +28,9 @@ USAGE... Motor Record Utility Support. * .03 09-09-08 rls Visual C++ link errors on improper pdbbase declaration. */ -#include "epicsVersion.h" - -#ifndef VERSION_INT -# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) -#endif - -#define VERSION_INT_3_16 VERSION_INT(3,16,0,0) -#if EPICS_VERSION_INT < VERSION_INT_3_16 -#define RECSUPFUN_CAST (RECSUPFUN) -#else -#define RECSUPFUN_CAST -#define REC_TYPE motorRecord -#define USE_TYPED_RSET -#endif - #include +#include "motor_epics_inc.h" + #include #include diff --git a/motorApp/MotorSrc/motor_epics_inc.h b/motorApp/MotorSrc/motor_epics_inc.h new file mode 100644 index 00000000..0d4698c5 --- /dev/null +++ b/motorApp/MotorSrc/motor_epics_inc.h @@ -0,0 +1,33 @@ +#ifndef INCmotorepicsinc +#define INCmotorepicsinc 1 + +#include "epicsVersion.h" + +#ifndef VERSION_INT +# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) +#endif + +#define VERSION_INT_3_16 VERSION_INT(3,16,0,0) +#if EPICS_VERSION_INT < VERSION_INT_3_16 +#define RECSUPFUN_CAST (RECSUPFUN) +#else +#define RECSUPFUN_CAST +#define REC_TYPE motorRecord +#define USE_TYPED_RSET +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* !! for callocMustSucceed() */ +#include +#include + +#endif diff --git a/motorApp/MotorSrc/motordevCom.cc b/motorApp/MotorSrc/motordevCom.cc index 540da34f..b82bc8fa 100644 --- a/motorApp/MotorSrc/motordevCom.cc +++ b/motorApp/MotorSrc/motordevCom.cc @@ -59,31 +59,11 @@ USAGE... This file contains device functions that are common to all motor * motor_init_record_com(). See README R6-10 item #6 for details. */ -#include "epicsVersion.h" - -#ifndef VERSION_INT -# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) -#endif - -#define VERSION_INT_3_16 VERSION_INT(3,16,0,0) -#if EPICS_VERSION_INT < VERSION_INT_3_16 -#define RECSUPFUN_CAST (RECSUPFUN) -#else -#define RECSUPFUN_CAST -#define REC_TYPE motorRecord -#define USE_TYPED_RSET -#endif - #include #include #include -#include -#include -#include -#include -#include -#include +#include "motor_epics_inc.h" #include "motorRecord.h" #include "motor.h" From dcf7b37c8932d58fdab80c6f91a7b03379bcf871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Tue, 2 Oct 2018 15:37:28 +0200 Subject: [PATCH 5/5] Avoid warnings with R3.16.1 in devSoft.cc and devMotorSim.c Need to set USE_TYPED_RSET to avoid a warning whencompiling against Base R3.16.1 Older Bases don't know the #define, and R3.16.1 seems to need it. --- motorApp/MotorSimSrc/devMotorSim.c | 3 +++ motorApp/SoftMotorSrc/devSoft.cc | 2 ++ 2 files changed, 5 insertions(+) diff --git a/motorApp/MotorSimSrc/devMotorSim.c b/motorApp/MotorSimSrc/devMotorSim.c index 15552418..f8889e3c 100644 --- a/motorApp/MotorSimSrc/devMotorSim.c +++ b/motorApp/MotorSimSrc/devMotorSim.c @@ -6,6 +6,9 @@ #include #include +/* The following is needed to compile against Base R3.16.1 without a warning */ +#define USE_TYPED_RSET + #include "epicsFindSymbol.h" #include "dbAccess.h" #include "recGbl.h" diff --git a/motorApp/SoftMotorSrc/devSoft.cc b/motorApp/SoftMotorSrc/devSoft.cc index 5ef2ddd0..55d29138 100644 --- a/motorApp/SoftMotorSrc/devSoft.cc +++ b/motorApp/SoftMotorSrc/devSoft.cc @@ -46,6 +46,8 @@ NOTES... - Can't call CA functions until after dbLockInitRecords() has been called and initialized lock sets. */ +/* The following is needed to compile against Base R3.16.1 without a warning */ +#define USE_TYPED_RSET #include #include