Tweak to callback API.

This commit is contained in:
Andrew Johnson
2014-12-02 11:30:37 -06:00
parent 42a3cf8e11
commit 0f23784b32
3 changed files with 19 additions and 10 deletions

View File

@@ -20,6 +20,11 @@
-->
<h3>Callback subsystem API</h3>
<p>Added a new macro <tt>callbackGetPriority(prio, callback)</tt> to the
callback.h header and removed the need for dbScan.c to reach into the internals
of its CALLBACK objects.</p>
</body>
</html>

View File

@@ -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);

View File

@@ -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);