Introduce & use FASTCONVERTFUNC with full prototype

This commit is contained in:
Andrew Johnson
2023-12-24 17:50:09 +00:00
parent 785237e41a
commit f287cfa2ac
8 changed files with 20 additions and 26 deletions

View File

@ -14,13 +14,16 @@
#include "dbFldTypes.h"
#include "dbCoreAPI.h"
#include "link.h"
#ifdef __cplusplus
extern "C" {
#endif
DBCORE_API extern long (*dbFastGetConvertRoutine[DBF_DEVICE+1][DBR_ENUM+1])();
DBCORE_API extern long (*dbFastPutConvertRoutine[DBR_ENUM+1][DBF_DEVICE+1])();
/* typedef FASTCONVERTFUNC is now defined in link.h */
DBCORE_API extern FASTCONVERTFUNC dbFastGetConvertRoutine[DBF_DEVICE+1][DBR_ENUM+1];
DBCORE_API extern FASTCONVERTFUNC dbFastPutConvertRoutine[DBR_ENUM+1][DBF_DEVICE+1];
#ifdef __cplusplus
}

View File

@ -19,8 +19,6 @@
#include "dbConvertFast.h"
#include "dbConvertJSON.h"
typedef long (*FASTCONVERT)();
typedef struct parseContext {
int depth;
short dbrType;
@ -42,7 +40,7 @@ static int dbcj_boolean(void *ctx, int val) {
static int dbcj_integer(void *ctx, long long num) {
parseContext *parser = (parseContext *) ctx;
epicsInt64 val64 = num;
FASTCONVERT conv = dbFastPutConvertRoutine[DBF_INT64][parser->dbrType];
FASTCONVERTFUNC conv = dbFastPutConvertRoutine[DBF_INT64][parser->dbrType];
if (parser->elems > 0) {
conv(&val64, parser->pdest, NULL);
@ -54,7 +52,7 @@ static int dbcj_integer(void *ctx, long long num) {
static int dbcj_double(void *ctx, double num) {
parseContext *parser = (parseContext *) ctx;
FASTCONVERT conv = dbFastPutConvertRoutine[DBF_DOUBLE][parser->dbrType];
FASTCONVERTFUNC conv = dbFastPutConvertRoutine[DBF_DOUBLE][parser->dbrType];
if (parser->elems > 0) {
conv(&num, parser->pdest, NULL);

View File

@ -1399,7 +1399,7 @@ static long cvt_device_st(
* NULL implies the conversion is not supported.
*/
long (*dbFastGetConvertRoutine[DBF_DEVICE+1][DBR_ENUM+1])() = {
FASTCONVERTFUNC dbFastGetConvertRoutine[DBF_DEVICE+1][DBR_ENUM+1] = {
/* Convert DBF_STRING to ... */
{ cvt_st_st, cvt_st_c, cvt_st_uc, cvt_st_s, cvt_st_us, cvt_st_l, cvt_st_ul, cvt_st_q, cvt_st_uq, cvt_st_f, cvt_st_d, cvt_st_e },
@ -1455,7 +1455,7 @@ long (*dbFastGetConvertRoutine[DBF_DEVICE+1][DBR_ENUM+1])() = {
* NULL implies the conversion is not supported.
*/
long (*dbFastPutConvertRoutine[DBR_ENUM+1][DBF_DEVICE+1])() = {
FASTCONVERTFUNC dbFastPutConvertRoutine[DBR_ENUM+1][DBF_DEVICE+1] = {
/* Convert DBR_STRING to ... */
{ cvt_st_st, cvt_st_c, cvt_st_uc, cvt_st_s, cvt_st_us, cvt_st_l, cvt_st_ul, cvt_st_q, cvt_st_uq, cvt_st_f, cvt_st_d, cvt_st_e, cvt_st_menu, cvt_st_device},

View File

@ -77,14 +77,14 @@ struct macro_link {
char *macroStr;
};
struct dbCommon;
typedef long (*LINKCVT)();
struct dbAddr;
typedef long (*FASTCONVERTFUNC)(const void *from, void *to, const struct dbAddr *paddr);
struct pv_link {
ELLNODE backlinknode;
char *pvname; /* pvname link points to */
void *pvt; /* CA or DB private */
LINKCVT getCvt; /* input conversion function */
FASTCONVERTFUNC getCvt; /* input conversion function */
short pvlMask; /* Options mask */
short lastGetdbrType; /* last dbrType for DB or CA get */
};

View File

@ -36,8 +36,6 @@
#include "epicsExport.h"
typedef long (*FASTCONVERT)();
typedef struct calc_link {
jlink jlink; /* embedded object */
int nArgs;
@ -558,7 +556,7 @@ static long lnkCalc_getValue(struct link *plink, short dbrType, void *pbuffer,
dbCommon *prec = plink->precord;
int i;
long status;
FASTCONVERT conv;
FASTCONVERTFUNC conv;
if(INVALID_DB_REQ(dbrType))
return S_db_badDbrtype;
@ -638,7 +636,7 @@ static long lnkCalc_putValue(struct link *plink, short dbrType,
dbCommon *prec = plink->precord;
int i;
long status;
FASTCONVERT conv;
FASTCONVERTFUNC conv;
if(INVALID_DB_REQ(dbrType))
return S_db_badDbrtype;

View File

@ -23,8 +23,6 @@
#include "epicsExport.h"
typedef long (*FASTCONVERT)();
typedef struct const_link {
jlink jlink; /* embedded object */
int nElems;
@ -458,7 +456,7 @@ static long lnkConst_loadArray(struct link *plink, short dbrType, void *pbuffer,
short dbrSize;
char *pdest = pbuffer;
int nElems = clink->nElems;
FASTCONVERT conv;
FASTCONVERTFUNC conv;
long status;
if(INVALID_DB_REQ(dbrType))

View File

@ -34,8 +34,6 @@
#include "epicsExport.h"
typedef long (*FASTCONVERT)();
typedef struct state_link {
jlink jlink; /* embedded object */
char *name;
@ -143,7 +141,7 @@ static long lnkState_getValue(struct link *plink, short dbrType, void *pbuffer,
{
state_link *slink = CONTAINER(plink->value.json.jlink,
struct state_link, jlink);
FASTCONVERT conv;
FASTCONVERTFUNC conv;
if(INVALID_DB_REQ(dbrType))
return S_db_badDbrtype;

View File

@ -83,13 +83,13 @@ long z_getval(struct link *plink, short dbrType, void *pbuffer,
long *pnRequest)
{
long ret;
long (*pconv)(const epicsInt32 *, void *, const dbAddr *) = dbFastGetConvertRoutine[DBF_LONG][dbrType];
FASTCONVERTFUNC pconv = dbFastGetConvertRoutine[DBF_LONG][dbrType];
zpriv *priv = CONTAINER(plink->value.json.jlink, zpriv, base);
if(pnRequest && *pnRequest==0) return 0;
epicsMutexLock(priv->lock);
ret = (*pconv)(&priv->value, pbuffer, NULL);
ret = pconv(&priv->value, pbuffer, NULL);
epicsMutexUnlock(priv->lock);
if(ret==0 && pnRequest) *pnRequest = 1;
return ret;
@ -118,18 +118,17 @@ long z_putval(struct link *plink, short dbrType,
const void *pbuffer, long nRequest)
{
long ret;
long (*pconv)(epicsInt32 *, const void *, const dbAddr *);
zpriv *priv = CONTAINER(plink->value.json.jlink, zpriv, base);
if(INVALID_DB_REQ(dbrType))
return S_db_badDbrtype;
pconv = dbFastPutConvertRoutine[DBF_LONG][dbrType];
FASTCONVERTFUNC pconv = dbFastPutConvertRoutine[DBF_LONG][dbrType];
if(nRequest==0) return 0;
epicsMutexLock(priv->lock);
ret = (*pconv)(&priv->value, pbuffer, NULL);
ret = pconv(pbuffer, &priv->value, NULL);
epicsMutexUnlock(priv->lock);
return ret;
}