diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index 8361621c8..b2e5fdc65 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -20,6 +20,11 @@ --> +

Callback subsystem API

+ +

Added a new macro callbackGetPriority(prio, callback) to the +callback.h header and removed the need for dbScan.c to reach into the internals +of its CALLBACK objects.

diff --git a/src/ioc/db/callback.h b/src/ioc/db/callback.h index 2732f9d5e..66a949036 100644 --- a/src/ioc/db/callback.h +++ b/src/ioc/db/callback.h @@ -47,14 +47,16 @@ typedef struct callbackPvt { typedef void (*CALLBACKFUNC)(struct callbackPvt*); -#define callbackSetCallback(PFUN,PCALLBACK)\ -( (PCALLBACK)->callback = (PFUN) ) -#define callbackSetPriority(PRIORITY,PCALLBACK)\ -( (PCALLBACK)->priority = (PRIORITY) ) -#define callbackSetUser(USER,PCALLBACK)\ -( (PCALLBACK)->user = (void *)(USER) ) -#define callbackGetUser(USER,PCALLBACK)\ -( (USER) = (void *)((CALLBACK *)(PCALLBACK))->user ) +#define callbackSetCallback(PFUN, PCALLBACK) \ + ( (PCALLBACK)->callback = (PFUN) ) +#define callbackSetPriority(PRIORITY, PCALLBACK) \ + ( (PCALLBACK)->priority = (PRIORITY) ) +#define callbackGetPriority(PRIORITY, PCALLBACK) \ + ( (PRIORITY) = (PCALLBACK)->priority ) +#define callbackSetUser(USER, PCALLBACK) \ + ( (PCALLBACK)->user = (void *) (USER) ) +#define callbackGetUser(USER, PCALLBACK) \ + ( (USER) = (PCALLBACK)->user ) epicsShareFunc void callbackInit(void); epicsShareFunc void callbackShutdown(void); diff --git a/src/ioc/db/dbScan.c b/src/ioc/db/dbScan.c index ba927a04b..08c5c4af3 100644 --- a/src/ioc/db/dbScan.c +++ b/src/ioc/db/dbScan.c @@ -813,9 +813,11 @@ static void spawnPeriodic(int ind) static void ioscanCallback(CALLBACK *pcallback) { - ioscan_head *piosh = (ioscan_head *) pcallback->user; - int prio = pcallback->priority; + ioscan_head *piosh; + int prio; + callbackGetUser(piosh, pcallback); + callbackGetPriority(prio, pcallback); scanList(&piosh->iosl[prio].scan_list); if (piosh->cb) piosh->cb(piosh->arg, piosh, prio);