Introduce & use FASTCONVERTFUNC with full prototype
This commit is contained in:
@ -14,13 +14,16 @@
|
|||||||
|
|
||||||
#include "dbFldTypes.h"
|
#include "dbFldTypes.h"
|
||||||
#include "dbCoreAPI.h"
|
#include "dbCoreAPI.h"
|
||||||
|
#include "link.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DBCORE_API extern long (*dbFastGetConvertRoutine[DBF_DEVICE+1][DBR_ENUM+1])();
|
/* typedef FASTCONVERTFUNC is now defined in link.h */
|
||||||
DBCORE_API extern long (*dbFastPutConvertRoutine[DBR_ENUM+1][DBF_DEVICE+1])();
|
|
||||||
|
DBCORE_API extern FASTCONVERTFUNC dbFastGetConvertRoutine[DBF_DEVICE+1][DBR_ENUM+1];
|
||||||
|
DBCORE_API extern FASTCONVERTFUNC dbFastPutConvertRoutine[DBR_ENUM+1][DBF_DEVICE+1];
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
#include "dbConvertFast.h"
|
#include "dbConvertFast.h"
|
||||||
#include "dbConvertJSON.h"
|
#include "dbConvertJSON.h"
|
||||||
|
|
||||||
typedef long (*FASTCONVERT)();
|
|
||||||
|
|
||||||
typedef struct parseContext {
|
typedef struct parseContext {
|
||||||
int depth;
|
int depth;
|
||||||
short dbrType;
|
short dbrType;
|
||||||
@ -42,7 +40,7 @@ static int dbcj_boolean(void *ctx, int val) {
|
|||||||
static int dbcj_integer(void *ctx, long long num) {
|
static int dbcj_integer(void *ctx, long long num) {
|
||||||
parseContext *parser = (parseContext *) ctx;
|
parseContext *parser = (parseContext *) ctx;
|
||||||
epicsInt64 val64 = num;
|
epicsInt64 val64 = num;
|
||||||
FASTCONVERT conv = dbFastPutConvertRoutine[DBF_INT64][parser->dbrType];
|
FASTCONVERTFUNC conv = dbFastPutConvertRoutine[DBF_INT64][parser->dbrType];
|
||||||
|
|
||||||
if (parser->elems > 0) {
|
if (parser->elems > 0) {
|
||||||
conv(&val64, parser->pdest, NULL);
|
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) {
|
static int dbcj_double(void *ctx, double num) {
|
||||||
parseContext *parser = (parseContext *) ctx;
|
parseContext *parser = (parseContext *) ctx;
|
||||||
FASTCONVERT conv = dbFastPutConvertRoutine[DBF_DOUBLE][parser->dbrType];
|
FASTCONVERTFUNC conv = dbFastPutConvertRoutine[DBF_DOUBLE][parser->dbrType];
|
||||||
|
|
||||||
if (parser->elems > 0) {
|
if (parser->elems > 0) {
|
||||||
conv(&num, parser->pdest, NULL);
|
conv(&num, parser->pdest, NULL);
|
||||||
|
@ -1399,7 +1399,7 @@ static long cvt_device_st(
|
|||||||
* NULL implies the conversion is not supported.
|
* 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 ... */
|
/* 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 },
|
{ 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.
|
* 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 ... */
|
/* 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},
|
{ 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},
|
||||||
|
@ -77,14 +77,14 @@ struct macro_link {
|
|||||||
char *macroStr;
|
char *macroStr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dbCommon;
|
struct dbAddr;
|
||||||
typedef long (*LINKCVT)();
|
typedef long (*FASTCONVERTFUNC)(const void *from, void *to, const struct dbAddr *paddr);
|
||||||
|
|
||||||
struct pv_link {
|
struct pv_link {
|
||||||
ELLNODE backlinknode;
|
ELLNODE backlinknode;
|
||||||
char *pvname; /* pvname link points to */
|
char *pvname; /* pvname link points to */
|
||||||
void *pvt; /* CA or DB private */
|
void *pvt; /* CA or DB private */
|
||||||
LINKCVT getCvt; /* input conversion function */
|
FASTCONVERTFUNC getCvt; /* input conversion function */
|
||||||
short pvlMask; /* Options mask */
|
short pvlMask; /* Options mask */
|
||||||
short lastGetdbrType; /* last dbrType for DB or CA get */
|
short lastGetdbrType; /* last dbrType for DB or CA get */
|
||||||
};
|
};
|
||||||
|
@ -36,8 +36,6 @@
|
|||||||
#include "epicsExport.h"
|
#include "epicsExport.h"
|
||||||
|
|
||||||
|
|
||||||
typedef long (*FASTCONVERT)();
|
|
||||||
|
|
||||||
typedef struct calc_link {
|
typedef struct calc_link {
|
||||||
jlink jlink; /* embedded object */
|
jlink jlink; /* embedded object */
|
||||||
int nArgs;
|
int nArgs;
|
||||||
@ -558,7 +556,7 @@ static long lnkCalc_getValue(struct link *plink, short dbrType, void *pbuffer,
|
|||||||
dbCommon *prec = plink->precord;
|
dbCommon *prec = plink->precord;
|
||||||
int i;
|
int i;
|
||||||
long status;
|
long status;
|
||||||
FASTCONVERT conv;
|
FASTCONVERTFUNC conv;
|
||||||
|
|
||||||
if(INVALID_DB_REQ(dbrType))
|
if(INVALID_DB_REQ(dbrType))
|
||||||
return S_db_badDbrtype;
|
return S_db_badDbrtype;
|
||||||
@ -638,7 +636,7 @@ static long lnkCalc_putValue(struct link *plink, short dbrType,
|
|||||||
dbCommon *prec = plink->precord;
|
dbCommon *prec = plink->precord;
|
||||||
int i;
|
int i;
|
||||||
long status;
|
long status;
|
||||||
FASTCONVERT conv;
|
FASTCONVERTFUNC conv;
|
||||||
|
|
||||||
if(INVALID_DB_REQ(dbrType))
|
if(INVALID_DB_REQ(dbrType))
|
||||||
return S_db_badDbrtype;
|
return S_db_badDbrtype;
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
#include "epicsExport.h"
|
#include "epicsExport.h"
|
||||||
|
|
||||||
|
|
||||||
typedef long (*FASTCONVERT)();
|
|
||||||
|
|
||||||
typedef struct const_link {
|
typedef struct const_link {
|
||||||
jlink jlink; /* embedded object */
|
jlink jlink; /* embedded object */
|
||||||
int nElems;
|
int nElems;
|
||||||
@ -458,7 +456,7 @@ static long lnkConst_loadArray(struct link *plink, short dbrType, void *pbuffer,
|
|||||||
short dbrSize;
|
short dbrSize;
|
||||||
char *pdest = pbuffer;
|
char *pdest = pbuffer;
|
||||||
int nElems = clink->nElems;
|
int nElems = clink->nElems;
|
||||||
FASTCONVERT conv;
|
FASTCONVERTFUNC conv;
|
||||||
long status;
|
long status;
|
||||||
|
|
||||||
if(INVALID_DB_REQ(dbrType))
|
if(INVALID_DB_REQ(dbrType))
|
||||||
|
@ -34,8 +34,6 @@
|
|||||||
#include "epicsExport.h"
|
#include "epicsExport.h"
|
||||||
|
|
||||||
|
|
||||||
typedef long (*FASTCONVERT)();
|
|
||||||
|
|
||||||
typedef struct state_link {
|
typedef struct state_link {
|
||||||
jlink jlink; /* embedded object */
|
jlink jlink; /* embedded object */
|
||||||
char *name;
|
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,
|
state_link *slink = CONTAINER(plink->value.json.jlink,
|
||||||
struct state_link, jlink);
|
struct state_link, jlink);
|
||||||
FASTCONVERT conv;
|
FASTCONVERTFUNC conv;
|
||||||
|
|
||||||
if(INVALID_DB_REQ(dbrType))
|
if(INVALID_DB_REQ(dbrType))
|
||||||
return S_db_badDbrtype;
|
return S_db_badDbrtype;
|
||||||
|
@ -83,13 +83,13 @@ long z_getval(struct link *plink, short dbrType, void *pbuffer,
|
|||||||
long *pnRequest)
|
long *pnRequest)
|
||||||
{
|
{
|
||||||
long ret;
|
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);
|
zpriv *priv = CONTAINER(plink->value.json.jlink, zpriv, base);
|
||||||
|
|
||||||
if(pnRequest && *pnRequest==0) return 0;
|
if(pnRequest && *pnRequest==0) return 0;
|
||||||
|
|
||||||
epicsMutexLock(priv->lock);
|
epicsMutexLock(priv->lock);
|
||||||
ret = (*pconv)(&priv->value, pbuffer, NULL);
|
ret = pconv(&priv->value, pbuffer, NULL);
|
||||||
epicsMutexUnlock(priv->lock);
|
epicsMutexUnlock(priv->lock);
|
||||||
if(ret==0 && pnRequest) *pnRequest = 1;
|
if(ret==0 && pnRequest) *pnRequest = 1;
|
||||||
return ret;
|
return ret;
|
||||||
@ -118,18 +118,17 @@ long z_putval(struct link *plink, short dbrType,
|
|||||||
const void *pbuffer, long nRequest)
|
const void *pbuffer, long nRequest)
|
||||||
{
|
{
|
||||||
long ret;
|
long ret;
|
||||||
long (*pconv)(epicsInt32 *, const void *, const dbAddr *);
|
|
||||||
zpriv *priv = CONTAINER(plink->value.json.jlink, zpriv, base);
|
zpriv *priv = CONTAINER(plink->value.json.jlink, zpriv, base);
|
||||||
|
|
||||||
if(INVALID_DB_REQ(dbrType))
|
if(INVALID_DB_REQ(dbrType))
|
||||||
return S_db_badDbrtype;
|
return S_db_badDbrtype;
|
||||||
|
|
||||||
pconv = dbFastPutConvertRoutine[DBF_LONG][dbrType];
|
FASTCONVERTFUNC pconv = dbFastPutConvertRoutine[DBF_LONG][dbrType];
|
||||||
|
|
||||||
if(nRequest==0) return 0;
|
if(nRequest==0) return 0;
|
||||||
|
|
||||||
epicsMutexLock(priv->lock);
|
epicsMutexLock(priv->lock);
|
||||||
ret = (*pconv)(&priv->value, pbuffer, NULL);
|
ret = pconv(pbuffer, &priv->value, NULL);
|
||||||
epicsMutexUnlock(priv->lock);
|
epicsMutexUnlock(priv->lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user