From 1893cb4f54264d137e7a6eb0c3a8c2193f9d2f89 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 14 May 2018 19:51:27 -0700 Subject: [PATCH] add USE_TYPED_DRVET and USE_TYPED_DSET options --- src/ioc/dbStatic/devSup.h | 38 ++++++++++++++++++++++---------------- src/ioc/dbStatic/drvSup.h | 28 +++++++++++++++------------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/ioc/dbStatic/devSup.h b/src/ioc/dbStatic/devSup.h index 63ffb36ce..7520b7a71 100644 --- a/src/ioc/dbStatic/devSup.h +++ b/src/ioc/dbStatic/devSup.h @@ -24,22 +24,6 @@ struct devSup; struct ioscan_head; /* aka IOSCANPVT */ struct link; /* aka DBLINK */ -#ifdef __cplusplus -extern "C" { - typedef long (*DEVSUPFUN)(void *); /* ptr to device support function*/ -#else - typedef long (*DEVSUPFUN)(); /* ptr to device support function*/ -#endif - -typedef struct dset { /* device support entry table */ - long number; /*number of support routines*/ - DEVSUPFUN report; /*print report*/ - DEVSUPFUN init; /*init support layer*/ - DEVSUPFUN init_record; /*init device for particular record*/ - DEVSUPFUN get_ioint_info; /* get io interrupt information*/ - /*other functions are record dependent*/ -} dset; - /** Type safe alternative to 'struct dset' * * Recommended usage @@ -113,6 +97,28 @@ typedef struct dsxt { /* device support extension table */ /* Recordtypes are *not* allowed to extend this table */ } dsxt; +#ifdef __cplusplus +extern "C" { + typedef long (*DEVSUPFUN)(void *); /* ptr to device support function*/ +#else + typedef long (*DEVSUPFUN)(); /* ptr to device support function*/ +#endif + +#ifndef USE_TYPED_DSET + +typedef struct dset { /* device support entry table */ + long number; /*number of support routines*/ + DEVSUPFUN report; /*print report*/ + DEVSUPFUN init; /*init support layer*/ + DEVSUPFUN init_record; /*init device for particular record*/ + DEVSUPFUN get_ioint_info; /* get io interrupt information*/ + /*other functions are record dependent*/ +} dset; + +#else +typedef typed_dset dset; +#endif /* USE_TYPED_DSET */ + /** Fetch INP or OUT link (or NULL if record type has neither). * * Recommended for use in device support init_record() diff --git a/src/ioc/dbStatic/drvSup.h b/src/ioc/dbStatic/drvSup.h index 59a566938..943105f31 100644 --- a/src/ioc/dbStatic/drvSup.h +++ b/src/ioc/dbStatic/drvSup.h @@ -18,7 +18,19 @@ #include "errMdef.h" -typedef long (*DRVSUPFUN) (); /* ptr to driver support function*/ +typedef struct typed_drvet { + /** Number of function pointers which follow. Must be >=2 */ + long number; + /** Called from dbior() */ + long (*report)(int lvl); + /** Called during iocInit() */ + long (*init)(void); + /*other functions are device dependent*/ +} typed_drvet; + +typedef long (*DRVSUPFUN) (); /* ptr to driver support function for use with plain/untyped drvet */ + +#ifndef USE_TYPED_DRVET typedef struct drvet { /* driver entry table */ long number; /*number of support routines*/ @@ -28,19 +40,9 @@ typedef struct drvet { /* driver entry table */ }drvet; #define DRVETNUMBER ( (sizeof(struct drvet) -sizeof(long))/sizeof(DRVSUPFUN) ) -typedef struct typed_drvet { - /** Number of function pointers which follow. Must be >=2 */ - long number; - /** Called from dbior() */ - long (*report)(int lvl); - /** Called during iocInit() */ -#ifdef __cplusplus - long (*init)(); #else - long (*init)(void); -#endif - /*other functions are device dependent*/ -} typed_drvet; +typedef typed_drvet drvet; +#endif /* USE_TYPED_DRVET */ #define S_drv_noDrvSup (M_drvSup| 1) /*SDR_DRVSUP: Driver support missing*/ #define S_drv_noDrvet (M_drvSup| 3) /*Missing driver support entry table*/